#help-development
1 messages · Page 444 of 1
- Custom resource pack with red moon!
did you check that it isn't
like did you actually test the plugin
oh it costs money
my bad
yes, and i just read it even better and found out was a texture pack
yes my error
They could have made the sky red without a resource pack though
Bit of a missed opportunity
packets help
no, with packets you can set the dimension, or changing the biome and then with that change the sky color
ah
How i can create a personal gui?
How much java experience do you have?
The general idea is that you create a new inventory for each player
and an instance of a handler for each inventory.
If you want to write a gui library for your projects then i would recommend
this guide which explains in depth on how to write a scalable gui api:
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/#post-4553427
Ok thanks
How would i go about disabling my plugin if a dependency plugin is not found?
apparently depend: does not seem to work from plugin.yml
that is because your depend is not a list
depend: [WorldEdit, Towny]
this is how it should be
do you have JPremium on the server or shaded in?
are you sure it didn't disable later down on the log?
otherwise, not sure then why it isn't working for you, but maybe it could be that underscore in the author name causing the problems
since your log and what you posted don't seem to match in regards to author
try moving it above commands
then I guess it is a bug
try using depends
if that don't work then I would recommend creating a ticket on spigots jira
?jira
mm
I see the issue now, you are using waterfall
mm lemme try bungee then
I don't think bungee has this functionality
hmmm
you could try it and see, but if that is the case the thing is you are not testing with spigot related things to begin with
does anyone know a discord server for help with the forge mod loader?
you can't say something is an issue with spigot when using someone elses implementation
similar to this one?
i couldnt find a documentation on this as well
you can however implement it in code
all you have to check for when your plugin loads is if whatever you are depending on exists, if it doesn't disable or don't do anything
i did find an alternative and try adding it in the code, but the enable message still shows up
could you guide me?
its similar to the above
except you want to reverse the check
check if not null, then register those things
in this manner, you shouldn't encounter NPE because you are not allowing anything to run
in your plugin that is
MMD
Or just the Forge discord if you're on a supported version
The Spigot javadoc isn't 100% clear on this.. is Tag.WHATEVER.isTagged() the same as Tag.WHATEVER.getValues().contains()?
im pretty sure you can call contains directly but check source for 100% confirmation
?stash
getValues is slower, it streams to an unmodifiable Set
then performs your .contains
How do you shade a jar?
I am on Intellij and using gradle
You’d either be writing a custom jar task, or use shadowJar (a third party gradle plugin)
then for all dependencies that you want to shade, use implementation or runtimeOnly
let me try
- add the thirdparty shadow plugin:
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"`
}
- configure shadowJar to run on build
tasks {
build {
dependsOn(shadowJar)
}
}
- add relocations when needed to your existing build block:
tasks {
/ ...
shadowJar {
relocate("some.librarry", "me.mypackage.myplugin.some.library")
}
}
- set the dependencies you wanna shade to "implementation"
dependencies {
implementation "someone.else:some-library:1.0.0"
}
you also need to add mavenCentral() to your repositories because shadow is not part of gradle
or mavenLocal() if you already have the shadow plugin in your local repo
and then you'll end up with a .jar called "myplugin-whatever-all.jar" (it ends with -all.jar), that's the shaded one
the relocations are optional
one question
it should also work without relocations
tasks { shadowjar }
and tasks { build }
need to be in a different tasks wrapper?
or I can add them inthe same one
if you don't do step 2 and 3, you could also just run ./gradlew shadowJar, but I#m not sure whether you manually have to run build first
in the same
like this
if you don't relocate, this should be enough:
tasks {
build {
dependsOn(shadowJar)
}
}
what does relocation do?
it moves the dependencies to its own packages. that was needed when plugins didnt use their own classloader, it shouldnt be needed anymore
but it also can't hurt, and e.g. bstats refuses to work if you dont relocate it
e.g. it moves bstats from org.bstats to your.plugin.bstats
Appending shadowJar to build?
Or well the other way around
Think just running the shadowJar task is enough
It runs shadowJar when running build
Yes but that essentially builds the jar 2 times
The gradle build task is a lifecycle task
Idk, all i know is that it works lol
It doesn't do anything on its own
no errors, let's hope it works on server startup
In maven i just tell it to run shade during package
Yea
Yes
Thats what i said ealier
Shadow uses a classifier for the shaded jar
Dont ask me why
You can also make it replace the existing jar with some additional configs
so I need to use the -all.jar right
Yes
So would having build depend on shadowJar make it run shadowJar instead of jar?
Like completely substitute it
letsgo
From what i know, it just means „when you run build, i also run shadowJar“
Yeah, but build calls jar by default already
Mostly curious if build would still keep invoking the jar task, after shadowJar
idk, most people just copy/paste existing gradle build files, without knowing what it does, and hoping that it works lol
that's how I do it too
Lmao yea
is gradle that hard?
Its a bit complicated but we were discussing the build task, which is just a composition of other tasks
it's way more complicated than maven imho
but it is faster right?
especially when using maven 4
But gradle allows u to append small snippets of code to ur build pipeline execution more conveniently
yay
There might be some maven plugin that can allow u to define build logic in other languages
Idk
I just remember trying to execute a task after build but not being able to do so
however the docs are often wrong or outdated lol
the javdocs shouldn't be, though
Yea since the wrapper gets updated so often
Some docs are just not updated even though the api changed, and so u end up looking at the right doc version but still sth is missing
Probably less likely to happen now
yeah that is so annoying
But it was case back a year ago or sth quite frequently
one of the reasons why I wouldn't use gradle voluntarily
no docs are better than wrong docs
I think gradle becomes a hassle with all the build scripts
Like when the complexity of the build logic increases its almost as if we have to start writing tests to test the build logic itself
lol yeah
my bathtub is ready, bb
Oo nice
I am the only one who their entire family asks them to fix computer stuff?
just tell them you don't know
some times I miss python
Ah gradle fun lol
Gradle stuff?
conn = sqlite3.connect("mydb.db")
c = conn.cursor()
Yup gradle
Most people know to run build
Its not any different from shadowJar?
Or am I missing something here 😅
I mean i would understand if you redefine build
but that just looks to me like you’re gonna run the jar task 2 times effectively if im not stupid
(Since shadowJar does call jar on its own sorta)
ShadowJar depends on jar
Yes
But gradle is smart enough to not run jar twice
If build depends on shadowJar
Ah alr it substitutes out jar to shadowJar then?
Oh even smarter
Thanks for the enlightenment <:

