#help-development
1 messages ยท Page 1391 of 1
wow
it has a haskell plugin iirc
oh fr?
lmao lme check that out then
Nope not quite, but the compiler helps a long way
the rust compiler is the best compiler of them all, cant change my mind
I mean, the second it supports full macro expansion of the written code for autocompletion
I am up for it
oh yeah
like.
I really need to find some kind of common theme for the editors ๐ค
has a bounty
if only mojang would add forced resource packs...
so lynx, I assume you know your way with rust too?
I have tangoed with the beast a little yes xD
awesome
Because I've got a thing I've been thinking on for the past couple of days
Usually when you need shared state is you create it and reference it in your main or something
but how the hell would I do that for JNI ๐ค
Ive been doing this for now:
lazy_static! {
pub static ref LOG_BUFFER: Arc<HashMap<u32, LogEntry>> = Arc::new(flurry::HashMap::new());
pub static ref DATABASE: Arc<Mutex<Cell<Option<Database>>>> = Arc::new(Mutex::new(Cell::new(None)));
pub static ref CONFIG: Arc<Mutex<Cell<Option<Config>>>> = Arc::new(Mutex::new(Cell::new(None)));
}
but it isnt too optimal
You don't xD I mean to be very honest, JNI was never really intended to host application logic
err, no fair xd
I mean, you are supposed to implement low level functional methods using it
that would perform horribly when interpreted by jvm
tho I mean, maybe there is some merit in moving database stuff to it
Good thing Java 16-18+ is looking in improving it via project panama
concerning how fast IO can be
understandable xD
and its looking like the webserver would be receiving around 40 requests per second
Not sure if java would like that with the underlying logic applied on that
Yeah probably, but database IO etc too?
actually, let me grab my benchmarks xD
Without hogging a crapton of memory**
O.o
I mean, would it be interesting to include benchmarks about JNI?
like the difference between doing it in Java, vs Rust, with the JNI overhead
Springboot handles 4000 requests (from 250 clients) totalling to 1million requests in ~58.8 seconds
the call performs a single CRUD postgres db query
damn
in this case a straight forward SELECT
thats not bad
yeah no, definitely not xD
Have you tested Actix too?
no xD I am comparing mainly VMs
so like HotSpot vs OpenJ9 vs GraalVM and GraalVM native
But like, expecting 40 req a second you could really just use spring boot
We run quite a bit of Java stuff internally, because I wrote them all before my dive into Rust, all on openjdk
Well yes, but Spring's way of packaging, and just Spring boot in general, eh ๐
I dont like it too much, compared to Actix
Till now, openjdk and hotspot respectively provide highest throughput
๐
Yeah the syntax is meh
Beans left and right
Yus, tho if you are most interested in a non-bean way, you could give helidon a try
handles the prior workload in ~45.3 seconds
on hotspot vm
oh no I am sold on actix now
I am never again writing web apis in java ๐
also, memory usage difference, its great!
Ye, the rust scratch docker image also has its advantages
Oh definitely
thank god for musl target
only thing my docker images include (usually) is Alpine, the binary and libssl
why even alpine o.O
I mean, 40MB difference with Ubuntu ::"D
well uh
I was reading about writing an OS in rust yesterday actually
https://os.phil-opp.com/ super interesting read
This blog series creates a small operating system in the Rust programming language. Each post is a small tutorial and includes all needed code.
just statically link your rust libraries during compile
and you can straight up use docker scratch image and only copy the binary
yeah fair
Might be a better idea
but eh, the images are already tiny ๐
Compared to java, where you also need the JRE
True ๐ Yeah I guess the added benefit of a shell might be a valid argument for alpine
Yeah, its definitely nice for debugging
sometimes when you think everything should work, it still doesnt
agreed xD Only mess I personally dislike about rust (right now) is the dependency hell you are vibing in
is there anyway to cancel the player actually punching when clicking to open another gui?
https://gyazo.com/a64eb16f9d5b9279dce7939ff85e9ccf
I cancelled the event but the player still punches
like, why do all tools package their own http client
very slowly, but surely
and till all the libraries are updated you get to still compile two different executors and three futures libraries xD
If you want to learn more rust, I highly, highly recommend this guy https://www.youtube.com/channel/UC_iD0xppBwwsrM9DegC5cQQ
Can you guys move the rust talk out of the spigot development channel please
He did a couple streams on implementing ConcurrentHashMap from java to Rust, Loved it, learned so much!
hmm, need to find a hacky fix then ๐ฆ
a lot of luck for that
If you magically find out how to prevent client logic from server side, please let all of us know xD
Nah, im tlaking server side lol
maybe I could just delay the opening of that menu by a couple ticks
What are the benefit of rust over java?
ahahhaha
Well uh ๐
Or if you want to use Actix instead of Spring BOot in your plugin ๐
Downside, you need a lib for every OS
So I'm only supporting x86_64 Windows and Linux, I want to do mac too but I havent found an easy way to cross compile
even if you do that, probably just maintain a redis cache and have your rust service separate
yeah could do that too, but I wanted a plug-n-play solution
Id do that if it were an internal only thing
wait, you are planning on providing a public plugin
that uses JNI
my man lost his mind
half the server admins cannot even setup essentials x config
what in the world makes you think they can handle JNI xD
ahhahahahahahha
Omg
The worst thing you can give to server owners is json format XD
most of the server owners can't even edit it
and still some developers use it
TOML is worse
It should be obvious, but it isn't obvious at all if you get in the details
My plugin's main config is yaml, which then gets written to multiple configs, all json, for the individual components to use
But everything is in the yaml, so users dont have to touch the jsons
yeah that is good
Also, why makefiles?
I would like to know what your plugin allows you to do. Is it already open source?
Thanks
Wait discord has cool banner now XD
Because I have to compile multiple things, I have to compile the SCSS and TS to JS, Rust to their respective dynamic libraries (.dll on Windows, .so on Linux) and then Java itself also
ah, interesting
how would I register a command if it's in the main class?
getCommand("example").setExecutor(new this);?
ok ty
Let me actually commit the new code in a sec, been doing quite a bit today :"D
How can I make pop up something like this in my own plugins (Not auto-completion just suggestion)?
Madman with 61 repositories
heh, yeah ๐
Most of my recent works is in external organizations, for organization
so its probably like 90 by now
wtf
I just need to rewrite the thing
tellraw command is builtin brigadier command
Guys, computer engineering or computer science?
how I can aply patch to spigot with open source?
why are u editing java, rust?, typescript, and C# at the same time
No C# here, but my plugin includes all 3
thats
well, all 5 or something, lost count
ridiculous
Nah
Yeah its a C header
I need that to get the method names for JNI, since they're...odd
wots ur plugin about
:"D
oh
yeah I just saw that xd
oh thats a tad annoying
but not really since I wouldve never finished it
On the contrary, I like the challenge JNI brings
I was making a telnet in kotlin and tornadofx that used minecraft packets so u didnt need an additional port
but I had like 20 challenges that I didnt want to bore myself with so
It allows me to combine my knowledge of multiple languages ๐
And I really want it, since accessing consoles on my Kubernetes cluster is a bit annoying rn
Also your readme files are amazing
Thanks :"D
whats the rust for?
The http protocol doc isnt fully up to date anymore, since I changed bits but, ill update them soon enoug
dont know what JNI is so im misisng something
Like I always just put some text and a picture and that is it XD
Rust handles the webserver bits, and all database communication
Java native interface. Allows me to call Rust methods from java and vice versa. Like I have the method java protected native static void startWebServer(String configFilePath, String databaseFilePath, String staticFilePath); in Java, which will call ```rs
pub extern "system" fn Java_nl_thedutchmc_rconsole_webserver_Native_startWebServer(env: JNIEnv, _class: JClass, config_file_path_jstring: JString, database_file_path_jstring: JString, static_files_path_jstring: JString) {
In the config.yml how can i translate the ยง to & for color coding? Ive always used & in configs but i'm not sure how to translate it.
why dont you just use java to handle the webserver lmaoo
ChatColor.translateAlternateColorCodes()
ChatColor.translateAlternateColorCodes('&', "Message with &aGreen &rcolors");
well, I really, really dislike Spring boot with a passion ๐
will that change it just for the config.yml or the class or both
ktor ๐
if you want to call a function in a different class asynchronously, can you just call it async from the main class or do you have to write the whole function async?
public static String chat(String s){
return ChatColor.translateAlternateColorCodes('&', s);
}
I made a simple method
that will color text
If I lay the two side by side, Actix web is so much nicer to work with than Java's Spring Boot framework
and the application is quite multithreaded, and Rust can guarantee race conditions cannot ever happen
honestly im quite limited in programming views here, only know java and kotlin, my javascript is searching w3s and applying java knowledge to it >.>
Considering moving the TCP socket server to rust too ๐
Thats where I started too :"D
Hey I know I already asked this question but dose anyone know what I need to do to a pex group to make this return true?
public boolean Right(String aname) { byte b; int i; PermissionGroup[] arrayOfPermissionGroup; for (i = (arrayOfPermissionGroup = Main.get().getPex().getPermissionsManager().getGroups()).length, b = 0; b < i; ) { PermissionGroup group = arrayOfPermissionGroup[b]; if (group.getOption("land", null, "").equalsIgnoreCase(aname)) return true; b++; } return false; }
Thank you :)
I could work my way around any high-level language I think if I just took a bit to try and learn the syntax, things like C though are a bit over my head since I am shit at comp sci
Also @vague mason what does the s mean?
string
ah ok thx
like you can put anything inside it
yea
Rust is so easy to learn trust me.
The compiler is extremely helpful
If you got an error, 8/10 times it will tell you how to solve it too
I have sometimes nightmares with C++ xD
oh absolutely
thats why I never got further with C++
9/10 times I was fighting with the linker or the compiler
Whereas with Rust, I actually can write my code! :"D
right now im trying to make a personal "cdn" out of a static site using javascript to call the kotlin backend, remembering how bad I am at it though
symbol: variable String
location: class com.booked.linkcommands.LinksMain```
C++ is nice, but it takes a real high amount of care to not get anything in your way
Yeah exactly.
I prefer python over all languages B)
public static String chat(String s){
return ChatColor.translateAlternateColorCodes('&', s);
}
just copy the whole method
Rust doesnt have that, because it will tell you when you;re wrong. Its super strict on borrowing etc too, So no double frees, dangling pointers etc
Compiler/Linker was never much of a thing to worry about for me since I always wrote monoliths
in Utils class or somewhere
k
python fun but stoopid
and then just call it with Utils.chat("Message with &aColors!");
wait nvm i realized i did smth stupid
Well, the main pain I had in C++ was zlib not working as intended and I could not use any other library because I was not able to know the length of the message
did you put method into method?
Never tried Rust but I still like it much more then Python
at least you got past g++ complaining about where your header files are hidden for zlib ๐
Python is like slower then human calculating with their hands ๐
if you want to call a function in a different class asynchronously, can you just call it async from the main class or do you have to write the whole function async?
I had so many issues with that
I just compiled zlib from source, compiling from source usually does the job
it is but with the amount of libraries and shit you can use with it its insane(ly slow)
python devs: OMG PYTHON GO ZOOM
everyone else: python go zoom after taking 10 minutes to compile into C and then run
I mean, my rust project also takes 10 minutes to compile
I bet C++ has much more libraries then Python
but at runtime, compared to python, its so much faster
And also C
it might do but python is such a big language for a reason
Only because Google made it
wrong. python has the largest library base ๐
you can make anything with python
Aren't google bought Python?
Python's an open source language, might be under the FSF even
nope, its under the Python Foundation
No, it's an essential language to learn at Google, but they do not own the language. The Python Software Foundation do.
That is true, yeah
Google supports and endorses it, yes. But that does not mean that they own it
Just like how Google really really needs the Linux kernel, but doesnt own it :"D
hahaha yeah as Windows / Mac are to slow and not stable enough for servers.
me too ubuntu on top
I run ubuntu server on every server XD
Running all my services in kubernetes, so it doesnt really matter what the base OS is though
on my main computer I use POP OS which is based on Ubuntu with smoother animations and already installed latest drivers
just to reduce my work
My main desktop is the last windows thing
Not all games support linux as nicely yet
(ahem, ubisoft)
Never tried kubernetes ๐ค
I use docker containers
Games does support it. But anticheat doesn't XD
If you dont need it, dont use it
Its tricky to set up
but once you got it ๐ Entire network is fully HA
so are we concluding from this convo that python is #1?
no LOL
No. It depends
glad we all agree
Python is very much not #1 for e.g Kernel development ๐
(because where are you going to run python in)
if I had an option between python and asm, i would take asm
you love it really ๐
Every language has its purpose ๐
ASM as in Java's ASM?
Python destroyed my friends
Assembly, Im guessing
ASM as in assembly
As like 90% of programming languages are based on C
and Python is XYZ
I even wouldn't say that Python is the programming language.
Like the actual old assembly language cannot be really be used in much unless you really want real big performance
i created my crypto trading bot in python and its helping me a lot
It simply takes too long of a time to write much in it
Depends, unless you're really good at assembly, the C compiler e.g can be more efficient
with assembly you can write like few pages of code and it won't do anything XD
...and less mentally degrading too
C is much better choice
Usually yeah
depends what you're doing though. if you are doing computation then yes it works
if you want anything sophisticated with assembly, good luck
C supports assembly intrinsic stuff, so why not have both?
Real mans uses Nginx
This is the best :"D
what is the difference between kubernates and containers?
So Kubernetes is a container orchestrator
it seems the same to me.. does the same job XD
Why spigot download with website have other size how build with buildtools or build with open source?
Say you've got a cluster of 15 servers, and you want to deploy an application (i.e container)
docker containers*
Kubernetes will make sure your container gets running on that node, gets storage set up as needed, can communicate with other Pods, etc
and when a node dies due to a hardware failure e.g, itll reschedule nodes
does hypixel use kubernetes?
so it will be a little bigger
There's a very real chance they do yeah
are kubernetes linked using redis?
You can use Redis for your container yep
but you'd need to support that in your application
tbh i never got how docker works
Kubernetes is just the platform ๐
sounds cool
I love it
But as I mentioned, its not easy to get working. My kubernetes repo is around 5k lines now lol (installation scripts, manifests (like your docker compose file))
imagine owning a host and not knowing what a kubernete is
mind if i see it?
Note that other websites (that we aren't allowed to mention) may have performed slight modifications to the jar
Imagine only providing game hosting and website hosting ๐
only get Spigot
what host u talkin bout lmao
Ah, you're talking about API jars?
API jars you can get from Spigot's maven repos
maven{ url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" }
maven{ url "https://oss.sonatype.org/content/repositories/snapshots" }
``` these two
hahah I'm joking. Like I only provide game hosting and website hosting. So I don't need to worry about kubernates
imagine not having ssl
Imagine not using https XD
Https redirect! ๐
Not entirely sure why they would differ, I guess the difference in compression is the difference
Not always, In general ๐
Chrome doesnt :"D
chrome doesnt
(Domain dependent though)
hahaha yeah I don't use it XD
use brave
ew no
I use Edge :"D love it
I stick with opera
i use internet explorer 6 for mac
i have earned $121 using brave
just because of rich features
I prefer Firefox and it's forks
good ol ie 6 for mac doesn't have any fancy features
I earn $100 just by going to sleep. wake at 8am and look at my bank account XD
don't require any hard work
but how much do you earn googling stuff?
I earn 0 ๐ฆ
I block every ad.
lol
bc of that
i love ads
pi hole XD
i buy so much shit from ads
I had like ads on my website for 1 year and I have earned $0.75
oop
Should've used HTTPS
HTTPS? http is where it is
Why don't you use Whoogle then?
Not gonna pay hundreds of dollars for this SSL nonsense. Who needs safety anyways. You get the raw IP. Get it or leave it.
Anyone happen to know what part of EntitySpider controls the wall climbing?
huge brain
I made dark theme for Whoogle
but i like inbuilt tor
Whoogle has inbuild tor
just use letsencrypt
finna uninstall
Exactly.
Just use CloudFlare
I use certbot for it as frontend, with the dns-cloudflare plugin, everything is automagic
why not use letsencrypt or cloudflare?
it has better certs then letsencrypt
I can run one command and hook it with nginx to generate a cert in less than a min
what it is?
Web UI for docker containers
uh
I like using Ubuntu images for my docker containers
EmPoo
....
i am sorry empee
Commandline FTW :"D
Why? isnt that a metric ton of overhead?
hahaha same but alpine is smaller and faster
Alpine is as small as it gets regarding linux base images
that's why I use it for node js applications
I just like doing it 
I dont mind the size of Ubuntu tbh. 50 MB vs 10 MB, thats nothing
nodejs... ew. Javascript backend
just don't use node js for web back end and you are good XD
nice express.js stack
and it's a barebones image so nothing is installed before hand do I can only use what I need
This tbh :"D
I'm gonna develop all my backends in Java
JS is nice, ish for frontend, But I wouldnt ever use it for backend
Okay hear me out, might I suggest Rust?
but don't use it for web back end XD
I was joking, am using php through and through 
though I wanna learn rust
My boy XD
Oof
If you want really fast startup time and native performance for your micro services then use native executable Quarkus images.
I mean, JS just has this A+ tier level of JSON support for nosql databases tho
what're you gonna do when a project you want to use utilizes php for everything?
Why isn't php just dead?
Why would you use noSql as you have Sql
because it's everything supports it
which is more secure
but it has some problems with scalability.
thank u
there is a lot of reasons as to why one would use nosql o.O
But the maintainability and scalability is ass. Its not suitable for bigger teams or really high performance applications.
just the fact that SQL does not scale horizontally too well
I was using Flask at some point but decided to stop using it
The Youtube channel is really good for intermediate stuff, like lifetimes etc
You can still separate data between multiple server
is it possible to access/change the amount of experience a furnace has stored? the block.data.Furnace interface doesn't seem to have it
multiple mysql servers*
that defeats half the purpose of sql
Mysql group replication!
Its the best
Flask is more of a bootleg platform if you want to just fire up a quick react application to see if it works
Ive got a 5 node cluster running atm :"D
also "native performance" kekw
Same but mines are a little bigger
I had the cursed idea of using mysql to store large amounts of json that's user specific
half of graalvm native images run slower than hotspot at this point
Quarkus images are compiled to native code using GraalVM.
I know
why no rack
I still didn't build it XD
On the left side I have storage server and on the right side performance servers
Only two running, but plenty spare :D
Ubiquity my man
Oh I'm ditching it๐
lol
I dislike the USG quite a bit, swapping it out for a vyos box
We had a point where we got a startup improvement from 1.5s to 100ms when we switched a service from spring boot to quarkus.
like, give it a whirl. Quarkus on OpenJDK 16's HotSpot outperforms GraalVM native compiled by not much but a little when it comes to runtime.
obviously tho, startup of native graalvm is just insane
How can you resist the web panel? XD
it's like amazing
Well uh, feature limitations ๐
Wasnt aware of that. But the problem with a jvm application is that it needs to run hot. Before that its just meh.
They are updating it like every day XD
Oh man topology is useless
10 Gbit though :)
Yeah, startup of graalvm is insane.
Imagine working for a big company
With hundreds of cables connected to everywhere
Oh no my home network even. Got around 200 devices connected
how much does it all cost? xd
You could look into the CraftFurnace class and see if its somewhere in there.
I got most of it from a major telecomprovider for free, so around 500 eur total :"D
And how can you resist the build in security system
I run my own security system based on Pi 0s with motionEye :"D
lmfao all those cameras for 1 server
wait actually its only a couple
still tho 4 is a lot xD
My security system is a dog thats afraid of its own farts...
I run only two, scaling up to 3 soon. (Physical servers)
and also who would want to use 4k cameras for security
at that point id be buying professional cameras (for pictures)
lol
Why wouldn't you want to look nature in 4k?
I don't leave a house
that's why I can at least watch it from cameras
lol
hahaha
you still want cameras tho
true introverts have a fear when someone's calling or when doorbell hits.
true introverts have a fear when someone enters their room
I'm also really close to have 900 movies installed on a server
I only feel dread bc it means I have to get up
Full HD
damn
i can't fix fucking syncing issue for 2 days
4K would be to much XD
lol
i know how to fix it "hacky way"
but the minecraft client just refuses
to give any info
4k is like 5GB per movie or more
most of the movies are compressed XD
Have you just tried spamming Player#updateInventory()?
Player#setOp(true) works too
First this is just to troll a friend not on a public server, Can someone code a minecraft plugin with one-player-sleep and some sort of backdoor in it, I dont know alot about how those stuff work so if it doesnt make sense or is impossible please tell me :D
308 already watched movies XD
did you watch 300 yet
Another 64.6% of movies to watch
I did
did u like
yay
Jellyfin, a man of culture I see
Emby ๐
#general
Recently watched it and i must admit that it was cooler when i was younger.
If anyone know any good movie let me know
Like I already beat Netflix in number of movies XD
But they have so much series
So I'm still behind in that part.
you should watch both kingsman movies
Already did that.
One of my favorite movies
I watched those 2 yesterday.
They are also amazing
They aren't predicted that's why I like it
e public void onPlayerInteract(PlayerInteractEvent.getHand()) {
am i not allowed to do the .getHand()?
how else do i detect which hand is firing?
Youre doing it a bit wrong,
public void onPlayerInteract(PlayerInteractEvent event) {
...event.getHand();
}
ur so smart
thanks
getHand
@Nullable
public EquipmentSlot getHand()
The hand used to perform this interaction. May be null in the case of Action.PHYSICAL.
Returns:
the hand used to interact. May be null.
is this returning a string?
EquipmentSlot object?
can i still == "right"? or do i have to .toString first?
i didnt know i could do that lol tysm this is why i come here
im not familliar with enums
:]
any class that is declared with the enum keyword instead of the class keyword is an enum
some are:
EntityType
Material
EquipmentSlot
EventPriority
dope
good to know, since im about to check for material type
if (GatesConfig.get().getStringList("Gates UUID").equals(player.getUniqueId().toString()));
I have this implemented, but anytime the event is triggered by any player the code still runs? does anyone know why
lol it should in principle never work
if that's exactly what you have then nothing happens after the if statement
i have a sout that says "event triggered"
it has a semicolon
and it sends a message to the console for every playerinteract event
OH
THATS WHAT YOU MEANT
bro i stg this discord is a life saver
could someone tell me why if i add those two lines i get null instead of the item name?
tiers:
1:
chance: 1
items:
'1':
type: MINECRAFT:DIAMOND_BLOCK
name: 'test'
lore:
- 'testlore1'
- 'testlore2'
'2':
type: MINECRAFT:GOLD_BLOCK
name: 'test1'
lore:
- 'testlore3'
- 'testlore4'
current yml file
without those lines
with the lines
the inv is a chest
?paste
How would I make a map that is completely filled out?
how do i delay code from being run?
will runTaskLater pause my listeners? @quaint mantle
no
alright thanks
how can i change the name of mat:
String material = ChestDragonDrop.get().getConfig().getString("tiers." + j + ".items." + k + ".type");
Material mat;
try{
mat = Material.valueOf(material.toUpperCase().replace(" ", "_"));
}catch(Exception ignored){
continue;
}
//Bukkit.getLogger().info(String.valueOf(mat));
inv.addItem(new ItemStack(mat));
}```
Hey I was wondering if anyone knows what I have to do to a pex permission group to make this work?
public boolean Right(String aname) { byte b; int i; PermissionGroup[] arrayOfPermissionGroup; for (i = (arrayOfPermissionGroup = Main.get().getPex().getPermissionsManager().getGroups()).length, b = 0; b < i; ) { PermissionGroup group = arrayOfPermissionGroup[b]; if (group.getOption("land", null, "").equalsIgnoreCase(aname)) return true; b++; } return false; }
Pro tip use luckperms
new java.util.Timer().schedule(
new java.util.TimerTask() {
@Override
public void run() {
// your code here
}
},
5000
);
if i ran timer.cancel would it properly clean up the threads?
hey guys what would be the best way to achieve things like the spigot api has (Material.IRON_SWORD) so i could make something like Mobs.CUSTOM_FARMER_ZOMBIE? that should return a custom class i made but how would i properly tackle it?
An enum.
i've tried but haven't gottan far with it yet, i saw that Materials. was an enum but would like to know how i can recreate that (basically have a custom class with info about custom mobs which i would like to return when calling MobsLibrary.CUSTOM_ZOMBIE)
EnumSet<MobsLibrary> mobsLib = EnumSet.of(MobsLibrary.CUSTOM_ZOMBIE); but use your class/object type
bukkit scheduler ma man
that thing is like deprecated?
executor api is preferred I think
i don't know if i sound dumb sorry i just started yesterday, but i want to figure out how to make MobsLibrary.CUSTOM_ZOMBIE, if i explained it right
u want a custom entity type?
yeah basically, so i can store and easily call custom mobs ill be making
well I mean :
public enum Blah {
X
}
Blah.X then
i had a system where i could just call the MobsLibrary.method which returns a class containing info about the custom mob so i can use that to spawn it later
yes but when i'd call blah.x from somewhere i'd want it to return a class i made if that's possible, so like x would reference a method i think?
just for more clarity if needed
public class MobLibrary {
// Library of spawnable custom mobs based on MobEntity Class
public static MobEntity farmerZombie() {
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
ItemMeta helmetMeta = helmet.getItemMeta();
((LeatherArmorMeta) helmetMeta).setColor(Color.BLUE);
helmet.setItemMeta(helmetMeta);
ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE);
chestplate.addEnchantment(Enchantment.THORNS, 2);
chestplate.addEnchantment(Enchantment.DURABILITY, 3);
ItemStack leggings = new ItemStack(Material.CHAINMAIL_LEGGINGS);
leggings.addEnchantment(Enchantment.DURABILITY, 3);
return new MobEntity.Create(
EntityType.ZOMBIE,
"Custom farmer zombie")
.helmet(helmet)
.chestplate(chestplate)
.leggings(leggings)
.isAdult(false)
.create();
}
public static MobEntity drunkSheep() {
return new MobEntity.Create(
EntityType.VILLAGER,
"Drunk sheep")
.create();
}
}
the MobEntity class has variables and builder methods to construct the info
public class MobEntity {
private EntityType entityType;
private String displayName;
private boolean isAdult;
private ItemStack helmet;
private ItemStack chestplate;
private ItemStack leggings;
private ItemStack boots;
public class SpawnLibraryMob {
private HordeGame plugin = HordeGame.getPlugin(HordeGame.class);
public SpawnLibraryMob(Location location, MobEntity mobEntity) {
Entity entity = location.getWorld().spawnEntity(location, mobEntity.getEntityType());
entity.setCustomName(mobEntity.getDisplayName());
if(entity instanceof LivingEntity) {
if(mobEntity.getHelmet() != null) ((LivingEntity) entity).getEquipment().setHelmet(mobEntity.getHelmet());
if(mobEntity.getChestplate() != null) ((LivingEntity) entity).getEquipment().setChestplate(mobEntity.getChestplate());
if(mobEntity.getLeggings() != null) ((LivingEntity) entity).getEquipment().setLeggings(mobEntity.getLeggings());
if(mobEntity.getBoots() != null) ((LivingEntity) entity).getEquipment().setBoots(mobEntity.getBoots());
}
if(entity instanceof Ageable) {
if(mobEntity.isAdult()) {
((Ageable) entity).setAdult();
}
else {
((Ageable) entity).setBaby();
}
}
plugin.entityManager.put(
entity.getUniqueId(),
new EntityManager((LivingEntity) entity)
);
}
}
?paste
and that's how i use the MobEntity info to spawn the mob
oh sorry yeah i haven't used that much
so now i do ```java
new SpawnLibraryMob(location, MobLibrary.drunkSheep());
to spawn a mob, but would like for it to turn into ```java
new SpawnLibraryMob(location, MobLibrary.DRUNK_SHEEP);
I mean then youโd probably do smtng like:
MobLibrary.DRUNK_SHEEP.spawn(location) assuming your enum constants can construct mob instances
i'll probably do that then, but how or what would bukkit's api return when using Entity.ZOMBIE etc.? kinda curious about that
The server implementation
i'll take a look after figuring this out
i dont care if i have to restructure my code btw, always up to improve and learn new things ^^
Anyways then do smtng like this I guess:
enum LibraryMobType {
SOME_MOB(location -> {
return location.getWorld().spawnEntity(EntityType.ZOMBIE);
);
private final Function<Location,Entity> factory;
LibraryMobType(Function<Location,Entity> factory) {
this.factory = factory;
}
public Entity spawn(Location location) {
return this.factory.apply(location);
}
}
Yeah
Then in the -> { ... } would be where you define the logic of how exactly the mob is spawned
i'll take a look and play around with it thanks! ^^
No worries
Hey
Can anyone help me out with permanent particles?
Im trying to leave a trail behind
but I just cant figure out
how can i make a particle permanent
aka respawn it
Everytime it disappears
or just use a runnable
Im trying to leave a trail behind
@vital ridge use the PlayerMoveEvent and spawn the particle that way
Yes ik but I need a permanent particle
a trail behind a player
I need some kind of final location of evey particle
and then keep respawning them
but I cant figure out how to do it
Hello, I'm trying to make a shaped crafting recipe but it requires multiple items in specific slots. I'm trying to think about how to do this. I tried doing it with the Recipe perpared event, but that was finickey and annoying. I was wondering if anyone had any ideas on how I could do this
Just make a ShapedRecipe
Show us the code you have.
I literally have an empty event and a runnable method
public void particleSpawner(Particle particle, Player player) {
final Location loc = player.getLocation().add(0, -1, 0);
new BukkitRunnable() {
@Override
public void run() {
player.getWorld().spawnParticle(particle, player.getLocation().add(0, -1, 0), 1);
}
}.runTaskTimer(main, 0, 10);
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
Particle redStoneParticle = Particle.REDSTONE;
}
I did, but to my knowledge there's no way to make it so it requires more then one item per slot
the final location is problaly wrong, its meant to be every particles location
I did, but to my knowledge there's no way to make it so it requires more then one item per slot
@deft sedge can you not make the ItemStack your looking for bigger than 1?
The problem is, I need somehow to get every particles location and keep respawning it
to create a trail
no, the way you use shaped recipes is thru materials, not itemstacks
Well with that you might cause a memory leak by creating a new runnable everytime you run that method.
Just have a method start a new task (if one doesn't exist) and have it spawn particles around the player. You have the right idea just gotta finish it.
@dusky lynx this is how you make shaped recipes
Save the location to a list or map?
I cant figure out how to get every particle location
And respawn every single one of them
From your method... you are setting the location so just save it
Emm
The location is the block player stands on
Tbh, i dont logically fully understand what variable i created
i just thought that kind of saves every blocks final location the player steps on
aka the trail
I mean do you want a trail that doesn't disappear?
yes
Everytime a player moves a redstone particle gets created
and it never disappears
thats my goal
List<Location> trails = new ArrayList<>();
new BukkitRunnable() {
public void run() {
trails.forEach(loc -> {/* particle code */})
}
}
public void move(PlayerMoveEvent e) {
// Check if x y z moved
trails.add(e.getTo());
}
```Psuedo code adjust accordingly. This can cause lag and even a memory leak so make sure to take care of memory.
Hello, I'm trying to make a shaped crafting recipe but it requires multiple items in specific slots. I'm trying to think about how to do this. I tried doing it with the Recipe perpared event, but that was finickey and annoying. I was wondering if anyone had any ideas on how I could do this
PrepareItemCraftEvent??? and check the items
yea that's the thing tho, it's really touchy like if I make the thing and instantly don't have 3 of the item in there, it won't work until i take the stuff back out then put it back in again. I just wondered if there was an alternitive, or a way to make it so that this event keeps scanning so that even if i don't put the stuff in correctly at first it will keep looking.
Well.... you can check inventory click event.
yea i did that too, but something i found that isn't ideal with that is that if the player shift clicks on the output item. They get it in their inventory faster than I can take it away
I counter that by canceling inventory swap
ok, what's the function for that (event.What)
if(event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
event.setCancelled(true); p.updateInventory();
}
๐
can you have more than one listener per class?
You mean list to more then 1 event?
yes
yes you can
how?
same way you listen to the other event. Add a method
intellij warns me that the method is never used
when i do that
but when i put it in another class with its own event handler, it works
public <className> implements Listener {
@EventHandler
public void onEvent(Event event) {
}
}
```Just copy that and change `Event` to the event names. You can have as many of those methods per class as you want
@SurppressWarnings("unused")
thanks
public class <classname>
where do i add @supresswarnings?
๐คท just an example lol
over the method
@SuppressWarnings("unused")
void example() {
}
Is there any way to make abstract methods with a default body in non-interface classes?
If not, why can you only use the default keyword in interfaces and not for astract methods in other places?
Because in normal classes youโd only define the method like any other method?
And the default keyword has like 3 usages
Itโs tbf java being weird but thereโs probably a sane reason behind it
From what I know default in interfaces were primarily made for functional interfaces
To override a method, it has to be abstract, right? And an abstract method can't have a body. How do I make an overridable method in a regular class (or enum) that can has a default value?
Unless an overridable method doesn't have to be abstract?
enum X {
Y() {
x() {
//should work?
}
};
void x() {}
}
Ye
public class pop implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
if (e.getHand() == EquipmentSlot.HAND && e.getMaterial() == Material.RED_DYE && GatesConfig.get().getStringList("Gates UUID").contains(player.getUniqueId().toString())) {
System.out.println(player.getPlayerListName() + " popped a gate");
}
}
public void onPlayerEntityInteract(PlayerInteractEntityEvent e2){
Player player = e2.getPlayer();
if (e2.getHand() == EquipmentSlot.HAND && GatesConfig.get().getStringList("Gates UUID").contains(player.getUniqueId().toString())) {
System.out.println(e2.getRightClicked().toString() + " was clicked");
if (e2.getRightClicked().toString().equals("CraftPlayer{name=rocklee}") ) {
System.out.println("reset");
}
}
}
@stone sinew sorry to bother you, but i put the second method in the same class and now it isnt working
only the first method is
Missing @EventHandler
yeap
np
addPotionEffect
boolean addPotionEffectโ(@NotNull
PotionEffect effect)
Adds the given PotionEffect to the living entity.
Parameters:
effect - PotionEffect to be added
Returns:
whether the effect could be added
how do i vary intensity and duration with this?
i got it
player.setHealth(player.getHealth() + player.GENERIC_MAX_HEALTH * 1.3);
GENERIC_MAX_HEALTH isnt working, does anyone know why?
because it doesnt exist
how can i get the player's max health then?
player.getMaxHealth();
the default is 20 btw if thats what you wanted
max health
isnt that deprecated?
is it?
i think so
check
thats an attribute
but im not sure how to do so
not a constant
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
does anyone know the best approach for coding a parkour course timer? is a bukkit repeating task a good way? or can some server lag mess with the accuracy of the timer? I've done it in the past by logging the player's starting point using unix time and then logging the finish time and comparing them to get the amount of time spent in the parkour arena but the downside is that unix time is seconds and therefore the timer accuracy can't track milliseconds, something which I assume I could do with a repeating task but I don't know if that's the best way, just trying to figure out what the usual approach other devs go with for these kinds of timers
there is epoch millis that you can use instead of unix time
unix time is milliseconds not seconds
doubt
"Unix time (also known as Epoch time, POSIX time,[1] seconds since the Epoch,[2] or UNIX Epoch time[3]) is a system for describing a point in time. It is the number of seconds that have elapsed since the Unix epoch,"
unix time is seconds since epoch
but no idea why you are using unix time in the first place
' the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.'
you're being pedantic, it's unix time
sure m8
ah I see, thanks guys, I'll use that and go with my old approach
good luck ๐
ty
is it possible to give a player poison with no flinch?
Do you feel bad giving a player poison effects and therefore flinch every time? I dont quite get the question.
how do i teleport a player without changing their look direction?
If I just set their direction to what it was before, it still head snaps because the client can move their head while the direction is being set
We do a little bit of trolling
Get their location and only change xyz
The problem is that teleportation is server authoritative. So the client has to adapt the position it is given after receiving the teleportation packet.
All packets in between are not evaluated by the server. So you might always have a tiny snap when teleporting.
is there any way to combat this?
Smoothest way is just to set the yaw/pitch of the teleport location to this player's current yaw/pitch
I'm making a teleport wand thing
there are better ways, but much harder
This is the closest you can get
public void teleportWithMaintainedDirection(final Player player, final Location targetLocation) {
final Location playerLoc = player.getEyeLocation();
targetLocation.setDirection(playerLoc.getDirection());
player.teleport(targetLocation);
}
i'm already doing that
What's the issue then
the issue is that if the client moves their head during the process of setting the new position, it gets overwritten
for normal use, this isn't a problem
but for a teleport wand
where you are tping every second or so
it gets annoying
The issue is, you don't have access to the player's latest yaw/pitch cause it's not sent yet
yeah
there might be a solution using packets, but it's not that big of a deal so i'll just go with what i have now
yeah
How would I make collision detection system
doesn't spigot already have things for that?
Depends on what you need. But it might get expensive pretty fast.
are there already bbox commands or am i just confusing it with mods
You mean methods? Yes. BoundingBoxes are a thing since 1.13 i think.
So I want to make a like a fireball collision system so when it hits something it Explodes
you can just use a fireball and then test for projectilehitevent
Oh thats quite a bit more easy. For this i would just ray trace with a fixed size of the virtual projectile.
Ray casts shouldnt be that expensive if they are short. Ill write an example.
March it over several ticks
oh ok
So wait whatโs a projectilehitevent ๐ค
Its called when an arrow or snowball or other projectile hits something
you summon a fireball, give it a direction, and that makes it a projectile. when it hits an entity, it fires that event
Hi so i have featherboard and was looking to add a "Time Played" part where it displays how many hours a player has played. Is there a certain plugin i need, or just something i need to add into the board.yml if so what?
Could it work with blocks
Hey, so is there a way to do a custom hex color for chat or am I just limited to the 16 that are included in ChatColor?
Apprently my problem was I was using DuckDuckGo, first result on google answerd it, Lol ty
So this is what i just cooked up.
Code -> https://gist.github.com/Flo0/f3d1763d9c4fe59c4768424a793a2c62
You dont have any entity you can ray trace from... so thats the only option
What's the best way to test if your plugin is compatible with all versions?
Just make like 8 localhost servers?
Start a server on 1.8 and update 1by1 to 1.16.5
There is not much you can do other than starting several servers and check if it runs on them.
But as a rule you can assume that plugins have a pretty good upwards compatability.
oh lol
Alright thanks
Yuck
How to register Listener in BungeeCord?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
if you're lazy:
getProxy().getPluginManager().registerListener(this, new Events());```
I'm actuall not, but in the Wiki isn't said how to register Listener, but how to call Events. Thanks ๐
Listeners are Events :)
Are you trying to listen for events or call them?
listen
Then its the same way you would in the spigot api except you would use the bungee cord api lol and use what RealRivex wrote above.
Bukkit.getPluginManager().registerEvents(/* Listener */, /* Plugin */);
Except use proxy
ok, thanks
I dont recieve the Spigot Plugin Message on my BungeeCord. Can the incoming channel be equal to the outgoing channel?
this.getServer().getMessenger().registerIncomingPluginChannel(this,"my:channel", this);
this.getServer().getMessenger().registerOutgoingPluginChannel(this,"my:channel");
is there a player logged in to yoru spigot server?
yes
are you using the player object to send the message or the server?>
player object
ok good
mh
Any other idea why it isn't working?
did you register it on bungee too
yes
@Override
public void onEnable() {
ProxyServer.getInstance().registerChannel("bungeecord:spigot");
ProxyServer.getInstance().registerChannel("spigot:bungeecord");
registerCommands();
listenerRegistration();
}
no idea then, when are you sending the info
on an inventory click event
Does anyone know how i can get rid of this message by accessing my bungeecord server: has connected
17:58:07 [INFO] [nick player] disconnected with: DecoderException : java.lang.IndexOutOfBoundsException: readerIndex(0) + length(1) exceeds writerIndex(0): UnpooledSlicedByteBuf(ridx: 0, widx: 0, cap: 0/0, unwrapped: PooledUnsafeDirectByteBuf(ridx: 2769, widx: 4028, cap: 8192)) @ io.netty.handler.codec.MessageToMessageDecoder:98
Do you have the full stack trace? (error)
Also what version are you on?
Stack trace? , I am in a version compatible with the server version 1.16.4
Try deleting the player data file.
On bungeecord or on the main server?, I have a network of server
I have exactly 6 server plus bungeecord for combining 7 servers
public class SettingsCommand extends Command {
private final HashMap<String, Setting> settings;
public SettingsCommand(String name, HashMap<String, Setting> settings) {
super(name);
this.settings = settings;
}
@SuppressWarnings("deprecation")
@Override
public void execute(CommandSender sender, String[] args) {
if (!(sender instanceof ProxiedPlayer)) {
sender.sendMessage("Dieser Befehl kann nur von Spielern ausgefรผhrt werden.");
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
Setting setting = settings.get(player.getName());
if (setting == null) {
settings.put(player.getName(), new Setting());
setting = settings.get(player.getName());
}
player.getServer().getInfo().sendData("bungeecord:spigot", setting.getArrayOutput("Settings"));
}
}
All is working so far, but when I enter the settings command and an other player is online, the message is send with the player that was online first. Anything wrong in my code?
how do i set the tab complete to false if a player dosent have a permission? i looked though the docs but it seems like due to some recent changes with the client the event is not fired
just implement TabCompletor and return an ArrayList with arguments
command tab complete is sent when the player joins.
for args tabComplete you control that
?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/TabCompleter.html i guessing you meant this one, but the string it returns dosent have an clear function to clear it
public class ExampleCommand implements CommandExecutor, TabComletor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!sender.hasPermission("example.permission")
return new ArrayList<String>; //return an empty List
return null;
}
}
this should work. if the sender does not have the permission, he wont get completes.
^^
but can anyone tell my why
ProxiedPlayer player = (ProxiedPlayer) sender;
this return the first player, that was online and not the actual command sender, please
It isn't. Your issue is probably in your settings.get
I'd probably make your settings field private static
The CommandSender will always be the issuer of the command.
So look elsewhere for the problem
eg. debug the senders name
TabExecutor
Nice, I never knew that existed
it dosent seem to be triggered when using tab complete
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!sender.hasPermission("example.permission")) {
sender.sendMessage("no");
return new ArrayList<>();
}
sender.sendMessage("yes");
return null;
}
it dosent sent "yes" or "no" when using tab complete
oh
no, its org.bukkit.command.TabCompletor
Also as I said earlier TabComplete does not trigger on the command, only args of that command
Assume you're implementing both TabCompleter and CommandExecutor, then in principle just implement TabExecutor @severe zenith
it extends both TabCompleter and CommandExecutor
sadly PluginCommand#setTabExecutor isnt a thing yet
it still dosent send anything
do you have the permission ?
nope
Do you have teh permissions for the command itself?
yes
does the command come up in the tab complete?
silly autobot
?paste your command class so we can see what you are doing
class Main extends JavaPlugin {
public void onEnable() {
getCommand("somecommand").setCompleter((sender,cmd,label,args) -> {
if (!sender.hasPermission("x.x")) {
return Collections.singletonList("no");
}
return Collections.singletonList("yes");
});
}
}```
this should work fine
ok your issue is you are using a generic onCommand
i dont understand
um, still it shoudl work
Seems like you need to learn the fundamentals of java frankly.
And stuff like naming conventions.
In yoru main class you don;t need to specify CommandExecutor, TabCompleter as they are already implemented in JavaPlugin
okay, i removed them
You are returning false in the onCommand so its never going to execute your tab completer
i removed that too
return true not false
should probably cache the completions if they're not dynamic
probably no need to, gc is good
done
quiet frankly, idk what im even doing i just copied the code from here
So long as your command is correct in your plugin.yml it should now work.