#help-development
1 messages · Page 2047 of 1
I'm not using mojang mappings too
uugh
I find it more confusing when using mojang mappings, idk why xd
in the beginning, it's confusing. after that, it makes everything sooo much easier
I tried to use that but idk how to reobfuscate it on Gradle before.
this works totally fine in mojang mappings:
ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER,
((CraftPlayer)player).getHandle());
Yeah same thing.
Here's what I'm trying to achieve https://www.spigotmc.org/threads/packet-discovery-spectator-mode-modifications-noclip.319125/, although I successfully implemented that but it will not work If the server is in offline mode.
idk maybe this helps: https://www.spigotmc.org/threads/1-17-mappings-with-gradle.511184/#post-4202136
hm sorry I have also no idea left
so I did this @tender shard
private final VillagerPark plugin;
public transferEco(VillagerPark plugin) {
super("transfereco");
this.plugin = plugin;
mysqlSetterGetter mysql = new mysqlSetterGetter(this.plugin);
}
and now I cannot use mysql.FunctionsIHaveInIt
I could when it was outside the constructor
Making player gamemode to spectator but send a packet tells that player is in creative mode.
bro sorry but
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
obviously you have now made mysql a local variable
you want it to be a field that only gets initialized in the constructor
private final VillagerPark plugin;
private final mysqlSetterGetter mysql;
public transferEco(VillagerPark plugin) {
super("transfereco");
this.plugin = plugin;
mysql = new mysqlSetterGetter(this.plugin);
}
this ^
also please use proper names! You use lower case for classes and UpperCase for methods, that just hurts my eyes and everyone else's too
Okay, thanks anyway alex!
maybe ask on the forums too
actually
How can I completely smooth teleport a player? Because in the moment, i teleport the player +0.2D each tick and it isn't smooth. My Problem is, that I have to make it faster, but than it would be more less-smooth.
you cant stop me MUHAHAHHA
no but people can just stop helping you if you don't listen to them
But is the reason of the error still the same? Because something is missing on the GameProfile.
teleport using packets and you can achieve a smoother movement as packets are not rate limited.
and later you could expand your project with mongodb, flat file dbs
idk, you haven't send an updated error message 😛
Hello !
I'm trying to get a configurable period for a bukkit task in config files.
What's the thing for a long in a yml file ?
Simply this ?
period: 100
or maybe
period: 100L
?
(I'm using the FileConfiguration#getLong method)
you can just use "period: 100"
Okay ty 🙂
FileConfig#getLong can easily also read integers
with using 100L you'll just confuse server admins 😄
Okay I see xD
you can basically ALWAYS use integers when a long is required
but other way around, you need to cast it
Can you give me an example?
dont do that
dont make it ticks
some idiots wont understand
make it seconds or milliseconds
yeah I normally let them enter seconds, then I parse it as double and simply do *20
and convert it in ur code
It's the same, and this one is error from 1.16 https://paste.md-5.net/ibepegufuk.md
Okay ty for this information x)
Tbh, this plugin is for a friend, so I can explain it easily
hm no idea, maybe something else is missing. I don't have 1.16.5 right now but you can try toCtrl+B into those classes and see what each line is doing, especially NetworkManager lambda$b$6 (so the sixth lambda / anonymous class inside the b method)
26.03 09:45:30 [Server] INFO java.lang.IllegalArgumentException: Plugin already initialized!
26.03 09:45:30 [Server] INFO at net.md_5.bungee.api.plugin.PluginClassloader.init(PluginClassloader.java:176)
26.03 09:45:30 [Server] INFO at net.md_5.bungee.api.plugin.Plugin.<init>(Plugin.java:36)
26.03 09:45:30 [Server] INFO at com.wonkypigs.villagerpark.mysqlSetterGetter.<init>(mysqlSetterGetter.java:14)
26.03 09:45:30 [Server] INFO at com.wonkypigs.villagerpark.commands.giveEco.<init>(giveEco.java:17)
26.03 09:45:30 [Server] INFO at com.wonkypigs.villagerpark.VillagerPark.registerCommands(VillagerPark.java:84)
26.03 09:45:30 [Server] INFO at com.wonkypigs.villagerpark.VillagerPark.onEnable(VillagerPark.java:24)
26.03 09:45:30 [Server] INFO at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:265)
26.03 09:45:30 [Server] INFO at net.md_5.bungee.BungeeCord.start(BungeeCord.java:285)
26.03 09:45:30 [Server] INFO at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
26.03 09:45:31 [Server] INFO at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
wtf is even wrong anymore
you are creating a new instance of your plugin in mysqlSetterGetter line 14
and this is my last answer for you unless you fix your class names
How to check if item stack is null?
My eyes, class starting with a small letter O.O
if(itemStack == null) // it's null
Oh 💀
he also has UpperCaseMethodNames
I can't find it ;(. What version do you have right now?
1.18.2 remapped in my test plugin 😛
Todo: watch that movie again lol
is that wolf of wall street or great gatsby?
Wolf of Wall Street 🙂
ah yeah I think it's the scene where he's talking to his father about how all girls are shaved nowadays lmao
Probably lol
Here's the error on 1.18 https://paste.md-5.net/rilecoziqi.php
yeah that still seems to be either the player's name or the textures
did you actually change the ServerPlayer's textures?
I really have no idea, I'd ask in the forums instead
Here's the full code https://paste.md-5.net/nitiyiruhi.cpp
Okay, I'll ask the forum.
What is the title? I actually don't know how to describe this issue.
How can I delete the item from an EntityPickupItemEvent? I found this method but it didn't work
Cancel the event and remove the Item entity.
Okay thanks
took me a while to find it in the docs lol
if (items =! null) items = null;
so I have this running when a player joins the bungeecord network
PreparedStatement insert = plugin.getConnection()
.prepareStatement("INSERT INTO villagerPark_players (UUID, NAME, ECO, STREAK) VALUES (?, ?, ?, ?)");
insert.setString(1, uuid.toString());
insert.setString(2, name);
insert.setInt(3, 0);
insert.setInt(4, 0);
insert.executeUpdate();
but the mysql table is still empty
I am using PostLoginEvent
have you tried to just change it to onPlayerJoint event
the hell is post login event
once there's a proxiedplayer and before they connected to a server
o
npc library
I REMEMBERED
WHAT I WANNA DO
IS
Offline players management
so u can modify stuff about offline players
basically treat them as they were online
i need a name for it tho
OfflinePlayersManager ig
ill have a way that u can like
put events on some offline player
offlinePlayer.whenJoins((p) -> {
/*
*/
} and
offlinePlayer.whenJoins(Predicate, (p) -> {});
OnfflinePlayers
I'd do offlinePlayer.onJoin(player -> { ... })
definitely you'll want it to be a consumer instead of a runnable 😄
otherwise it's pretty worthless
offlinePlayer.whenJoin(() -> { Bukkit.broadcastMessage("someone joined but no idea who lol"); });
offlinePlayer.addItem
i mean the object ur using
you have that dont you
but its better for me to make it a consumer
so the user can get the player object
the online one
imagine you have a class
public class JoinConsumer implements Consumer<Player> {
//
}
you want to allow using this
and there you don't have the player object
so definitely consumer and not runnable
i don't know, maybe look at OpenInv, IIRC it allows to view offline player's inventories
I don't know how they do it
running at 60 tps? or running every 60 ticks?
60 tps
bro what
don't different packets during a tick get queued and then sent all at once?
i think no
yes
. (this is bungeecord btw)
this does look like a queue to me
hm
but why when I start a thread and update an array it doesn't crash??
wdym with "crash"? any error messages? if so, why don't you send them pls
translator bad, i mean the screen starts to freeze
let me show a example
wait
probably because your packet queue is getting bigger and bigger, carshing the client? or sth?
I dont' know, check out the client's logs maybe
there is nothing on client log
let me make a video
how do i make a particle linger for a specific amount of time?
BukkitRunnable
I don't think you can, afaik.
Each particle has it own fixed lifespan.
usually its variableType variableName
Yeah but what si the type ?
on line 35, i need to use seconds
not a integer
but i don't know what is the type of second
for exemple
the type of a simple number is " int " or " integer "
lemme check
You mean float/double?
thats weird my java doc says this
Tick = 1/20s, just a reminder
Not 1/4 seconds ?
What
you sure about that ?
PotionEffect potionEffect = new PotionEffect((PotionEffectType) PotionEffectType.ABSORPTION, 30, 0);
this give the effect for 0 second
why ? xD
actually
it gives you 'no effect'
cuz the amplifier is 0
anything times 0 is 0
as such
no effect
change it to 1
false because 0 is for level 1 of effect
Yeah most likely
i have tested this
Amplifier starts at 0, no?
yes
Maybe the code isn't being executed
Or
You're not giving it to the player
/ entity
the code is executed
Whatever
Try 10 seconds
The duration is only 30 ticks
Not 1.5s
Which is 1.5 seconds.
20 tick is 1 second, and you put 30 ticks on the PotionEffect duration
it works ! thank you ! 😄
hey this is m,ore of a general question, but intellij cannot seem to access javafx imports?
so ive just added it
import is fine
bad class file: C:\Users\Gaming\.m2\repository\org\openjfx\javafx-controls\19-ea+3\javafx-controls-19-ea+3-win.jar(javafx/scene/control/Alert.class)
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.```
how do i fix this? or change the version
compile with a more recent version of java
Kinda weird to use java 11
why? it's an LTS version, I don't see any reason on not to use it
because you're using an older java on windows
52 is java 8
so you're using java 8 on windows but javafx requires java 11+
17s got a lot of stuff as well. Might as well
I'm reading the error wrong. I need my morning coffee
set your pom.xml to use at least java 11
https://blog.jeff-media.com/common-maven-questions/ see the third headline
I need to start a blog lol
Because you're concurrently modifying a collection
so, how i can fix that problem?
Do it

It's snorkel time! ٩(- ̮̮̃-̃)۶ uwu :3
I'm learning react native so maybe I'll use that to build a nice website for myself 
for whatever reason now my plugin cant find the api, but its added as a dependency
https://paste.md-5.net/ofatudujah.xml
it used to work now it doesnt
¯_(ツ)_/¯
trying running clean see if that fixes it
if it's intellij invalidate caches. But clean usually fixes things
I think intellij crashes once a year for me
Intellij saves more time than it costs. Hence why it's so popular lmfao
ikr
if i have a class b extend interface a and a HashSet<a> containing band call a method in a that's overwritten by b by doing for(a item : set){item.method()}, does it execute the method in b?
its nice for syntax and shit, but its always breaking
lol now it works after taskkilling it ¯_(ツ)_/¯
decided to actually download the packages
dependencies
whatever they call it for java
try it and see lol
can you help me private ?
Why does it need to be private?
i cant send a image here
java.lang.NullPointerException: Cannot invoke "me.ag4.cloudsmc.Main.getConnection()" because "me.ag4.cloudsmc.Test.plugin" is null answer is right there
can i send the main class
Because I don't know what the problem is, and I don't know why it gives me null
Of course you can
How do I make so that NPCs spawn in a jungle, like villagers spawn in a village, the same concept
thanks 1m i send it😇
i cant save it why (Something went wrong!)
does org.bukkit.configuration.configurationSection::getIntegerList() return a ordered list?
arraylist iirc
ordered as in a list where position matters? yes. Sorted? You'll probably have to sort it yourself
please...?
Since it returns a List and not any specific list impl, you must not rely on the order anyway
Even if it returns an arraylist today, it could be sth different in the next update
i want to make so the NPCs spawn naturally at the jungle and cannot be respawned, so entity spawn event wont work
well it doesnt have toIntArray for some reason
How do I serialize a uh
HashMap<OfflinePlayer, Set<ConditionalConsumer<OfflinePlayer>>>
the ConditionalConsumer is a predicate with a consumer
Do you know what the problem is?
You really should use dependency injection instead of a static instance
thats not it
That’s hard
he never initialized the connection varaible
Best way is to make a registry of said consumers or sth
Which is why dependency injection is the answer
Then each consumer would be associated with a key, and then you merely use the key as an identifier
conclure rn what im doing is
im making a library
for manipulating offline players
the ConditionalConsumer is for a method for OfflineUser class
(whenJoins)
so u can do smth like this
OfflineUser.from(offlinePlayer).whenJoins(player -> true, player -> /* */)
but i thought
what if the server closes
and the player hasnt joined yet
That do be a lot of generics
how to ad multiple alians?
but you're never going to be able to serialize a predicate unless you hard-code in some predicates and associate them with ids
because you can't serialize Java code ;p
Just add in more arguments at the end. It's varargs (note ...aliases). e.g. "help", "somethingelse", "anotheralias"
thanks you ❤️
Sorry
Any api for dealing with blocks on 1.18.2 smth like World edit. I want to use it for a protection plugin
whom pinged me
@onyx fjord
nice theme
updated to java 16 and its fixed, thanks lol
Theme name?
thanks
its dracula
?
Dracula
dracula theme
na bro only dracula
but i dont like how some highlights are red, which throws me off lol
so i use dracula
dracula has even its own history
I have the 2022 beta versión
creator of dracula had a surgery
but someone stole his laptop in hospital
he had to redo all configs
and decided to make his own theme
do u use vscode?
probs because its beta
Kaper do you also have experience with nodejs templates?
Templates applied to website
public void onJoin(PlayerJoinEvent e) { e.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(2); }
what'd i do wrong lol
get the Bukkit recipeIterator
then check out every recipe's result
erm I mean ingredients
🧑🍳
depends, what are you trying to achieve?
tryna set their max health
when they join the server
should work. did you try without any other plugins?
yeap
maybe set the players health as well. I've had many issues with messing with the max health attribute
mm
MikeShadow do you have experience with vectors?
did you forget @ EventHandler ?
there you go
Because i need to calculate a radious of blocks (doesnt matter how much) based on a center custom block
I've used vectors but not with spigot
thank you
np lol
I cannot figure how to do that
what exactly are you trying to do
Im doing a protection based a custom block. So once you are in the radious you cannot break, build etc
get the block's distance from the origin block, done
if(block.getLocation().distance(otherBlock.getLocation()) > 10) { ...
but you should rather use distanceSquared instead
Let say I put a block on coord x=0 and z=0, them based on thst block I cannot break in radio of some blocks
Would that apply the same?
yes?
Hmn im so confused
about what
life, the universe and everything
On place event if my custom block I save the location. And them on break event im getting the block and the location
But i dont know how to it using radio
So the protection protect a round of 20 blocks botton, top, right and left
2(pi)r - if you actually want to calculate it from the circumference
get the block's distance from the origin block, done
That so?
I dont understand math
So if you can do a example
private static final int PROTECTION_DISTANCE = 20; // 20 blocks
private List<Location> protectedBlocks = new ArrayList<>();
@EventHandler
public void onPlace(BlockPlaceEvent event) {
for(Location protectedLocation : protectedBlocks) {
if(protectedLocation.distance(event.getBlock().getLocation()) >= PROTECTION_DISTANCE) {
event.setCancelled(true);
}
}
}
no math needed
2 pies in a circle
but yeah you should use distanceSquared instead, and not 20 but 20*20
Location of each protection block right?
obviously that's what the for loop is for
what is the difference between distance and distancesquared
if A and B are 20 blocks apart
distance = 20
distanceSquared = 400
I thought you were ssving every block location from the protection
yes, distance has to calculate the square root while distanceSquared doesn't have to
and since sqrt(400) is harder to calculate than 20*20, better use distanceSquared
Distance squared is area for a rectangle
bullshit
aight, thanks
distanceSquared is just distance * distance
will be replacing distance now 😳
Oh that's right lwh
a^2 + b^2 = c^2
so to get c, you have to sqrt(a^2 + b^2)
but you don't need it to just compare it to a given distance since you could easily square the given distance
is wondering why we went from circles to right angle triangles.... maybe breakfast will help
example, let a be 1 and b be 2
1*1 + 2*2 >= 3*3?
easy.
but
sqrt(1*1 + 2*2) >= 3 involves getting the square root, which is just not needed if you simply also square c (3 in this case)
Yes I learn it on 2° of High school
Now im 4th of bachiller doing computer science
Cos^2 p + sin^2 t = 1 is where we have all the fun
If you think about it, circles are just infinitely recursive squares
Fied egg sandwich will help! Wave forms are not really squares but yeah you can slice them as such
everyone talking about squares and waves here. I think it's time for me to mess with some synths again
Zither time?
Shit 😂
wonders if the eggs will taste like tuna ...
Ah that accent is to die for
"water station" 
I don't know the english word for "Napf" lmao
Water bowl
Yeah
It's beautiful stfu
Yeah your English is fine lol
anyway I found the cable lol
Miraculously
The mouse pad jumped to escape the cables?
Its one of those angry looking usb cables
yes lol
Whst that?
one of my cable drawers
you know, where you put cables inside that you use once per decade
Oh you get your mouE on water
I wsth it without audio
And dont understand
So now I u. Derstand
yeah all you people were talking about sinus and squares and waves so I wanted to get my synth running again
so I needed a cable
and that's what caused the mousepad to fall into the dog's "water station"
Alex do you know Where I can buy arduino modules?
ebay
Here they are too expensive
Because my country tax me if products are $+200 and them I have to pay the Product price and extra for "derecho de importaxion"
main:
` public RespawnBonus other;
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Grabbing registerEvents");
getServer().getPluginManager().registerEvents(new RespawnBonus(), this);
getServer().getPluginManager().registerEvents(new BedNerf(), this);
getServer().getPluginManager().registerEvents(new LimitMaxHealth(), this);
other = new RespawnBonus(this);
}`
respawnbonus:
` private Softcoresmp mainClass;
public RespawnBonus(Softcoresmp main) {
this.mainClass = main;
}
public RespawnBonus() { }
@EventHandler
public void onRespawn(PlayerRespawnEvent e)
{
Bukkit.getScheduler().runTaskLater(this.mainClass, task -> {
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,600, 2));
}, 5L);
}`
proper formatting pls
maybe i should send these as text files
or ?paste
?paste
public RespawnBonus other;
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Grabbing registerEvents");
getServer().getPluginManager().registerEvents(new RespawnBonus(), this);
getServer().getPluginManager().registerEvents(new BedNerf(), this);
getServer().getPluginManager().registerEvents(new LimitMaxHealth(), this);
other = new RespawnBonus(this);
}
respawnbonus:
private Softcoresmp mainClass;
public RespawnBonus(Softcoresmp main) {
this.mainClass = main;
}
public RespawnBonus() { }
@EventHandler
public void onRespawn(PlayerRespawnEvent e)
{
Bukkit.getScheduler().runTaskLater(this.mainClass, task -> {
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,600, 2));
}, 5L);
}
just use proper formatting
using shitty guides
i see
basically just doesn't work
any errors?
nope
or just the potion not getting applied, without error messages?
yeah
that's all
it's known that potion effects take like a tick to be registered after respawn
so i tried to do just that
Verano123 hit the link above, most ebay shops buy from them or ali anyway
Awe man don't do listeners in your main class 

It's not
So the effect is not applied?
nope
no sir
i'm trying again but registering the event passing in the main class
OH SHIT
that worked
ok good good
yeah i just forgot that
thanks all for enduring my wall of text lul
That's why I wrote my library. Autoregister stuff so I can't forget anymore 
yeah i should do that lmao
i just made the instance with the default constructor instead of using the new one i just made like a 3head
anyone has a lib idea
A library to complain when someone uses NMS when they shouldn't
someone explain why the FUCK doing (float) section.getDouble("size") where the config says size: 1.0F is NOT equal to hard coding 1.0F
thats more liek a wiki
well
ur getting a double
and getting a double out of 1.0F is weird since theres a letter there
isnt there getFloat
casting a double 1.0d to float, it will be equal to 1.0F
otherwise you're doing sth wrong
well 2Hex was right
even though typing 1.0F in code is a float
1.0F in a config isnt
Ah one of the weird java conventions 😆
as such removing the f solved that problem
wait are you typing 1.0F in the config?
:/
Why
not really
Well now you know
yaml isnt java u dont expect it to be the same conventions
Yes really: float is not always a double in java, it is just commonly cast that way. It's not an assured type
That was a hard lesson to learn - float is a fixed type in most other languages
i mean according to the docs
An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int.
A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double.
I wanna have a clean Main class, is this a good way of loading commands for example?
If not, can you guys suggest me one ?
@Override
public void onEnable() {
instance = this;
new CommandLoader();
}
// CommandLoader Class
public class CommandLoader {
AxleCrates instance = AxleCrates.getInstance();
public CommandLoader(){
instance.getCommand("crates").setExecutor(new Crates());
}
}
normalize a vector pointing in the direction you want the player to go, multiply it with the int
i mean if u have that many commands
public final class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
// Creating an auto-register for the base package the plugin is contained in
AutoRegister autoRegister = new AutoRegister(this,"com.miketheshadow.exampleplugin");
/*
Running default setup registers all classes annotated with
the command annotations or any listeners
*/
autoRegister.defaultSetup();
}
}
The cleanest setup 
Registers everything
so I can just implement CommandExecutor? and thats it ?
is that ur library?
https://github.com/MikeTheShadow/AutoRegisterLib In the examples
It's still a WiP
Waffles!
That's actually smart lol.
it looks very bad to me
there's nothing wrong to have a bunch of "getCommand("asd").setExecutor(...)"
I pick random images of cartoon food and apply it to my profile pictures. Although I should probably make it more professional
imho this is unusable once your listeners or commands have soft dependencies
you need an annotation like "RequiresPlugin("WorldGuard")"
What'd be your approach then ?
Why would soft depends break it?
imagine you have a listener with worldguard imports
you cannot instantiate that class without worldguard
that's why people would do stuff like this:
if(PluginManager.getPlugin("WorldGuard") != null) { registerListener(); }
because without worldguard, you'd get NoClassDefFoundError and plugin won't enable
Hmmm I can solve that.
https://paste.md-5.net/jaqinapito.java
Does anyone see anything wrong here?
I'm trying to have a direct connection between Spigot and BungeeCord.
(PluginMessage is not "flexible" enough for my taste)
but how? To check the annotations, the class has to be loaded and so it already throws a NoClassDefFoundError
imho "auto registering" is always a very bad idea
I don't think that doing it manually is bad in any way
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
He could use plugin annotations to specify
and where would those annotations be?
exactly, in the class that can'T be accessed
Or you'd add an exception to the builder.
They arnt actually in a class
auto registering listeners and commands might work in tiny plugins without dependencies. but I don't think it's worth the trouble at all
thats really cool
just register your listeners and commands properly and you're done
simple and useful
(that's just my opinion, the idea is nice though)
The end goal is to make it in a broad a system as possible. So I'm going to be attempting to take open-source plugins add it and see if I can get it to work in as many as possible.
Kinda my test cases
@SoftDependency(plugin = "Worldedit")
That wouldn't work it'd need to be more like
There's an open source Island plugin that you may want to try it with.
autoRegister.requireDepend('class','plugin_name')
You have to load and setup the annotations preprocessor
yeah but for example just look at this listener. I bet you wouldn't even be able to get the annotation if this class would use imports instead of reflection if FarmLimiter wasn't installed
But if those classes don't load it's not that big of a deal. Considering they wouldn't work anyways.
yeah but just imagine that that class would do something in its constructor before any exception would be thrown for example
Hey, is there a way to display all PDC Keys and their corresponding values instead of testing of it's there, then displaying it? Can't seem to get the PersistentDataType from the PDC itself.
I think auto registering stuff is a good idea but to get it working in complex scenarios, dirty hacks will be required. I'd for example just explicitely say "register listener/command X if Y is true, or don't"
but sure, some people might find it useful
PDC#getKeys
Yes, but then I can't get values.
you will always need some kind of DataType to retrieve it, yes
but, there are only like 10 builtin datatypes
so yeah you can't get around checking them all
ah ok
I bet that getting them as byte array will always work
The goal is to prevent the need for dirty hacks. I'm working on making it flow as nicely as possible.
(almost always)
yeah I know, I just consider your whole approach to be a dirty hack
because the proper, nonhacky way is to simply tell bukkit directly what you want to get registered
don't get me wrong, I love hacks like this, I just think that they will cause trouble in SOME cases
in 99% of cases it'll probably work fine
I just think that if bukkit wanted something like this to exist, it would have been built in since 1.4.6 or sth
The reason it doesn't is it requires an awful lot of assumption. You'd need some sort of manager and that's what I'm writing
Plugins getting a new scoreboard every tick
yeah or plugins doing synced HTTP requests
or plugins on spigotMC that only have a 100% german / spanish / russian description
ja
if I'd be allowed to have another alt account, I'd vote them all 1 star
but my only approved alt account is not allowed to do any reviews
and if I'd rate them with my main account, I'd get 1 star reviews in return lmao
Just pay some guy to downvote things for you
get some work
I have
rob some banks
oh btw maybe I'll be a certified flight instructor in 2 years
how can i make a plugin compatible with more minecraft versions?
define "more"
Damn Towny is thicc.
3-4
use less API that's unsupported by those 3-4 older versions
how?
i have a issue where Action.RIGHT_CLICK_AIR Doesn't get fired
you could write different classes for each version but if the api hasnt changed use the same stuff
multiply the vector with -1 then
it doesn't get fired for all items in hand
i tried debugging and every other action gets fired except for RIght_click_Air
I can offer you some servers to run on my PC:
What I offer:
AMD Athlon II 2 cores,
2GB DDR-2 RAM Mhz-???
64GB storage
Let me know if you're interested. IT'S OP BTW
How to get player from UUID? 1.12.2 paper
wdym
Bukkit.getOfflinePlayer
String name = e.getPlayer().getName();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "execute as " + name + " run function namespace:respawn");
also update your server
it doesn't get fired at all
Thanks
what i offer: a doggoe
Thanks
with any item
I mean, the event is not called when you are right clicking air with certain items
no this is not an answer to your question
i used hand, swords, blocks
this doesn't work for some reason idk
everything
Hmmmm, I have to think about it tbh.
player from uuid not uuid from player
ooooh
how to get player from UUID
scared now
some people just decide not to read
Ohhh, hmmmm..
stop spamming
sorry
String name = e.getPlayer().getName();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "execute as " + name + " run function namespace:respawn");
this doesn't work, anyone know why?
btw how can i fix? I tried with every item type
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
for some items, the event simply isn't called and there's nothing you can do about it
it throws an error in the console, saying that the command is invalid. i don't know why
it's a valid command
yeah but the point is that i tried with every type of item
did you read the text the bot sent you?
?pastethe entire stacktrace.
i tried with food, swords, armor, blocks, and various items
yes?
some really dont to
so why didn't you send any error msg?
i mean the minecraft console
it successfully sends it as a command
but even though it's valid it says it's invalid
🤷♂️
can't help you then
ok
[16:09:11 INFO]: ...s skissue function wildernesskit<--[HERE]
: |
that's all i mean
[16:09:11 INFO]: Incorrect argument for command
Looks incorrect too
it runs perfectly normal when i run it manually
[16:21:34 INFO]: Executed 1 commands from function 'namespace:respawn'
trying another function
does anyone know why this happens?
from https://www.spigotmc.org/resources/nbt-api.7939/#:~:text=The API can be used in different ways%3A
im trying to use NBT tags for 1.18.2
Show entire pom
Probably missing the repo?
?paste
This
wdym repo
this works on 1.18?
Yes
?paste your pom
Which api class do i need to use to parse a Block to ItemStack?
i already did
add the proper repo
wdym?
I mean, add the repository to your pom that provides the API you're using
Sometimes you have to add the repo dependenciees
in this case, this:
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
<layout>default</layout>
</repository>
Block#getType
new ItemStack(type)
Smth like that
ah}
blocks are no itemstacks, what do you mean?
Let say im giving a player a custom beacon with lore and name. I want to check if the event block has that lore and name
i created a plugin and a server for 1.18.2 but it still says that "are u on the right version" what to do?
blocks don't have lore or name
Did you get other errors?
nope
what's bad about being on the "right version"?
let me send the whole msg
So how i check if player place a custom beaco with lore and name? Hmn
I'd only worry if you were on the "wrong version"
while player.isOnline().
here?
?scheduling
That mfalex
store the name and lore of the placed itemstack somewhere
Yeah
e.g. with my CustomBlockData lib https://github.com/JEFF-Media-GbR/CustomBlockData
I already done, i dont know how to parse the event block iton itemstack
stop pasting your stuff 3 times
your recipe must not contain 9 lines
crafting tables have at most 3 lines
lines = rows
Thought you said no errors, fix the error
wait I have 3 lines only
A block is not an item stack. Anyways I awnsered you above. Keep in mind the block won't have any lore or name
Yah just a sec
run it on another thread
Well yeah. Which is why you should use the scheduler like they linked
Bukkit.getScheduler().runTaskAsynchronysly
Allright
i need lib idea uwu
wait runTaskTImerAsync better
How would I do something for each individual player? ```java
public boolean checkArea(Player p, Connection conn) throws SQLException {
String query = "SELECT area FROM Gungenns WHERE uuid = ""+p.getUniqueId()+""";
ResultSet selection = Main.instance.getConnection().createStatement().executeQuery(query);
while (selection.next()) {
if (p.hasPermission("essentials.warps.a2")) {
conn.createStatement().executeUpdate("UPDATE Gungenns SET area = 2 WHERE uuid="" + p.getUniqueId()+""");
return true;
} else if (p.hasPermission("essentials.warps.a3")) {
conn.createStatement().executeUpdate("UPDATE Gungenns SET area = 3 WHERE uuid="" + p.getUniqueId()+""");
return true;
}
}
return false;
}
public boolean update(Player p, Connection conn, Chat message, Economy econ) throws SQLException {
String query = "SELECT balance,rank FROM Gungenns WHERE uuid = ""+p.getUniqueId()+""";
String rank = message.getPlayerPrefix(p);
String replaced = rank.replaceAll("&", "§");
String stripped = ChatColor.stripColor(replaced);
ResultSet selection = Main.instance.getConnection().createStatement().executeQuery(query);
if (selection.next()) {
conn.createStatement().executeUpdate("UPDATE Gungenns SET balance=" + econ.getBalance(p) + ",rank=\"" + stripped + "\" ");
return true;
}
return false;
}``` i'm trying to update table values for each player but it updates for one and sets the whole row
and specify the ticks to wait until re running
I ask because i gived a player a custom itemstack (a beacon with custom name and lore), and i was asking the next "when he place a block how i would check he placed that block and no other block"
If you're listening to the place event you can get the item from the event
all scheduler methods are running on a threadpool/ different thread right?
The async ones yeah
i assume so but the sync ones get joined
and runTaskTimer does that runs on the main thread?
tbh I am not sure if my previous statement is true
Yes
but it will not interrupt the server?
e.getPlayer().getName() doesn't work for running commands apparently, what should i use?
non-async stuff will block the server
Synced will probably block main thread.
^^
ah wait lol i was confused a bit
what do you mean? Player#getName will always work
i forgot that it blocks too
and, what a surprise, it returns the player's name
when i run commands like Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "give " + e.getPlayer().getName() + " torch");
it says "player not found"
do minecraft:give
What you can do is run something async. So
asynctask -> {
doheavyasync
synctask -> {
sync processed stuff
}
}
although this means delays
obviously that player wasn't found then, noone knows what "give" command you're using
it uses the essentials one
what functional difference does it make?
ohh interesting
i'm not so proficient with minecraft commands
essentials has a different implementation which doesnt like some things
what is that even supposed to do?!
iirc @s @a etc doesnt work
hm
it would be helpful if you send the actual code instead of random examples
and some item names are different too
alright here we go again
` @EventHandler
public void onRespawn(PlayerRespawnEvent e)
{
if (e.getPlayer().getBedSpawnLocation() == null) {
e.getPlayer().sendMessage(ChatColor.DARK_GREEN + "You spawn in the wilderness.");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "execute as " + e.getPlayer().getName() + " run function namespace:respawn");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:give " + e.getPlayer().getName() + " torch");
Bukkit.getScheduler().runTaskLater(this.mainClass, task -> {
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,600, 1));
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,600, 1));
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,60, 1));
}, 1L);
}
}`
or whatever java formatting
that's the exact same thing as your "example"
btw
what happens if i use stuff from thread a in thread b, but i join thread b with a
I don't get it, first you said the code was "just an example", now it's not "just an example" anymore?
void main() {}
why do you dispatch commands instead of directly giving them a torch
int main() {
return 0;
}
how do i do that?
dispatch command is what i found when i looked up online
fn main() {}```
oh you mean like
declaration: package: org.bukkit.inventory, interface: Inventory
well because that's an example
player#getInventory()#addItem(ItemStack)
that i wrote to explain to you why the command above it doesn't work
Sorry For The Delay
public class CraftingRecipe {
public static ItemStack MonsterOfTheSea ;
public static ItemStack TurtleChestplate;
public static ItemStack TurtleBoots;
public static ItemStack TurtleLeggins;
public static void init(){
createTotem();
createGodApple();
createTrident();
}
private static void createTotem(){
ItemStack item = new ItemStack(Material.TOTEM_OF_UNDYING,1);
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("totem"),item);
sr.shape("BGB"+
"GEG"+
"BGB");
sr.setIngredient('B',Material.BLAZE_ROD);
sr.setIngredient('G',Material.GOLD_BLOCK);
sr.setIngredient('E',Material.EMERALD_BLOCK);
Bukkit.getServer().addRecipe(sr);
}
private static void createGodApple(){
ItemStack item1 = new ItemStack(Material.ENCHANTED_GOLDEN_APPLE,1);
ShapedRecipe sr1 = new ShapedRecipe(NamespacedKey.minecraft("apple"),item1);
sr1.shape("TGT"+
"DAE"+
"GGG");
sr1.setIngredient('A',Material.GOLDEN_APPLE);
sr1.setIngredient('D',Material.DIAMOND_BLOCK);
sr1.setIngredient('T',Material.TOTEM_OF_UNDYING);
sr1.setIngredient('G',Material.GOLD_BLOCK);
Bukkit.getServer().addRecipe(sr1);
}private static void createTrident(){
ItemStack item2 = new ItemStack(Material.TRIDENT,1);
ShapedRecipe sr2 = new ShapedRecipe(NamespacedKey.minecraft("trident"),item2);
sr2.shape("CCC"
+"SDS"
+"SDS");
sr2.setIngredient('C',Material.PRISMARINE_CRYSTALS);
sr2.setIngredient('S',Material.PRISMARINE_SHARD);
sr2.setIngredient('D',Material.DIAMOND_SWORD);
Bukkit.getServer().addRecipe(sr2);
}
}
?paste, please!!!
which is simply trying to link a namespace function into my plugin so that it can be used with more ease
ShapedRecipe#shape takes an array of strings
"DDD", "DAD", "DDD" for example
ohh
for this:
Diamond Diamond Diamond
Diamond Andesite Diamond
Diamond Diamond DIamond
Tysm
A very good link to learn recipes (coding them) ?
I don't know any tutorials, just look at what the API says, e.g. ShapedRecipe: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ShapedRecipe.html
declaration: package: org.bukkit.inventory, class: ShapedRecipe
the API is pretty straightforward
dad?
Diamond Andesite Diamond
son?
String Obsidian Netherrack
lol
but yeah I'd never hardcode any recipes anyway, they should always be configurable 😛
do you have any idea about what enums are?
so you use Enum#valueOf
omg it worked
of course it worked lol
bruh
here's my totally dirty way to parse custom recipes from config files btw https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/RecipeUtils.java
oop at its best
even though i usually dont listen to my own advice
1 word variables = bad
in most cases imo
e.g: final ShapelessRecipe recipe = new ShapelessRecipe(key, result);
what is re cipe
the recipe that people want to get
there is no other recipe
so what else would it be
yeah how am i supposed to know
because the class returns a Recipe
well base = choices.get(0);
do you also do "Player playerInvolvedInThisEvent = playerDeathEvent.getPlayer()" ?
what is that
base is the base item
addition is the item that gets added to it
e.g. diamond pickaxe + netherite ingot
diamond pickaxe is the base
netherite ingot is the addition
?
why would someone not use "recipe" as name if it's the only recipe involved?
Player p 😼
Player p is not good. Player player is fine
a little bit dangerous when you have another variable name starting with a p
unless there are two players involved
that doesnt make sense
but FurnaceRecipe recipe = .... is totally fine
base can be anything
mye
have you ever used a smithing table?
it only has two slots
mhm
a base item and the additional item
If someone gets cnofused about this, they truly have Alzheimer's
will do
i wouldnt name a variable its type
you never named a Player object "player"?
u get it
depends
sometimes its fine sometimes not imo
i would try to be as descriptive as i can without making the variable long
so you would rather name "base" "baseItem" although it's not an item but a RecipeChoice?
idk the context, i just thought its an item because you said "base item"
it might be a MaterialChoice or an ExactChoice
that depends on the config of course
I too like descriptive names but this method is merely 10 lines long
and baseItem would just be incorrect
it could be called "baseRecipeChoice"
mhm
but that's useless, there's no other variable with any similar name involved so yeah
I don't think that naming it "base" could cause any problems
but yeah I myself said that the class is messy, that's true
but I don't think that naming this 10 line variable "base" is the problem 😄
yeah merely base looks good here
I usually use this philosophy: if a variable only exists for 10 lines, no need for a long descriptive name
if it's part of a 300 lines method, yeah maybe baseRecipeChoice would be better
a variable's name should be proportional to the size of the scope its contained within