When you make it
why me
i dont grooy or kotlin


Do it in kotlin it prob wouldn't take that long to learn fancy Java
Transpile Java to kotlin else wise, I think IJ supports it
oh truwe
Is it possible to get the generator that mojang used for the moon generation?
Can't it just be java
no idea
Moon generation???
Yeah probably since interoperability
check the april fools snapshot
You don't know moon generation!!!!!!! (Guys what's moon generation)
you can go to the moon lol
I mean you can decompile it
Thereby making this the greatest update of all time.
Twitch VOD covering the update: https://www.twitch.tv/videos/1781600793
Merch: https://phoenixsc.store/
Cape: https://store.badlion.net/shop/PhoenixSC
https://www.minecraft.net/en-us/article/vote-update
This channel is pow...
minute 1.58
imma learn how to do that
I only interacted once with modifying generation
da moon
if i define the target like this can i do if (target == sender)?
You probably can as online players have reference equality
You just have to make sure both players are online as getPlayer may not return object for offline player
okay thx another question can i have a listener inside a command bc i need to use args of the command inside the listener
idk how else i would transfer that
No
Can you elaborate a bit further, I'm sure that is not correct approach
You need to store them somewhere
i have this command /duel <PLAYER> and i opens a gui
when click a certain item in the gui its supposed to send the <player> a msg and some other stuff
and i dont know how to get the player inside the listener class
because if they already are in a duel with another player i dont want it to send the request
If the GUI is only able to be opened through your command, then you could just give it a unique name to make sure it's "that" GUI?
not quite sure how that would help my problem
let me explain again maybe i didnt explain it right
i have sender lets call him player 1
and the target player 2
the sender uses /duel player2
and then a gui opens for player 1
when player 1 selects a specific item in that gui it send a request to the player 2
make a concrete gui class with the listener in and take a player as aparam
okay thx
when creating javadoc-style documentation do the comments go on the interface a class implements or the class that implements it?
I should be able to put it on the interface and have the interface methods uniformly documented right?
interface
cool thanks bby xoxo
One question, I am creating a method that adds a world to my database but idk which parameters are better
public void setWorld(String worldName, String owner, int maxPlayers, int size, Location spawnpoint, List<String> participants)
public void setWorld(World world, Player owner, int maxPlayers, int size, Location spawnpoint, List<Player> participants)
Which one should I use?
first
Player objects go stale
List<UUID> would be better
or at teh minimum a stringified UUID
Thank you, that's actually what I was concerned about. The javadoc for isTagged wasn't worded very clearly so I wasn't sure if it was checking the set (though nothing else would have made sense)
Yeah never store a Player object in a list, always store UUIDs
internally it stores the magic numbers, so fetchign valued performs a lookup for every entry and enters it into Set.
okok (the string was going to be an UUID)
but sqlite doesn't support direct UUID
using .isTagged performs a single number lookup
It doesn't, but you can store two longs
UUID as a String is fine
Also works as a String
Excellent, that's what I'll use. I looked at the source through IntelliJ but there was no code listed for either method. How did you view the source?
You can also do binary
?stash in CraftBukkit repo
Ah brilliant, thank you!
Yeah I had an entire class in my plugin with a bunch of lists for grouped materials, then I found out Tag had 90% of those same lists
is there any way to store nbt on entity without nms?
?pdc
?pdc
Read the part that says “storing on entities”
my java skills are garbage so sorry for asking again but how do i get the target from the command
handle the event in the inventory class
then have a class var for the target
and on ur constructor have a player var for the target
freejavalessons
Hey,
Lets say I have the following structure:
IBasePhone interface
Interface methods
APhone abstract implements IBasePhone
Contains base stuff that all implementations will have, such as type.
Phone class extends APhone
Contains override for specific stuff per phone type.
--//--
I want to have a custom item which I will assign a PDC value to identify. If I for example want to open a GUI when the item gets clicked, I would get check that the PDC value exists, if so, search for the identifier in a list previously saved and then do stuff accordingly with the information from the clicked item.
Is there a better way to do this
wha
I guess I'm asking for ways to identify a event being triggered from a specific item
Should I store an identifier on the pdc then? So I can keep track of items that way?
Yes
yes
I'm wondering for a while now. Do you actually offer that or is it a meme?
did you get "customers" that way?
Should I just store a random UUID as string
it's free lol
Or should I do things to be able to store the UUID as a UUID type
UUID.toString()
Yeah that's why I used the quotes
save the target somewhere when you handle the command
and get it in your inventory event
What's wrong with saving a UUID?
Or are we talking about file storage?
i guess he is storing to PDC
I see
How you got that much time? o.o
university student
is this good?
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player player)) {
Realms.logger.log(Level.INFO, "The console can't use this command");
return true;
}
return true;
}```
Like defining player inside the if
cool
should I do it like this?
okok
I see. I'd love that - could focus on personal projects a lot more
i just use Server#getConsoleSender#sendMessage(String s)
why not just sender.sendMessage
why use the logger when you have a var right there
logger is also a variable
I made a static class with log function so I can call "Log.info(message)" - it's an ugly solution but the logger is meh
Realms.logger is another class
mi
private void send(String text) {
getServer().getConsoleSender().sendMessage("[EtalonGame] " + paint(text));
}```
ill use sender.Sendmessage
Well in this case you are not actually logging some error, info or warn but you are telling console that you can't execute command as it
public static String paint(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}```
I would just use sender.sendMessage in this case, but if you actually logging smth, pls don't use ConsolesSender to send colourful logs
Yea
upfirst I have never really designed a game mode before:
so when i want to make a command /ff or /surrender
how would i make it that the command knows who you are in a game with.
we need to address the biggest issue with java, how unsexy it feels to write decent APIs
here's my first proposal, an intellij plugin that randomly changes the IDE background to different waifus when it detects you're writing javadoc documentation
Is it a 2 player gamemode?
Or do you want to start a voting?
Hi, Is it possible to set NamespacedKey without it including plugin name in the key?
I need it to match datapacks key values so then i can't include the plugin name
For meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, "switch");
currently it being "cubedcraft-warzone:war":"switch" but i need it to be "war":"switch" without the : seperation
you might create a hashmap with game as a key and players uuids
what would be the best way to make a command, should I just use a shit ton of ifs for checking parametrs?
some reason the curriculum my teacher is teaching from states that with a statement like
Cake cake = new Cake();
cake.doStuff(this);
``` the ‘this’ references the object stored by the cake alias.
Where doStuff() takes in a Cake object
that doesn't sound right
it’s not
quality education
Lol
this is just a special function parameter that exists within every instance method/constructor
hit them with my favorite burn of all time, "I should be doing what you do and you should clean my balls!"
Feel like this is more context to this.
https://youtu.be/zN0L5NToodM truly one for the ages
What type of storages can I use to be able to modify individual objects instead of having to rewrite the entire file like for example data.yml
databases
If I only want to save a specific data field instead of having to resave everything
Thought so
Or pdc
I like pdc tbh
Pdc i mean
Its in memory and writes to file io during important events
Not so different than a yml data storage
is it possible to define subcommands in plugin.yml?
still, arguments are not defineable right
it would be nice ngl
TabCompleter ill use then
how does grindstone work out what to do with two picks that have low durability?
(Commodore)
@terse ore
ty let me check
Or like 5837363 other command frameworks
guys, one question
which was the difference between | and ||
ik that one of them if the first argument was true it didn't check second one
because
imagine two conditions A and B
if (args.length == 0 || args[0].equals("help")) do;
with ||, if A is true, B is not checked
should I do it like this?
hmm
so in this case if a is 0 I won't get an error right?
you shouldn't
the same applies to & and && btw
with && if A is false, B is not checked
oh
and also | and & have something to do with bits
now I realise, python uses && and ||
but i'm not versed in those
| and & are bitwise OR and AND
yeah i don't know what those do haha
doesnt python has and and or
yay ik what those do
works the same for booleans
I meant that and and or use || and &&
only doesnt have operator overloading
I am starting to like Java
yay
Overrated :>
||still python will be better for a lot of stuff||
ill probably make my own programming language
ive been messing with bytecode fuckery the last time
FourteenScript#++
FScript#
make sure to add so much syntax sugar that the language isn't legible to a human being
otherwise no fun
it gotta be less verbose
speaking about no keywords, ive been doing this yesterday: java code above it
can someone check my code and tell me how bad it is
?paste
send it here plz
but uhh imma not continue my weird assembly stuff lol
Got it on github?
not yet
yes
lmao
Run
please
HES GOT A KNIFE
flippery fuckery
why do people use
connection.prepareStatement()
statement.execute(...)```
instead of
connection.prepareStatement(...)
statemennt.execute()```
also you are not giving your connection back to the pool
can you explain
steals it
i haven't worked with hikari but your code seems like a scramble and i'm afraid
you have to 'close' it, it doesnt actually close it but it tells hikari that its inactive
Won’t the try with resources handle that
how should I do it?
does he twr the connection?
i only see th estatements twred
oh man how do I even resolve this cursed thing
only closes the ps
what the fuck is a super capture
capture but better
oh like inferred type or
more specifically it works when I instantiate it outside of this class
this is the shit that i click on while reading stackoverflow and then procrastinate for 3 hours
Conclure making text wall
im ded
im correct in saying a something-sources.jar is just all the .java files squashed together into a jar
Arguably static abuse, config can be static but make sure it to name it as a constant then.
Your static initializer is way too big, the issue is that its hard to test logic of methods and classes when you use so much static.
Don’t use poopy File legacy api, use Path instead.
Those SQL statements, make them into constants, that way your code becomes a bit more readable and maintainable.
Be consistent on the names of your names for the exception variables, you go between e, throwables etc. Stick with one, arguably e since it follows the proportional name principle.
Also feels like these database calls should be async.
Use this keyword if possible, its better as it shows if a method call or field access is from the instance itself.
Use PreparedStatement.
pretty much the real jar just with -sources
ah fun hikaris code is written by a code generator so there are no sources for the ::getConnection impl
where is programming jesus when you need him
what is "this"?
can I ask some stuff
How does addActivity look
WanderBackToPointBehavior the second screenshot
public void addActivity(Activity var0, int var1, ImmutableList<? extends BehaviorControl<? super E>> var2) {
this.addActivity(var0, this.createPriorityPairs(var1, var2));
}
by making config final you mean getConfig() method?
?paste
https://paste.md-5.net/ocoremogan.java full class context
shold I handle the create table on the constructor?
should I make a thread?
No and yes
callbacks and futures are better i think
And I meant with constant
static final THIS_IS_HOW_WE_NAME_THEM
or/and bukkit-scheduler-async
Constructor is ONLY responsible for constructing the unit on an object level
I have playtime in ms
how do I convert it into days,hours,minutes,seconds?
I'm trying it like so, but it shows absurd times
The create table should have its own function
should I make a method called createTables and call it in constructor?
Well, I’d do sth like
do you mean convert like a number to a number? you can use timeunit for that purpose
into 8d:10h:10m:9s
What's wrong with my code thread
let's talk in #1092452894881624085 Conclure
!x & 1;
SimpleDateFormat sucks sadly
any replacement?
joda time maybe?
imma take a look on it
And you have Instant that represents a timestamp
oh no :D
Conclure can you check the thread when you're able to
Where would i change the name of the file? ive looked for Plugin.yml, and porm changed everything to big letters, doesnt change anything tho.
finalName in pom.xml
plugin.yml changes the name used for /pl, and in console
like so?
never worked with times
soo yee :D
remember the ol' times when you could just import spigot jar and compile by exporting...
aand long is playtime in ms from CMI
You still can
Okay
why are you adding a generi type?
ACTIVITY_FORMAT.format(Instant.ofEpochMilli(myLong))
you could just extend Behaviour<LivingEntity>
Where would i put this?
And u have a string @twilit roost
ooh tysm
no need to add another <E>, that would only hide the super classes' generic type
in <properties>
Google your question before asking it:
https://www.google.com/
nah you need to add it
maven properties
?ecosia
Ecosia your question before asking it:
https://www.ecosia.org/
yes
Nvm
it works now
It didnt wanna take it before for some reason
Oh nvm again, it doesnt change the name..
?paste your pom
Someone just said properties tho lol
<project>
<build>
<finalName>...</finalName>
shouldn't modifying plugin yml be sufficient
what does plugin.yml have to do with the file name?
nothing
That worked thanks!
@ivory sleet for creating the database calls async I need to use the BukkitScheduler right?
its one of the many ways
Yeah that works
is there any recommended way?
Im not a fan of that for async io device tasks
Yes but not with bukkit scheduler
It just drops them in a cached thread pool
Which is… well… meh
Doubt it has any significance in ur case tho
how should I do it?
i think BukkitScheduler is also using cached thread pool under the hood
I like to just have my own work stealing pool for such tasks
too advanced for me I think
Well bukkit scheduler is fine, its just i prefer not to use it as it can become a hassle if you’re planning on scaling ur server (for these tasks particularly)
throws this error
maybe wrong Instant?
can UUID.randomUUID() return the same uuid 2 times?
its possible
nope
lemme see if i can access the slides
but extremely improbably
I am safe on not checking if I already used an uuid?
I need to generate an uuid per player
ie. Mojang issue a random UUID for new accounts, but they also check it's not already assigned.
why per player? the player UUID is already unique
Ah forgot
you have not explained why you need to generate a UUID per player
U need to specify time zone
riight
dynamic way to make it so?
Or just hardcode it in
and what for do you need those UUIDs?
for the world name
use owners UUID
And then just the rest
theres a plugin called personal worlds written by Gravypod. It's LONG out of date but the source should be out there still
tysm again :D
or player UUID + world name
makes it easier then randomly guessing UUIDs when retrieving players world
ngl
I do
I am trying to learn Java the same way I learned python
and as far as I am concerned my level is shit
but better than yesterday's shit level
cool
so I am making progress
looks like it's adding additional hour onto it
maybe CMI issue?
@terse ore https://github.com/gravypod/PersonalWorlds
doing what @twilit roost would work?
making the world name the player name
*player UUID
What would be the best way to store a shit load of locations?
persistent?
I have to get the locations every now and then
What are you doing with those locations
config?
I reckon
maybe one config per some region of yours?
but thats complicated
Problem is i have to get the location every like 5 seconds.. and that gonna take alot on the server tho right?
load it into some hashmap?
and on disable save it into config
Again: What are you trying to do?
What is your overall goal?
then load on start
this
smh, we have no idea what the best option is because there is not enough information.
How can I give a item like a chest which has pdc data into the users inventory
Without needing to break it, Like a pickup button
Okay. I'm making a generator plugin. I have to get the player's generators every like 5 seconds. Then i have to drop an item at that specified location where a player put a generator. If that makes sense.
You’ll need to construct an ItemStack with the pdc you want
ItemMeta -> PDC -> Set ItemMeta -> Give Item
Then give it to the player
ig
Wait, if the placed item already has the data in a pdc
It's not the same data when having the item in hand?
blockmeta -> PDC -> convert values to itemmeta -> give?
fun game: write https://www.spigotmc.org/threads/ into your search bar and add a random number there; the more cursed the thread you found is, the more points you get
sounds great :D
So construct a new item using the current pdc data
Mhm
i found a 1.7-1.8 Spanish Lobby plugin
I don’t think there is a method to copy the values from one pdc onto another
Could be useful
This is pretty complicated and can lead to massive lags. If you get a location
and drop an item on it, then the chunk on that location gets loaded. If you have
one player with 100 different locations in 100 different chunks then he will
single handedly half your TPS
Yep i know, i was thinking about putting it into a chest instead. But i would still need to store the location for when a player breaks a generator.
how to get a older version? (IntelliJ IDEA & Minecraft Development Plugin)
do it yourselves in pom
after creating the plugin
Do you want the generators to run when their chunk is not loaded or at all times?
At all times when the player is online.
but tbh api older than 1.13 sucks ass
if player only has 1 generator
make class which u can get via player value
which stores the generator class
Okay but i dont need to change a jar?
even though i love 1.8 the version, its api is unbearable
you'll just need to reload the pom
k
but if you say the api is ass
how tf i use a newer api and make it compatible for 1.8 to 1.19
You don’t
yeah sorta
You can only use 1.8 api methods if you want it to work on 1.8
damn
or you can code for 1.8 but refer to the modern documentation
and pray that you find the relevant methods
the biggest no-no of 1.8 api for me is the lack of nullable/nonnull annotations
No pdc either
or maybe if i try it on 1.8 server and 1.19 server it will be compatible with all of the versions between them?
it sometimes will, sometimes won't
for materials and sounds and particles and whatnot use XSeries btw
i think i'll give it a try
Alright then lets explore some options. So when a player joins the server you can load his generators
in a Map<UUID, Set<Generator>> to keep track of the players generators.
You will also want to store them in a Map<Location, Generator> for fast event
detection purposes. When the player joins you load this data async from a file <UUID>.json/yml
and when the player quits you remove the generators from both maps and store
them back in the file. Now the tricky part. There are several approaches to this.
Here is an interesting one:
You are ticking your generators every N ticks. If the chunk at the generatos location is loaded
then you can just drop the item. If not then you store this ItemStack inside the Generator object
and drop all stored items the next time the chunk containing this generator is loaded. I would
suggest a max limit of stored ItemStacks.
Okay, that sounds like a great option actually. Would dropping an item take more than putting it into a "Sellchest" of some sort?
Depends on how big the chest is and what you do with items that dont fit anymore.
I was thinking about just the item, and then putting the item name as how many items there are.
If that makes any sense
LIke this
Well in that case its faster because you just have to increment an integer in a Map<ItemStack, Integer>
Alright, thanks for the help! ill try it out.
it was the first thing i wanted to try.
😭
Btw i dont think im gonna to use like new stuff such as shields and that
just guis and inventories, nothing more
if multiversional support of spigot was so bad that you weren't able to print a message with the same method, there wouldn't be so many 1.8-1.19 plugins
well, that's true
If you want to support the garbage version and every version afterwards
then you need to build for the garbage version
^
im building for the garbage version thank to god
i wish you luck
Thanks
the last time i tried to make a serious plugin in 1.8.8, i recoded it fully for 1.16
yeah i love the version but the api brings me misery
Is there a way so you can pass unlimited arguments to a method like in python?
VarArgs?
yep
I just dropped support for all versions prior 1.17 because of lack of java 17 support (1.17 was made for java 16, but supports java 17)
Ie ItemStack… items
Object... obj
yup exactly
shit you sniped me twice
Which will be treated as an array
lmao
exactly what I was looking for
on my biggest plugin i dropped support for non java 19
would it be a good idea to make a method that accepts an sql statement and the args would be the rest of arguments
inside of the method I would handle that
instead of handling it every time I want to do a select for example
How can I convert a enum as in
enum.values() into a List of values for command completion?
Arrays.asList(Enum.values)
Arrays.stream(Enum.values()).map(enum -> enum.name().toLowerCase()).toList()
Oh... it's the long version
and please cache that
Ah right they aren’t strings
I mean, it's only 3 options, I think it's easier to just put the 3 strings manually
streams internally do a bunch of bs
But what if you add more things to enum
Yeah then just Arrays.asList("ANDROID", "IPHONE", "BRICK"));
It's just a static values
Not that scalable but still really easy to adapt
Hey,
I have a problem. When a player rightclicks on an enchamtne ttable with an item in his hand, the PlayerInteractEvent does not get triggere. But when the player is op, it does. Any one any Idea why?
(Plugin for 1.8.8)
wondering who lol
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
?paste
use this if you have a big text wall of code
there is not readly code to show. I did a Sout at the first line of the event and it does not get triggered
ig he is straight forward
Some plugin cancels the event with a permission i suppose
no, the method could be whatever and i wouldn't know
the only other plugin I have on teh server is WorldEdit
and I checked. I don't listen to the InteractEvent somewhere else
@EventHandler
public void onShopClick(PlayerInteractEvent event) {
System.out.println("clicked");
}
oh
when I click on teh grass block for example it works
but on the enchantmenttable it doesn't
i wouldn't be too surprised if it's one of the 1.8 api shenanigans
😄
so im trying to add an attribute to an item to make it swing faster
this is what i've got so far
i'm not sure what to put for modifier cuz i've tried numbers
Create an instance of AttributeModifier and add it there
change the weird char in the 4th line second arg to &
You can hover over the method in intellij and it tells you what you need as well
that's for the color
Why are you running it through translateAlternateColorCodes if you are already using the color character
you have to use & if you declared it that way
i know this might be irrelevant for this server but has anyone ever worked with the forge mod loader?
guys with friend we create a cod for a uhc mtp plugin with char like werewolf bet we cant compil it can ssomeone compil it pls
i was trying to create a mod and forge seems a lot more like bukkit than fabric mod loader so i was able to kind of able to make some more progress than i did with the fabric mod loader though.
i was wondering how if any of you work with forge, how did you learn it?
guys
i saw the basic documentation tutorial but it is not exhaustive and there does not seem to be a documentation like the javadocs for spigot.
or is there a documentation that i might be able to use?
lol
That has to be a troll
How to prevent my plugin from being decompiled with Luyten?
i know it is illegal but theres people that does that...
It's not illegal lol
Dont bother. Why would you want to prevent decompiling?
im going to connect to a SSH to make a interaction with a db
i just dont wanna leak the ssh
Then don't hardcore credentials
use environment variables or something.
Use config or some kind of environment variable
its a personal db for a license
also, people can just read memory dumps to find those credentials probably.
and java is not like other languages either they can still look for the string probably.
its easy to decompile.
Then you cant post this on spigot
even with obfuscations.
how spigot works with premium?
i dont understand it
What don’t you understand
A plugin basically has to work without internet connection
Anyway, if you want to check license you sure don't need credentials for licensing database, it's not how things work
i know theres spigot api license and stuff but i never used it before
and if you mention that if i use my own license manager i cant post it on spigot
@tender shard Question about MorePDC
bukkit api is kind of easy compared to writing mods for forge probably.
Can I serialize a class which extend an abstract class? As in, I want to store all the info from the class and it's parent in the PDC
probably, why not?
I assume I serialize the child class
Yeah
really? I tried making a mod with forge and had a hard time with it, and when I switched to fabric I found things making more sense
So then my serialize and deserialize just get the data from the parent
Is that the way to do it?
depends if the parent will always be extended by something that will serialize
can someone help pls
did you follow any particular tutorials or something for that though?
@EventHandler
private void onEvent(PlayerInteractAtEntityEvent event) {
Entity entity = event.getRightClicked();
int stack = plugin.getEntityManager().getStack(entity);
if(stack == 1) {
return;
}
Entity spawn = entity.getLocation().getWorld().spawnEntity(entity.getLocation(), entity.getType());
((Ageable) spawn).setBaby();
Logger.log("dupa");
plugin.getEntityManager().setStack(spawn, stack / 2);
}```
why my event is called two times when i clikc at entity?
or perhaps any documentation you used?
Yes
It will
No
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
if you serialize the child class, the fields of the super class will be serialized as well as long as they don't have the transient modifier
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
This is an entity interact event
Oh! sick!
does someone know something like ?paste but with java api?
So I can upload to it via code
Specifically the At one
with friend we make a code for a uhc plugin mtp with roles for pvp for fun but we cant compil it can u pls
I know
no java api but its legit just a rest api
speak a language please
You should be using the normal PlayerInteractEntityEvent
just the starter tutorials on the official pages, my mod was simple tho, i just wanted to listen to a keybind and send a packet to the server, and I could not do it with forge
can someone explain me this contraption that alex gave me
public static IntStream getPermissionValues(Permissible permissible, String prefix) {
int prefixLength = prefix.length() + 1;
return permissible.getEffectivePermissions().stream()
.map(PermissionAttachmentInfo::getPermission)
.filter(permission -> permission.startsWith(prefix)).map(permission -> permission.substring(prefixLength))
.map(valueAsString -> {
try {
return Integer.parseInt(valueAsString);
} catch (NumberFormatException e) {
return null;
}
}).filter(Objects::nonNull)
.mapToInt(Integer::intValue);
}```
idk rest lang
I would have otherwise used pastebin
what do you mean? why does it not compile?
it aint "rest lang" it's a fucking rest api
you call generic java methods to send a request
we write a code for a uhc mtp plugin like werewolf just for fight for fun but we cant compil it can someone doe it pls
No
is there a way to get from the BanList the entries/names from the banned players?
can someone help me pls
usually BanEntry.getSource()
- it gets a list of all of a permissible's permissions
- it finds all the permissions that start with a prefix
- it removes the prefix
- for every value of the deprefixed perm, it either turns it into an int or null
- it filters all nulls
why does it not compile, do you have like an error or something?
so for example if you have permissions perm.1, perm.2, you can pass in a player with prefix perm and it should output an IntStream with 1 and 2
in which case would a null be in there?
well take perm.1, perm.2 and perm.shit
trying to Integer.intValue("shit") will throw an exception
the method will handle it by instead returning null
i tryed with my pc but im bad with java + i have a free pc from school so i dont have the same platform like u but the code is right
makes sense
bro has a compiler in his brain
Noty
upload your code to github or a paste and send the link
ye
but i need everyone on the list this works only with .getBanEntry() not .getBanEntries()
i'm scared...
i sended u
loop over it
yea
for (BanEntry entry : getBanEntries())
send the link to your code here
And why is the return type an IntStream rather than an Int?
because you have multiple permissions
basically could add something like .collect(Collectors::toList) and return a list instead
i think
i cant
well say it's access to plots in a plot plugin
and someone has multiple plots
that are for some reason defined by perms
use cases are there for sure
Plugin uhc like werewolf
i can't think of one rn but that's acceptable
Essentials uses it for how many homes you can have
?paste
Actually no they map it config values
yeah but it is a singular permission
okay
well if you don't need the method don't use it ig?
then get the first int from the stream
who said that
I was asking why someone would have the same permission but with different number at the end
this looks very complicated to get a single permission value