#help-development
1 messages · Page 1214 of 1
that sign cant stop me because i cant read
I bought a course when it was really cheap on udemy
do u know any dev who will make it for me if they need owo i will because there is a event in my friends hosting
and they dont explain guis well
💸
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
@surreal wadi
listen
Getting someone to make stuff for you costs cash money
^
that's not great advice 
it is he if he doesnt wanna pay
he's gonna think skript is a sg plugin
I will take a wild guess and I will say he is indian
or like an individual
that wants it for free and just working
@surreal wadi I have a dev friend that could prob do it if u want if its a small project he makes it for free if its a bit bigger it costs to like 3euro max
inv as friend
A large squid game event will not be 3€ 😭😭
rad
its a skript dev XD
it will prob take him like an hour max
like its NOT that hard to code red light green light in skript
well red light green light is a scheduler, a area scan and a kill line
but if you want the other events things get more difficult
id be the kind of guy to make a whole 3d shape system for the area scan
a phase system for the scheduler
and an ECS to track who's dead

aint there a find entities in this area already?
like the collision box thing or whatever it was?
still more than 3€ lmao, and there's also other games they mentioned
what if I decide the area is a cylinder
i mean suuuuure but circles? in square game?
I told this dev to do duels for me he charged me 2 euro lol
does it really need to be a cuboid?
I know but its easy to use xd
im pretty sure red light green light tends to be played on one
doubt that's gonna be of literally any quality 
I'd be the kind of person to reimplement the client rendering on the server to render a camera which shows everything except players as it's own color, if it notices any movement on a color (so no animations) it will eliminate the player with that color.
This way you can hide behind players and stuff
but is mingle easy to mak ?
you don't need the client rendering when you can just raycast and implement player bounding boxes correctly
Instead of doing graphics you'd be optimizing the algorithm while reaching the same end goal
It's more efficient both in engineering and operating costs
Well yeah but consider textures with transparent pixels
not_god doesnt seem to care about quality if he doesnt wanna pay xd
Like tall grass
And charging for 2€ is not worth it
harder than lazy red light green light, but you can do it with the same area trick IF you are smart in building your map i guess
map is already builded
doable with volume scans then ig
Im using a PerkManager which i use to retrieve the default perk object by class in my PlayerJoinEvent class' constructor. Now I need to watch out for the right order so that the perks get registered before registering the events. Is there any elegant solution? BukkitRunnables maybe?
?gui
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(syncDataRepository, perkManager), this);
perkManager.registerPerk(new DoubleJumpPerk(this));
perkManager.registerPerk(new ElytraPerk(this));i
so its like this
but this doesnt work as the order is wrong
why do you need to register the listener at a specific time compared to the perks?
like, if all this happens at startup, by the time players can connect all the data the event could need shoudl exist
this.defaultPerk = perkManager.getPerkByClass(ElytraPerk.class);
im doing this in the constructor of PlayerJoinListener
but yes i could register the listeners at any point later on
just thought it was kinda weird/bad
i cant explain why but i think you might want to use ?di here
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
So like a DefaultPerkSupplier interface?
i have no idea if its correct, i just dont like the .class thing there
now that i think about it it doesnt rly matter as i only need the perkManager for testing there
like i said gut feeling
hm but then id need to store all the Perk objects in variables no?
you need to instantiate them so they work, and having them at hand might prove useful i guess
i tend to have classes keep a reference to my plugin instance for example
ig it also depends on how i want to change the default perk later on, should i make a varaible in the plugin main class?
make the default perk one that doesnt do anything imo
oh nvm
i could also use null but wait
nulltends to cause problems lol
what if i use singletons for all of my perks?
No s
wdym?
i thought along the lines of EmptyPerk
PerklessPerk fr
permissions can have default: (true | false | OP) so just set it to true
oh right ty
and is this smart?
nah then id have to static abuse
singleton isn't really static abuse
package com.sealpvp.sealMc.listeners;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
public class guiListener implements Listener {
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (p.getOpenInventory() != null && p.getOpenInventory().getTitle() != null) {
String title = ChatColor.translateAlternateColorCodes('&', p.getOpenInventory().getTitle());
if (title.equals(ChatColor.AQUA + "Select Kit")) {
}
}
}
}
how can I cheak now if a specific slot was clicked on or a specific item in the gui???
?gui is kinda gay
but if i need my Plugin class in the singleton?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
🤨
what hte skib is ?di
not you, kento
it's [the gui post] the best way to do guis on spigot
how can i modify the cooldown time of a shield?
i think its in item somewhere rafi
what cooldown do you mean?
ah no its in humanEntity
when a player gets hit by an axe and its blocking with shield
he prob means so after he disables it its disabled for a longer time
pretty sure that's not it
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
should rethink what I asked for...
have you considered that there are other people in this chat too
like what the skib is fancylogger
they even said that it wasn't directed at you
Im reconcidering my life
.
sigh
awh :(
wait is it not you, but kento or not you, i mean kento?
2nd
english is weird
tell me about it
but DI doesnt work with singletons does it?
to the constructor?...
yeeesss?
fuck guis Im gonna make player sel kit and round in the command
class example{
Object reference;
public example(Object reference){
this.reference = reference;
}
}
singletons are these
class Singleton {
private static final instance = new Singleton();
public static Singleton getInstance() {
return instance;
}
}```
thingies right?
use ~`
so constructor is kinda difficult
yeah, this is DI and what you sent is singletons
where would i specify the plugin's instance then?
i found a method that modifys the cooldown, but how can i check if the cooldown starts?
you dont, it gets instantiated for you
its the class that's extending JavaPlugin and can be referred to in the onEnable as this
you can just shove that into a static variable and write a getter, which can be quite useful at times
so i write the instance variable and getter for it in the plugin class?
you can, or you can since the only code that gets ran for you is the three methods in JavaPlugin, just pass the reference via injection
isnt this just static abuse but with a workaround?
no
part of the api apparantly
i knew you could grab plugins over bukkit but i wasnt aware its implemented like this
It depends how you use it
i dont rlly get it
Just use DI
you have different options how to get a referencew to your plugin, i outlined two there
alr, but the question is rather how, when i want to use singletons
or idk what i want
i want kotlin's Object keyword
yea im aware. maybe i js dont get what singletons are. let me google rq
public static NDGManager getInstance() {
if (instance == null) {
instance = new NDGManager();
}
return instance;
}
That's a singleton
Where there is only ever supposed to be a single instance of said object throughout the entire project (for the most part)
and DI with singletons doesnt work AFAIK
It does
how?
again, unless you copy an object (or its a primitive, think numbers), it's a reference
passing along the object in a constructor and caching it or grabbing the object from a static method in a singleton both result in the same reference
Because you're only getting a reference with DI, whereas a singleton will be constructed once and used everywhere, that being said you can still use DI to get an instance of that object but there's no point because you already give yourself a static reference to the class so
It's this vs:
Main main = Main.getInstance();
your main class cannot be an object
wait i mean like DI for the plugin instance and singleton for the perk instance
like the only thing i can imagine is
class EmptyPerk {
private final EmptyPerk instance = new EmptyPerk(LobbyPlugin.getInstance();
//...
}
i meant for the perk, but thatd also have the same problem as i have with singletons as ive realized
i didnt write the getter cuz yup
You would do something like this so there is no way for another instance to be created unless you explicitly do so
wait when do static variables get intialized?
when the class is initialized / loaded
and if its never initialized than its just like lazy?
Also the class would be initialized technically I guess the terminology is just a bit different? Not really sure on that lol
java is confusing
public class ElytraPerk implements Perk, Listener {
private static ElytraPerk instance;
public static ElytraPerk getInstance() {
if (instance == null)
instance = new ElytraPerk(TottoriLobby.getPlugin(TottoriLobby.class));
return instance:
}
// ...
}
anyway, is this an alright approach?
Well like in order to get an instance of an object (in another class anyway) that object has to be initialized and not null (unless you're expecting a null value ig)
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
the line that the error is showing is
public static NamespacedKey getKey(String key) { return new NamespacedKey(instance, key);}
(at the return part)
and the instance variable is
private static Pluginname instance;
It's messy yeah, but should work fine
I'd try to only use DI where possible
i would
Save static calls for util class and stick to pub/private access modifiers until you understand a bit more about java and those related semantics
It's not really a bad thing that you have static objects/method calls per se, it just depends what should be considered rather internal because static shouldn't hold onto state also for those static method calls, this can occur anywhere in your project so I guess you can consider it a global access modifier if you will
Send your main class in a
?paste
also send the whole class thats in
Static fields should normally be kept to strictly static values (non changing) as well, something of a Constants class kinda thing or just whatever field you know shouldn't be changed
well ig ill sip some tea first. thanks tho!
Sure!
how do you make nicknames invisible ?
Wdym by nicknames?
you never assign instance
You never assign
Man spigot must be hosted wherever you live ebic smh
Latency issue fr
nah i just read it quicker
pffffft
private static final Pluginname instance = new Pluginname (); ig ?
It extends java plugin, so this already occurs. Instead just use the "this" keyword and remove the static from the method call
Just make it public
NamespacedKey(this, key)
Hi Kat
Hi rad
And if you really want your main class to be a singleton (even tho it already is) use this syntax for the getInstance method
if i dont make it static how would i call it
like player.getPersistentDataContainer().set( getKey(stat), PersistentDataType.INTEGER, value)
(this is in another class btw)
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
the ones over your head
i guess they are called tags
The regular player name you mean?
i guess
Try putting an empty textDisplay as a passenger on the player
I've seen that the regular name gets removed when there is an overlapping textDisplay so
armor stand withut a name?
theres also some scoreboars option
I don't know 1.8 mate
What version of spigot are you using
depends but like 1.16 +
why not scoreboard with nametagVisibility never?
🤷 I've never done scoreboards
I did however accidently get the player name removed by doing the text display thing so
wheres the page where i can see the placeholders that work for when the plugin is downloaded from spigotmc
what placeholders and what plugin?
like
%%RESOURCE_ID%%
that kinda stuff
that i can put in my code
and spigot puts the resource id there when the jar is downloaded
I would figure you just put that in your plugin desc manually?
Hmm I'm not sure then
i just forgot where to find the list
uhh so like
i did this.getKey(stat) the issue is that the method that the pdc setter is in is static so it doesnt work
.
yes thats the one
❤️
Send all the code
its only for premium resources tho? sad
is there anyway to make it static and still make it work cause it would be a bit more annoying if i dont make it static
I'm sure but would not recommend
I need more context tho, send me all the code you're having issues with
i mean i have another method that just gets the stuff from the pdc
which ig also has the same issue
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ok i understand why it would work if i dont use static
but it would still baisically be super annoying cause i need to make an object of "StaticMethods" to do the setting / getting
Not really
You can still use DI in that regard, then just use the instance of that class to make a call to a public method
ah so like
call static method
static method makes object which then calls method which actually does everything ?
im a mc plugin developer dm me
no
private final Main main;
public SomeClass(Main main) {
this.main = main;
}
public void SomeMethod() {
doSomething(this.main);
}
... alternatively
public void SomeOtherMethod(Main main) {
doSomethingElse(main);
}
imagine having public constructors lmao
[sql] read directly after write but from different server reliably
Imagine right
imagine not allocating with unsafe
interface-factory-impl-provider pattern go brr
imagine allocating
Imagine computing
i didnt understand this that well
so all of this would be in another class (not the same as the Pluginname /Main class )?
Correct
is there any way to like put it all in 1 class (Pluginname /Main class)
so like ima try and summerise my issue cause even im getting kinda lost
so like to store stuff in my pdc i need a NamespacedKey which to create i need Pluginname object and a string
and if i put this into a method to create NamespacedKey and make it not static i would need a Pluginname instance to call it since the method is in the Pluginname class
and after this im kinda lost on what im doing
Hey, I want to modify maximum bees in a beehive, I did see this field called "Bukkit.MaxEntities", how can I modify it?
https://i.imgur.com/p4HxaE1.png
like wouldnt it be eaiser if i make the NamespacedKey maker method static and then call it anywhere
you could but as soon as ur project grows youll know why u shouldnt
you use constructor parameters to pass the plugin instance(Pluginname) to your class where you need the namespaced key. then you save the plugin instance to a variable(this is dependency injection).
Now you can simply use the local variable with your plugin instance to create the NamespacedKey
and because you create the instance for the class where u need the plugins instance in ur Pluginname class, you dont need static
like this, where Main is Pluginname(the plugin), main is the instance of the plugin
and SomeMethod(this.main) is new NamespacedKey(plugin, "...")
i mean im not getting the why i shouldnt
I am using tchristofferson's config updater and its not updating the actual file in the directory
private void checkLangUpdate() {
try {
log("l "+ getLangDouble("lang-version"));
if (getLangDouble("lang-version") != PLUGIN_VERSION) {
log("2");
ConfigUpdater.update(this, "lang.yml", langFile);
lang.set("lang-version", PLUGIN_VERSION);
}
} catch (IOException e) {
logError("Failed to check lang file update.");
e.printStackTrace();
}
}
it prints lang version was previously 1.0 (taken from lang)
then it prints new lang version is 1.2 (taken from lang)
this change in lang-version does not reflect in the directory file
and when i grab any of the newly added keys from lang they dont exist (a server restart fixes this, since they are added to the physical file)
so it would be
public class StaticMethods {
private final Pluginname plugin;
public StaticMethods(DnDGuh plugin) {
this.plugin = plugin;
}}
and i would somin like
public NamespacedKey getKey(String key) { return new NamespacedKey(this.plugin, key); }
also i realised that the class name is StaticMethods when im trynna not use statics
ill change it eventually
im confused cause like
dont i need to pass in an instance of Pluginname into the constructor
where would i make this instance
right direction but i would js use new NamespacedKey directly
and the StaticMethods class doesnthave any static methods
but now you see, you can use the plugins instance without static in a different class, so at least DI(dependency injection) is direct
Could someone help me with this stupid gui please 😭
public void onInventoryClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
Inventory inv = e.getInventory();
String guiname = e.getView().getTitle();
int clickedSlot = e.getRawSlot();
//gui mechanics
if (guiname.equals("kitGui")) {
e.setCancelled(true);
ItemStack clicked = e.getCurrentItem();
if (guiname.equals("roundGui")) {
e.setCancelled(true);
if (guiname.equals("kitGui")) {
e.setCancelled(true);
if (clicked != null && !clicked.getType().isAir()) {
if (clickedSlot == 10) {
p.sendMessage("G FUCKING G");
}
}
}
}
}
}```
like when I use the command
it just says "invalid usage"
wtf is this code
?
and there are no errors either...
show the command then
i mean the code
you want me to send the whole code?
does your gui open
and it still sends the message?
it could be easier for you to help
no
like its supposed to send "gg" on chat after clicking the slot
and it just gives me the correct usage or smth
this is my whole code
and this is my only class in the main class I got this
public void onEnable() {
getCommand("duel").setExecutor(new duelCMD());
}```
go and learn java, your event isnt registered and that class shouldnt be a command and an event, and you return false which causes sending the usage
????
it implements command executor and listeners
Holy hell
you do not register the listener, and you shouldnt import event listener
this is what Im trying to do
your command should not be an event too
Right you should learn java before trying to make plugins using an api
fine
yo wtf is that name
yes
holy triangle
dont forget to register it
you also should not be using inv name to detect what inventory
wdym register?
Im sorry if Im annoying by asking stupid questions I dont know java very well
Im still trying to learn
you have to register the event with Bukkit.getPluginManager().registerEvents
ye but im confused on the other part
ima just explain what im trynna do
so like i have a command which calls a function which sets a stat in a pdc
and this method is in the "StaticMethods" class which ima call SM for short
so to call the pdc setter i would need an instance of sm which would need the parameter of the Pluginname Instance
so where would i even do that
wait i think i got it to work
or am i still doing static abuse
that is horrible advice
you often need static in places where DI would just not make sense
well for this case i mean
kinda
but setIntStat needs to be public
and u cant create an instance of Pluginname
hm ?
then how would i put the parameter in the constructor ?
you can get the pluginname instance using "this" within the pluginname class
ye but like
im calling the setIntStat method from another class
dependency injection again
private Plugin plugin;
public ClasName(Plugin plugin) {
this.plugin = plugin;
}
welcome to java
i knew java was boilerplate hell but this seems over the top
eeh its just 2 lines in the end
like declaring variable and setting the value in the construczor
ye but wouldnt i need and instance of Plugin(Pluginname) when making the ClassName object ?
and to get that i would end up having to do Pluginname plugin = new Pluginname();
.
wait this would be in ClassName or the Pluginname class ?
e.g if u have a command that needs Plugin instance to call the setIntStat method:
public class Pluginname extends JavaPlugin {
@Override
public void onEnable() {
getCommand("setintstatcommand").setExecutor(new SetIntStatCommand(this));
}
@Override
public void onDisable() {
}
}
public ClasName
are data bans still a thing in modern versions of the game? i recall hearing that something about the maximum amount of data sent to the player got changed?
oh like that
yes, in that example SetIntStatCommand has a constructor that takes in the Plugin instance
ye ye i got it
tho like i still didnt understand the issue with static
ig it makes it less "oop" but still
It’s not that it’s less oop, it’s that there are access modifiers for a reason. Static is basically a global object being accessible throughout your entire project which unless done correctly can lead to a lot of issues. It’s also not a good idea to mix state with static fields. Really will just make your testing harder unless you’re using it correctly
oh um btw for testing stuff
is it just run local host server then join and then run command / do thing ?
Yes
whats the best library/api to use if i need the user to select a region (like the worledit wand does) and then have the plugin do whatever i want with said selected regionww
I don’t know if there is a library for that, but it isn’t that hard to code
aint that just region select + iterator
like, for x = x_small, x < x_large, x++ ... block block = world.getblockat(x,y,z)
because basically like id be selecting a play area that players cant get outside of either, so i would need easy checks for stuff like that
scheduler iterating player list and positions if player x < minx player x = min x, if player x > maxx player x = maxx... then?
hm.
but only upon block position change, otherwise that be called hundreds of times
how do I use meta.setCustomModelDataComponent? I need to set it to a string case for this resource pack config ("CUSTOMSTRING1") The method takes a CustomModelDataComponent but I dont know how to make one
{
"model": {
"type": "minecraft:select",
"property": "minecraft:custom_model_data",
"cases": [
{
"when": "CUSTOMSTRING1",
"model": {
"type": "minecraft:model",
"model": "minecraft:model1"
}
}
],
"fallback": {
"type": "minecraft:model",
"model": "minecraft:nether_brick"
}
}
}
.GetCustomModelDataComponent will make one
Or you can just use the old string method for < 1.21 style
old string method? 
List<String> customStrings = new ArrayList<>();
customStrings.add("CUSTOMSTRING1");
meta.setCustomModelDataComponent(meta.getCustomModelDataComponent().setStrings(customStrings));
this isn't compiling
Required type: CustomModelDataComponent, Provided: void
👍
i love CustomModelDataComponent
parasocial relations like this aren't it
depends on the PR 
totally not the poi one
if its not the POI one all good
lynx can i make a pr that has the buildscript of paper explode your pc
only for you tho
I'll accept it
approved
@river oracle there you go, totally dont make that poi pr
I'll port it tonight 😈
-# as a draft 🤫
Initialising the plugin before the world generation solved my spawning issue thanks. Unfortunately vault will not be loaded so i need to take that into account and load it afterward
Using ServerLoadEvent should fix that
Thanks for the help !
Even better or PluginEnableEvent if Vault is optional
Or even even better, ServiceRegisterEvent if you're using Vault services and they're optional
In my case I only need the "Economy" part of vault so ServiceRegisterEvent should be even better
thanks !
ok so i have a -#teensy tiny ###problem
is there a way to, somehow, make this generic without using (Object key, Object value) and a ton of if(Object instanceof Class)?
if not, is that the better solution in this case?
i mean, i personally would have a repository for each
ok the only thing in my head hearing that is github lol
especially if you have essentially the same method all over again you could just have an interface giving the methods
and different impls
ah, but i still would need to implement the methods just in different files
i was asking if there is a way to make this easier to tack additional types of keys and values onto
instead of having to make n*m methods lol
public interface Repository<T> {
public void storePDC(T, PersistentDataContainer);
}
or whatever
that would be the generic way
the problem is that those T still need to be translated into keys
hm
can you constrain T to a Set of classes?
like, T instanceof (Block, World, UUID) ?
not without all of them implementing a common interface
and since you're not bukkit you can't make an interface they implement without mixins and interface injection (my beloved)
no i think i got it
this class is already having a constraint in itself so that its only valid for one combination at once
so i can just have it store the PreparedStatement strings and call 'setKey', 'setValue', 'executeUpdate' and 'executeQuery'
like
private void storeString(int x, int y, int z, byte[] world, String value){
String statement = "INSERT INTO "+table_name+" (x, y, z, world, data) VALUES (?, ?, ?, ?, ?)";
try {
PreparedStatement preparedStatement = connection.prepareStatement(statement);
preparedStatement.setInt(1, x);
preparedStatement.setInt(2, y);
preparedStatement.setInt(3, z);
preparedStatement.setBytes(4, world);
preparedStatement.setString(5, value);
preparedStatement.executeUpdate();
} catch (SQLException e){
throw new VDBException("FAILED TO EXECUTE STATEMENT: "+e.getMessage());
}
}
and just split this into the key assignment and the data assignment, since because all tables store exactly one value, the preparedString depends only on the key type
for the love of god use the prepared statement for the table too
?
ah. well, the instances of this class are supposed to represent a specific table
is it an issue?
or just 'please dont do that' lol
you already use the prepared statement, so use it and sanitize the data
me when the table name is void; drop all tables; -- or something, idk sql
the table name is generated from the key/value type and final after instanziation
i dont see how it could cause an issue here but i can tell that its good practice in general i guess
ye need to write sql in CAPS so this wouldnt work lol
though my code yelling at me all the time is a bit annoying
:V
explain this then
maria
yea i think the direct mysql thing yells at you for not writing keywords in caps
aaaaalright then
my code for adding a custom model data component (string) is this:
List<String> customStrings = new ArrayList<>();
customStrings.add("ak47");
CustomModelDataComponent component = meta.getCustomModelDataComponent();
component.setStrings(customStrings);
meta.setCustomModelDataComponent(component);
Here is the data on the item when I get it via command: https://cdn.discordapp.com/attachments/1332849118762242079/1332859931505725595/Minecraft_1.21.4_-_Multiplayer_3rd-party_Server_1_25_2025_3_49_07_PM.png?ex=6796ca0b&is=6795788b&hm=36ee12a50d7e3f9979c08f2fbe4535174b67143d0409d52b5b50160b61afbfcd&
so it seems that it has an empty custom model data component. is there anything wrong with my code?
yeah... https://imgur.com/a/haFtK5G
whats the newest version?
this just means I need to get a new spigot jar from buildtools?
yes
yep, this bug was fixed a week or twoago
so I currently have an old 1.21.4 and need the newest 1.21.4? or experimental?
newest 1.21.4
I’m not even sure why enforcing caps was picked as a design for SQL
Yeah it's so you can tell what's a keyword
same goes for windows Batch scripts
(for the most part, i think older windows and some cmds do poop on U if its not cap)
That way SQL knows you're SERIOUS >:(
It really isn't enforced
where's the code looking for a safe spawn? i need to steal it
?paste
anyone know to remove actionbar from our screen but i didn'y know where is the command block
Reset title?
I just told you...
what ?
I think my database having hearing loss
cm'on guys its been half a bloody day lol
for what?
since this topic started
oh right
thought you were still waiting on safe spawn code and saying its been half a day
safe spawn detection isn't all that difficult
oh ik i can just search for solid block with 2 air above, but i want it to mimic overworld if possible, thats why im asking in the first place
basically the code just looks at the initial place, and then surrounding locations. And if that doesn't work then it looks higher until it finds a 2 block high spot
Anyone? 
The over world doesnt even have that good of a safe spawn code.
Look at some Opensource RTP plugins, they have gotta be using some logic to detect if a spawn is safe or not. When they do iterations for teleports.
Where do I download the SpigotMC API?
?maven
ohh. When he said "download" I assumed he was doing it external to a build system like Maven.
which command frameworks do you guys prefer? i have been using ACF for a while but since its basically abandoned i was thinking about switching to something that might be more frequently updated or more feature-rich
cloud, acf and commandapi are the popular ones
Can permissions be dynamic, or must they be inferred from a plugin.yml? For instance, can you have a plugin, say a "homes" plugin, have the quantity of homes per group dependent on a dynamic permission node. Assume we have a plugin, RizzHomes.
Would it be possible to have a node rizzhomes.limit.X, and assign rizzhomes.limit.1 to your default group, and perhaps have the limit be 3 (rizzhomes.limit.3) for VIP.
I know you could probably just do this in your config.yml like:
groups:
default:
limit: 1
vip:
limit: 3
but the prospect of it being permission nodes sounds cool. But if this is the case, would you have to statically define every single potential permission node, such as:
permissions:
rizzhomes.limit.1
rizzhomes.limit.2
...
Elaborate.
Like is there a way for your plugin to check, "Does this person have the integer permission", and if so allow them to create more than X amount of homes.
you can have dynamic permissions
This is how I sometimes do dynamic permission sets when you don't know what the perm is before hand
Thank you, I really appreciate a practical approach.
wouldn't be hard to modify that to handle integers instead
filter on getEffectivePermissions works well
String perm = "homes.total.";
int total = player.getEffectivePermissions().stream().filter(homes -> homes.getPermission().startsWith(perm)).mapToInt(homes -> Integer.parseInt(homes.getPermission().substring(perm.length))).max().orElse(0);```
What is a IntFunction<T>?
Interface
its a function that takes an int as an input and produces a result of type T.
im not passing this an int tho
oh its passed automatically aint it
huh
why is my ide markingn the parameter as R instead of T?
Internal to the interface, its R.
This might be a little confusing, but IntFunction looks like:
@FunctionalInterface
public interface IntFunction<R> {
R apply(int value);
}
R stands for Result. As relative to the inteface, it is the result, to you its the type.
fair enough
Is this in a lambda?
ye
Yeah it do
i saw it in the autocomplete for set -> array cast
ohh alrighty
hmm unrelated question but i just got an idea
is this valid sql? cant really test atm
"INSERT INTO table (id, data) VALUES (?, ?,)"
no
extra comma will throw an error
Hey, how can i update a scoreboard, i saw that you need to reopen it, but just doing player.setScoreboard(scoreboard) doesn't seem to work, i tried to remove the scoreboard with player.setScoreboard(null) gave an error. (I do not use teams)
I've already sent you the wiki link that explains how
Hes been answered a couple of times over teh past two days
Yeah I've answered at least twice
also you obviously can;t pass null, read the javadoc https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#setScoreboard(org.bukkit.scoreboard.Scoreboard)
i have two sets / arrays (doesnt matter which; currently writing the class) for which i need to figure out if they overlap at all
does java have set manipulation that allows me to calculate the crossection and check if its non-empty?
coz otherwise this is just n² comparisons
Should be a retain method you can use
'retain' ?
Not sure about the complexity of it though
retainAll
???
How do you plan on detecting that
Set<String> keySet = new HashSet<>();
for(TypesAccess keyType : keyTypes){
for(String key : keyType.keySet){
if(keySet.contains(key)) throw new RuntimeException("OVERLAPPING KEYS");
else keySet.add(key);}}
im going with this right now
Use retainAll 🙏
well almost all bukkit methods require synchronization except get methods
Also checking contains is redundant
i need to see if the overlap is empty and then grab the merged set if it is, so i figured this would be less operations total
for each iteration
alr then i just will create inteliji plugin for this
💀 Please don't
Do not mess with the code during compile time from a Intellij plugin
That will create a dependency on Intellij being used to compile
that'd only work if i want to check if the second set is a subset of the first
list a, b
copy a to c
c addAll b
is c size a + b
this not will be like lombok or smth
just warnings
where i should sync
isnt this worse than what i did above in terms of operations?
benchmark and see
idk need think
but if you're making the pdc thing still I don't think it matters that much
this isnt for pdc, im making a framework for databases to spare myself headaches later on once i forgot how sql works in 3 weeks
I see
Yeah I did already tell you that was a bad idea
Since there's no generic way of handling relationships between objects
You'd still need to define them
Hibernate!
well this isnt meant for complex database relation nonsense lol
this is so i can go 'hey, i want this table: (Keytype, Valuetype)' and get a instance that has 'put(key, value)' and 'query(key)'
Why use relational database then
wym
MongoDB moment
is it possible to assign final variables outside the constructor? i have a method thats supposed to be called from the constructor so that i can organize my code better, and it does some string manipulation
ah. i split the method into multiple parts and am now realizing a small issue. if i iterate the same set, with no changes, using for(T t : Set<T>), does it always iterate in the same order?
ah fuck it says 'subject to change' here
if order is important dont use set 👍
i stg the longer i am working on this the dumber my code becomes
how do i do a sql statement that overwrites if data is currently present?
im getting 'primary key constraint failed'
my current sql is INSERT INTO table_name (name, data) VALUES (?, ?)
maybe in a case statement if it exists delete the data to be overwritten before writing
idk how to write sql 🤷♂️
how about INSERT OR UPDATE?
huh its that simple
imma try that brb
[SQLITE_ERROR] SQL error or missing database (near "UPDATE": syntax error)
nope
depends on which sql
then just REPLACE INTO
check the properties for the appropriate sql syntax https://github.com/ElgarL/GroupManager/tree/master/resources
or insert into ... on duplicate key update
wait
yeah I just used replace into for simplicity
dont you need to state which keys on that?
as for elgar, you can use different placeholders on that?
[SQLITE_BUSY] The database file is locked (database is locked) what the
imma hit restart on that rq
hm no that still happens if i use REPLACE
thought you said mysql?
that is sqlite which is not mysql
ngl those are kinda swapping around in my head rn
sqlite is different syntax https://github.com/ElgarL/GroupManager/blob/master/resources/SQLITE.properties
noted
how to create an umbreakable sword in spigot 1.8.8
there should be item flags for that i think?
i dont foud it
[SQLITE_ERROR] SQL error or missing database (no such column: NAME_STRING)
its using the data base name as column now for some reason i think?
INSERT INTO NAME_STRING (name, data) VALUES (?, ?) ON CONFLICT(NAME_STRING) DO UPDATE SET UPDATED = excluded.UPDATED
are you even connected?
i mean, yea. it wouldnt complain about duplicate values if i exclude everything after (?, ?) otherwise
unless changing my insert string SOMEHOW disconnects me
your first entry shoudl be your table name
isn't that set to the table name?
a database can have many tables. You specify which table as teh first arg of your INSERT statement
thats the TABLE_NAME
this says STRING_NAME
ye
or NAME_STRING
thx
thats your table?
then why is it also in your on conflict?
on conflick shoudl be on name or data as those are the keys you are using
ah so it is a column
%s is my table name for the insert
I guess mine can be confusing as I have TABLE_NAME as a column in one table
that one with TABLE_NAME is just a table of timestamps of last update
keeps track of table change timestamps for syncing across servers
this error keeps getting weirder and weirder
[SQLITE_ERROR] SQL error or missing database (no such column: excluded.UPDATED)
i switched the table name with the primary key and that seemed to do something?
Your columns are name and data
oooh
caps strikes again lol
im Deeply Suspicious of the fact its not throwing errors anymore
more testing required
ah no
database is locked agian
are you getting new connections without releasing the old?
its a file so suffers from file locks
if you try to open a new connection while one is alreasdy open
lemme verify something
hm no that shouldn't be an issue atm - i make a connection, pass a reference to it to the class interacting with the table, and the only thing i ever do with it is calling prepareStatement
is there any good async/sync taskchain api?
ok this is decidedly odd. it causes an exception the FIRST time (something something result set), and THEN it goes 'Database Locked' on subsequent queries. Only fix to that is restarting the server
god damn it
statement.close has to be added bleh
if you use a try with resources it auto closes
ye but i am using a builder pattern (that the right name?) for composite keys
wot
its saying the statement is null
i dont unset that ever tho???
so a sql exception unlinks a reference. great
AAAHHHHHHHHHHHHHHHHHHHHHHHHHHH
https://github.com/aikar/TaskChain
ill try this one
how can i set a custom no permission message in acf?
Show code
uhh
@Subcommand("info")
@Syntax("<guild>")
@CommandCompletion("@AllGuilds")
@CommandPermission("guilds.info.other")
public static void guildInfoOther(Player player, String guildName) {
acf by aikar
spigot 1.21.4
Spigot no longer gives no permission messages, just unkown command
sure but acf does right
Rerun BuildTools in an empty folder
My discord didn't load ur messages
meant for @smoky oak to show code
i changed it around a bit and have a bunch of statement.close in my catch clauses now where i cant put into try(PreparedStatement ref = statement)
but what happened was that i had no statement.close() anywhere but after the error happened for soem fuckin reason the statement was null so i couldnt call close on it
specifically, after the error it stops executing, and the first call after that is to this method
public SQLTable prepareInsertStatement(){
try {
statement = connection.prepareStatement(insertString);
} catch (SQLException e) {
try {statement.close();
} catch (SQLException ex) {throw new RuntimeException(ex);}
throw new VDBException("FAILED TO SETUP INSERT: " + e.getMessage());
}
return this;
}
in which the debugger showed statement as null before that first line executed
Why no try with resources smh
Use t-w-r and you don't need to close
it's already good
that is cursed try usage
bc i need a preparedstatement field to do chains a la this
You can set the variable in the try with resources
not that it's a good idea since it already will be closed
(but that's also the case in your code above)
not too sure what exactly youre saying here tbh
What you should be doing is creating the prepared statement in the execute method
or if you really want to do it that way you close it in the execute method
wait nvm I missed that your second try was in the catch block 🤦♂️
btw i am doing that there since i can use twr there and closing the reference closes the statement
the issue was that after an sqlexception it for some reason unliked the statement reference from the field
which is like ?????
thats not how it works 😂
the code you showed would always have a null statatement if it errors in creation
ah thats not what i stated that method was
ah
hold up i see the problem now
i requested a new table but the connection was tied up in the error from the old instance
im a dumbass
of course two different objects dont have the same references
private void insertKeys(PreparedStatement statement) throws SQLException {
for(Map.Entry<KeyType, Object> entry : keyMap.entrySet()){
KeyType type = entry.getKey();
switch (type) {
case UUID -> statement.setBytes(keyOffsetMap.get(type), Serializer.serializeUUID((UUID) entry.getValue()));
case NAME -> statement.setString(keyOffsetMap.get(type), (String) entry.getValue());
}
}
}
public ResultSet executeQuery(){
try(PreparedStatement statement = connection.prepareStatement(queryString)) {
insertKeys(statement);
return statement.executeQuery();
} catch (SQLException e) {
throw new VDBException("FAILED TO EXECUTE QUERY: " + e.getMessage());
}
}
like this?
forces me to update it when i add different key types
is there a way to make a skeleton shot an arrow with the animation?
can
someone help me with gui
like I cant make it so it does anything on open
nor click
send your code
@Subcommand("accept")
@Syntax("<player>")
@CommandPermission("guilds.request.accept")
public static void acceptGuildJoinRequest(Player player, Player target) {
log(player.getName());
log(target.getName());
using acf
i am running the command with one account
and putting the name of a diff online account
but both player and target refer to the same player (the sender)
whats up with this?
¯_(ツ)_/¯
I just see it being done on this one plugin I've worked on that uses ACF
we use cloud at work but I've been preferring command-api a lot more tbf
it's the closest to the one I made while still supporting brig
.thenAsync((Task<Double, Object>) ignored -> {
System.out.println("hi");
return Math.sqrt(Math.PI);
})
is there any plans for java to allow simplifying this to
.thenAsync( ignored -> {
System.out.println("hi");
return Math.sqrt(Math.PI);
})
```?
kinda like kotlin does
or any way to make this not require casting/be simpler?
Is that your thenAsync method?
yea
Java already allows lambdas without explicit types?????
its incomplete but i commented what doesnt work
/**
* @param <S> return type of self task
* @param <T> return type of prev task
*/
public interface Task<S, T> {
/**
* Runs the task
*/
S run(T prevResult);
}
interessting part is propably this
Why not use Aikars taskchain?
uh i was too stupid to include it using gradle
what?
?? it's just a maven dep
and it didnt have any new commits so i was kinda concerend if its maintained
- shading
i got it included but the methods in TaskChain and all the classes didnt show up
Ancient shadow in that example so do make sure to update it
nvm now it works
plugins {
id("com.gradleup.shadow") version "9.0.0-beta6"
}
repositories {
maven("https://repo.aikar.co/content/groups/aikar")
}
dependencies {
implementation("co.aikar:taskchain-bukkit:<version>")
}
tasks {
assemble {
dependsOn(shadowJar)
}
shadowJar {
relocate("co.aikar.taskchain", "my.shaded.taskchain")
}
}
modern gradle
my savior 🙏
did u just copy paste it or is there some updater tool?
no i wrote that by hand
shame. thanks tho
ohmagawd shadow 9 beta 6 is out now
gonna have to update all my projects from beta 4
Should have stayed on stable
Livin' on the edge
listen i use arch (btw)
systemd 🤮
don't see the issue with systemd
anyway i dont get what my.shaded.taskchain shold be
i tried artix but i had issues
doesnt follow unix philosophy
your shaded package
if you set it to my.cool.plugin.shaded.taskchain it'll get shaded to that package
so its like groupid.artifactid?
it's just a package
i honestly don't really care, 890 megs of ram is fine for me
windows used 6 gigs soooo
i just have lots of stuff running that i need
i mean ram isnt the issue. but with big code u got more bugs and therefore security vulnerabilities
but mostly doesnt matter tbh
sadly i care so i hate like every linux distro xD
Whats the max bandwidth you guys have hit?
what about gentoo or lfs?
What you run on your hosting? 💀
voidlinux works too
i haven't tried void much yet
linux cuz its the best valid option
Why does an IronGolem change its yaw rotation when i aply a vector in the direction he is running?
Bukkit.broadcastMessage(vector.toString());
vector.setY(0.8);
Bukkit.broadcastMessage(vector.toString());
ironGolem.setVelocity(vector);```
its much more stable but overall pretty much the same. also no AUR
aur my beloved
xbps is a bit better than pacman in my opinion but maybe its js the packages being more stable
it betrayed me too often with broken packages
eh not really for me
i have to manage an alma server, rhel and dnf is such a pain sometimes
lucky me is js a 15 yo kid with no responsibilities but school
What to use instead of "EnumChatFormat" on 1.21 for ProtocolLib? (it says doesn't exists)
teamPacket.getOptionalStructures().read(0).map((structure) ->
structure.getEnumModifier(ChatColor.class,
MinecraftReflection.getMinecraftClass("EnumChatFormat"))
.write(0, ChatColor.RED));
like cmon man, why does the default option for the confirmation prompt have to be no
dunno, don't use it too much
oh or yes | dnf install ...
god i hate doing that
any chance u know how to fix "Unsupported class file major version 65
"?
huh i just noticed the memory usage on this srever is only 12 gigs for three minecraft servers, two proxies, a maven repo, three databases, four github actions runners and docker
what java version are you using
21
ChatFormatting
show the full exception
my 4 gb server struggled with a single mc server tf
also do cache that class somewhere so you don't call getMinecraftClass every time
for future reference use
?mappings
Compare different mappings with this website: https://mappings.dev/
how tf do i copy gradle errors without internal lines
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:199)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:180)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:287)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction$StreamAction.remapClass(ShadowCopyAction.groovy:339)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction$StreamAction.remapClass(ShadowCopyAction.groovy:325)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction$StreamAction.visitFile(ShadowCopyAction.groovy:239)
... 151 more
so theres this
org.gradle.api.GradleException: Could not add file '/home/k/Documents/IdeaProjects/TottoriUtils/build/classes/java/main/me/xkento/tottoriutils/TottoriUtils.class' to ZIP '/home/k/Documents/IdeaProjects/TottoriUtils/build/libs/TottoriUtils-1.0-all.jar'.
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction$StreamAction.visitFile(ShadowCopyAction.groovy:243)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
this + some yapping
Are you using the shadow version rad sent
uh no
pretty sure it does
ive used dnf all of like twice but
Trying to set Block Display as invisible, for shulker boxes it worked, but for Block Display it doesn't
(glowing effect works, but still not invisible)
WrappedDataWatcher watcher = new WrappedDataWatcher();
//...
watcher.setObject(0, WrappedDataWatcher.Registry.get(Byte.class), (byte) (0x40 | 0x20));
//...
Why are you using packets for this
Player#hideEntity in shambles rn
To spawn glowing invisible display block
It will highlight selected block for player
you can do that with the api
I know but it should be only client side and don't spawn decoration entities in world
Entity#setVisibleByDefault + Player#showEntity
i mean fwiw they dont tick so it doesnt hurt much to have them
just remember to clean them up if u dont want them lingering ig
Okay, but can block display be invisible? Like shulker box, like falling block
Hightlight only glowing borders
ah
Glowing works but invisible doesn't by some reason
you might get away with what rad posted
does #setInvisible works?
i seem to recall some nonsense with armor stands with arms, but i dont think thats what you need here
with rad answer that still will not achieve what nosatlev wants
have you tried giving invisibility potion or something?
The reason why client side is because worlds have limits of entities and entity spawn event will be cancelled
Maybe i should try with potions something
no??
worlds don't have entity limits for display entities lol
maybe he has his own plugin handles that
ah
just checked, i don't think you can give potion to BlockDisplay right?
it must be a livingentity
And what about setInvisible does it works with block display? (combined with setGlowing)
best of luck mate
can i ask for code reviews here? :v
i think theres a dedicated thread
ah ur right
https://paste.md-5.net/imikomenab.cs
I have this code, it gets some player statistics and applies it to an item lore, the thing is I'm getting the statistics on a seperate thread since it caused too much lag (a long delay when opening a menu). But now the problem is that the function returns before the seperate thread can calculate the values, which results in all the values being 0. How could I fix this?
a scheduler called from async on sync thread will jump back onto main next tick
you can either give the item when that scheduler jumps onto main, or edit it
I kinda understand, can you elaborate a bit more?
like, 'technical explanation' or 'gimme code'
Like technical but kinda like how should I do it
Ik you meant that I should runtask on main thread from the async
yep
minecraft does most stuff on one central thread
this includes world and item changes
so you need to re-join the main thread
Yeah but like
I'm returning a value
How should I access that returned value
from the async thread
you dont?
Like i'd need to set the lore's placeholders again
you have the rejoin runTask pass on the data
call the method to update the lore from the sync task
Aight, I'd just set the lore from the async thread then
It would be pointless to return it from the main thread
Since everything would be 0
you cant do that
async is limited in its interactions with the main thread
thats why you need to rejoin it via a sync task
when i rename an arrow, and i shoot it, the arrow entities still have the name that i renamed with?
dont think so but not 100% sure
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/ProjectileLaunchEvent.html pause that and check ig
declaration: package: org.bukkit.event.entity, class: ProjectileLaunchEvent
public List<String> getLore() {
List<Object> objects = (List<Object>) MAIN.getMenusFile().getFeatureAttribute(getFeatureType(), "lore");
if (objects == null)
return new ArrayList<>();
AtomicInteger coursesCompleted = new AtomicInteger();
AtomicInteger coursesUploaded = new AtomicInteger();
AtomicInteger coursesPlayed = new AtomicInteger();
AtomicInteger totalPlaysOfMyCourses = new AtomicInteger();
if (player != null) {
PlayerStatisticsFile playerStatisticsFile = MAIN.getPlayerStatisticsFile();
PlayersCoursesFile playersCoursesFile = MAIN.getPlayersCoursesFile();
Bukkit.getScheduler().runTaskAsynchronously(MAIN, () -> {
coursesCompleted.set(playerStatisticsFile.getCompletedCourses(player).size());
coursesUploaded.set(playersCoursesFile.getPlayerUploadedCoursesAmount(player.getUniqueId()));
coursesPlayed.set(playerStatisticsFile.getPlayedCourses(Bukkit.getOfflinePlayer(player.getUniqueId())).size());
totalPlaysOfMyCourses.set(playerStatisticsFile.getTotalPlaysOfCourses(player.getUniqueId()));
});
}
return objects.stream()
.map(obj -> String.valueOf(obj))
.map(str -> player != null ? str.replace("%PLAYERNAME%", player.getName()) : str)
.map(str -> coursesCompleted.get() == -1 ? str : str.replace("%COURSESCOMPLETED%", coursesCompleted.get()+""))
.map(str -> str.replace("%COURSESUPLOADED%", coursesUploaded.get()+""))
.map(str -> str.replace("%COURSESPLAYED%", coursesPlayed.get()+""))
.map(str -> str.replace("%TOTALPLAYS%", totalPlaysOfMyCourses.get()+""))
.collect(Collectors.toList());
}
So I'd need to just getScheduler().runTask() from the a sync thread, but what would be the code? like how can I pass the data to the main thread? I'd need a global variable, the current function wouldn't make sense since I could not use "return"
tasks can accept arguments
I could use completablefuture's
Just read about them
does anyone with nms experience know if its possible to spoof an item meta update packet? specifically, updating an item's persistent data container? I need to update it without causing the item to "bob" in the player's hand while they are holding it.
you'd need to cancel the item packet altogether, or use that new fancy resource pack option thingu
didn't you ask this before already?
chat i need help with gradle, once again.
I need to expose the taskchain api to consumers of my Api plugin while also shading it into a fatjar.
I tried this but im still getting NoSuchMethodException
// https://mvnrepository.com/artifact/co.aikar/taskchain-core
implementation("co.aikar:taskchain-core:3.7.2")
api("co.aikar:taskchain-core:3.7.2")
// https://mvnrepository.com/artifact/co.aikar/taskchain-bukkit
implementation("co.aikar:taskchain-bukkit:3.7.2")
api("co.aikar:taskchain-bukkit:3.7.2")
also pls ping ill go to sleep now, 2 am already and got school tomorrow 🪿