#help-development
1 messages · Page 1948 of 1
What
When done properly, you won't need many lines at the end to create it
That's what I said
So what’s this player map
You surely want it to work on a server with at least two players
Why not map the view instead of a player
This doesn't really matter
Or at least a uuid, you shouldn’t use the entire player object as a key
A hashmap works by using the hash of a object. It doesn't care whether you're passing a subclass or the exact type.
And? You're removing it when the inventory gets closed
unless an exception occurrs, there's nothing wrong with it
I suppose the close event should be called on disconnect
It does
Anyway, this is the basic impl I use https://github.com/Jishuna/JishunaCommonLib/tree/master/src/main/java/me/jishuna/commonlib/inventory
Otherwise it wouldn't be any better whether you're using an uuid or a HumanEntity
Especially as the HumanEntity instance is still of the type Player at the end
Unless you don't want to learn, I'd suggest anyone to create it himself. It's not difficult
But that isn’t really relevant
APIs exist for a reason, you should be scared of using them
And you can always take the initiative to figure out how they work
It's using almost the same one as for the uuid. There's no huge difference
Gotta save them cpu cycles
You shouldn't use one for the most basic thing. For the same reason why you should learn Java properly before starting with spigot
bruh
A properly implemented gui is not trivial. But i get the point. Everyone should strive to write his own common lib,.
depends on the scope
for my plugins it contains common functions. Doesnt matter if others use it or not.
7smile your common lib probably unlocks the secret to the damn universe
Mine is "hehe, item builber
"
Pretty much the same XD
i had have an interesting question:
i have an configuration where you can configure stuff like
Minimal cost
Maximal cost
Max level
then my plugin will autimatically figure out what each level should cost. but i want to add another way you could configure this. this being manually like
Levels:
1: 100
2: 200
3: 300
etc etc...
how would i best go about doing this so that it would not break everything.
What you could do is provide a String which can contain a math. expression f(x) or more precise cost(lvl)
level-cost-expression: "lvl ^ 2 + 4.35 * lvl + 50"
And then use Dijkstra's shunting yard algorithm or another library (there are some good ones) to evaluate that expression form lvl 1 to N.
hmm thats actually a very interesting idea
Crunch
i'l take a look into that. thanks for the idea
Crunch is meant to be the faster, but I’m sure it doesn’t matter that much
Unless you are doing it every tick or soemthing
Not if you calculate all costs at startup anyways ^^
True
yea i can calculate all costs at startup
Didnt know crunch
Who cares whether you're using a standardized lib or not. At least when you're shading it properly, nobody should notice it
Oh its from Redempt?
Ye
This is something different. Nobody will notice it, unless they're working with the code
Sure but imagine if something already existed and you didn’t need to write one :p
Oh well, it’s a chance to learn
What's wrong with that? Because one exists already doesn't mean that you are able to create a new and possibly better one
With that thought we'd still be using C++ nowadays
Problem is that there is no unbiased indicator of how "good" a certain approach is
That's why you have to at least try it to learn what exactly would be a good approach for your application
@waxen plinth crunch 🥰
Back in the days we just Nashorned our way through math. expression...
No!
redempt is pretty cool
Like Maggi fix
Wait... is that too german?
Do you guys know what "Maggi" is?
No lol
i think i do
XD fk
is that the shit people pour on food?
and soup sometimes
Yes. Old people always pour that on soup and stuff. Hate it. Basically just msg and some fermented garbage.
ahh well im dutch, so that might be why i know
were close
Oh god
Noice. I can understand some dutch words because they are so similar to german ^^
Don’t mention nashorn to Choco
Yes...
Nashorn is so unbelievably slow
yea, its the same the other way arround
but ive never understood why u guys sail on the road
I originally wrote crunch because gecko was trying to use nashorn for expression evaluation
And it was taking a full 10 seconds to do 2k evaluations
Ridiculously slow
But can crunch do arbitrary exponents
I have no idea what that is supposed to mean.
50 ^ PI
Yes it can do that
Sure
You could literally just do 50^pi in crunch and it would work fine
Oh, dangit now I can’t judge
It's a very complete library
What about arbitrary roots
50^(1/7) lol
You got me there
But can it do complex arithmetic like (11 + 9j) / (4 - 5j)
No it doesn't do complex numbers
Also EvalEx uses BigDecimal and Crunch uses doubles for everything
Crunch is specifically built to be ridiculously fast
How so
As in what did I do to make it fast?
Yes. I thought parsing expression using Dijkstra is as good as it gets.
But what if I overflow a double
🤷
Using dijkstra?
D:
Dont overflow them
Not familiar with that approach honestly
shunting yard algorithm
Ah I see
Mine works a little differently
The first trick is that it uses a prefix tree to tokenize
He has 100 workers in a foreign country that do the math on request
i mean... its basically just unwrapping the exp and working with a stack
A prefix tree is very well-suited to finding any named tokens very quickly
rest api with some poor indian and a calculator on the other side
I reimplemented Double#parseDouble which is ~2x as fast as the standard library implementation
Exactly
And after creating the token list, this is how it reduces it:
- The token list is a linked list (custom implementation which gives access to the individual nodes)
- Creates a size 10 array of lists
- Iterates over the tokens, adding tokens to the list corresponding to their priority
- Iterates over the array of lists, getting and removing adjacent value tokens for each operator and then combining them into lazy Operation tokens
Through that process the entire expression is reduced to a single token
And it will also combine operators working only on literal values into just literal value
What do you mean by "token"
int: 5
So for example it will combine 3+4 into 7
float: 10.1249141491284918941
Ah i see
A token represents either an operator or an operand
yes, pop left, pop right, merge into operator
It can be a constant, a variable, an operator, a function name, a function argument list, or a lazy variable
How do you evaluate the priority?
Done with this step
It puts them in the list in the array with the index being their priority
Then when you iterate they're already in order based on priority
I guess it's basically radixsort in that regard
But since it keeps references to the linked list nodes containing the operators rather than the operators themselves
What if you have over 10 priorities
It can get the adjacent value tokens from the linked list node, then remove them and set the token there to be the lazily-evaluated one
This is one of the very few use cases a linked list is well suited for
There currently aren't but I would need to expand the array
Why do you combine value tokens into lazy operations instead of evaluating them on the spot?
Wouldn’t deeply nested () qualify
Because this is for compiling expressions
For example
1+x
You don't want to have to recompile this from a string every single time
You can evaluate the expression just once after it is compiled
But it's a hell of a lot faster to just hold onto the compiled expression and re-evaluate it
You can look at the benchmarks in the readme: https://github.com/Redempt/Crunch#performance
If you have different values for x. Get it
i know how bytecode works after creating my own tcp packet system
be proud of me
Good job

I can do that
use rust ^
At this point I feel like the speed gains will be very minimal unless I use JNI or something
Do it no balls
Ok
Mmm excellent now my stupid library can become even faster
And yet I still haven’t released anything with it
It’s for parsing effects and conditions for config files
AdvancedEnchants style
Would be interesting to see if using multiple threads for parallel branches is worth. Probably only for certain expressions like (big exp) / (other big exp)
I kind of doubt it honestly
I really don't think expressions would ever get long enough for the overhead of parallelization to be worth it
And if they are then people are insane
Yeah
And the other thing with that is that you would need to figure out what the two parenthesized expressions are first
At least, where they begin and end
So you would iterate over the string twice at least
And in doing so waste a lot of time that you could have just spent tokenizing
It might be possible to parallelize compiling the tokens after the string is tokenized but it would be very hard to avoid race conditions and the overhead would still probably not be worth it
Am i... seeing tabs for intendation here?
Cancelled
Uh EvaluationEnvironment is stateful. Means Crunch is not thread safe on default because of the DEFAULT_EVALUATION_ENVIRONMENT.
The only real way to do indentation is with /* indent */
Hm you could always just pass a new one i guess
I dont read readmes i read code lul
And EvaluationEnvironment should only ever be modified prior to compiling any expressions
You could make copies and whatnot but there isn't really a better solution other than copy on write
Which I wouldn't want because speeeeeeeeed
I like this. Consider it stolen added to my useful libraries.
:)
Is it better to have one evaluation environment with a bunch of variables, or multiple smaller ones per use case
Well any variables defined in the evaluation environment must be passed to the expression each time you call evaluate
If you have a lot of them you should either use lazy variables or wrap the compiled expression with something that can supply only the variables that are needed
Lazy variables are kind of ideal for it though
Yeah definitely use lazy variables for that
In one EvaluationEnvironment that has all of the variables you need as lazy variables
not exactly what #getPlayerTime() does at https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#getPlayerTime()
My plugin adds the time it returns to a database with playtime += sessionTime, but the first time an entry is made the playtime is set to 75k and is always increasing, then from there it just adds small amounts from 100-5k
I did create a github gist that lets you use PlaceholderAPI placeholders in crunch expressions
static {
ENV.setVariableNames("%food%");
}
I would rather extend EvaluationEnvironment with a class that takes a varargs parameter in its constructor.
And what is up with tabs and leaving out bodies?
if (!(entity instanceof Player player))
return false;
Google code style is dead 😦
You shouldn't really be using an EvaluationEnvironment for this anyways
You especially should not be using a different one for every variable
That defeats the purpose
This is a good use case for lazy variables
You can define them like
env.addLazyVariable("%food%", () -> someMethodToGetFood())```
I thought I set eclipse to use spaces
I always skip {} for returns
If you're gonna skip the braces you should inline the return in my opinion
But I still prefer leaving the braces
It should be this:
if (!condition) {
return;
}```
But if you must leave the braces out then
if (!condition) return;```
But so many extra bytes :p
What would be the method to do this without an evaluation environment
Hm im actually also writing conditions at the moment...
@Data
@EqualsAndHashCode(callSuper = true)
public class HeightCondition extends PlayerCondition {
private int height = 100;
private NumericComparison comparison = NumericComparison.AT_LEAST;
...
Maybe i should consider using crunch instead.
Do what
You definitely should 👀
What I’m currently doing
Oh
Since you said
You'd just make it have a getter for its name and a DoubleSupplier
Though read through this
This is a bit of a workaround to allow it to work for a given player, it's stateful and not thread-safe
But you probably don't really need it to be thread-safe
So this should work fine
Or an approach similar to it
Hell, you could just use PAPI instead of your own system
And do %player_hunger%
Crunch can do boolean math
Though it just evaluates to 0.0 or 1.0 since crunch only uses doubles
Hm thats very nice. My primitive implementation is def faster but less powerful...
How much faster could it be
Once compiled, crunch expressions are pretty insanely fast
trying to remove a hashmap entry , check if it was null(existed) , and also get the value only thing I can think of is temporary variables
Yeah just keep the value in a variable
Oh i see an error there
Oh so you mean the benefit is that it doesn't wrap them in lambdas?
I guess that would be a smidge faster
But the overhead of a method call is pretty miniscule
Sounds like an xy problem
If you need to do that then you have probably a big design issue
^
XD
Why would it not be
If you need to get a task by ID then that's probably a design issue
If you need to cancel one by ID that makes sense
Yeah that's why you should always ask for help with your overall goal rather than your attempted solution at it
?xy
Asking about your attempted solution rather than your actual problem
this is what im doing https://paste.md-5.net/havolinudu.cs
you can tell me if theres a design issue pretty short
basically adding delays to teleports
all the forum posts urge people to use it
Bukkit.getScheduler().runTaskLater(plugin, () -> {
// Do stuff
}, ticks);```
Much cleaner
Yeah it is but it hurts my brain to read
Why
idk the arrow just makes no sense and the empty parenthesis
Yeah probably are
So basically I just want a single evaluation environment with a bunch of lazy variables
Right
Makes sense, also means I can condense all my numeric conditions into one
does getScheduler need to be called by the main class
I could technically do the other ones too, but users might get confused by something like %on_ground% = 1
No
Ok coo appreciate it
Why would they do = 1 there though
If %on_ground% is already either a 0 or a 1 then they wouldn't have to
Well true and false are just constants mapped to 1 and 0
I can Boolean I swear
So now your booleans can be 64 bits wide instead of 8 😁
Here is the rest of it where i cancel in case anybody cared lol https://paste.md-5.net/onutofuwoq.cs
Yeah this means I can just use a single condition, so users could do something like %on_ground% & %y% < 63
Yep
I wish someone told me that before I wrote them all :p
Oh well
Oh lazy variables didn’t exist when I made this
Yeah lol
That also makes sense
They are a very new addition
I noticed that a lot of people were trying to do this sort of thing
And regular variables are not really good for that
So I added lazy variables
I mean they're essentially just zero-arg functions that don't require the () to be called in the expression but they're really useful
%on_ground% & %y% < 63 is much cleaner than %on_ground%() & %y%() < 63
👌
I’ll probably still do some basic ones myself though, no sense requiring papi if I just want to use %health%
Yeah and papi will almost definitely be much slower
Because it has to fetch it as a string and then parse the string to a double
Also only applies to players
Although that means I probably shouldn’t use %xxx% for mine to avoid clashing with papi ones
You could always do something like $on_ground
Yeah that seems good
Does the Value class retain whitespaces?
No, why would it?
Whitespace is discarded when the expression is compiled
I mean, you could define a variable, function, or lazy variable with a space in its name and that would be valid
But otherwise it's ignored
Sure. But i would like to present the user with "x < 100 & x > 50" if he wrote it that way. So i need to keep track of the original String myself.
Will a Boolean expression always evaluate to exactly 0.0 or 1.0 or is it subject to precision jank
Then you could wrap the CompiledExpression with a class that also holds the String it was created from
CompiledExpressions have a toString() implementation that will spit out a string that you can use to compile the same expression again, but it's not particularly readable
Should always be exactly 0.0 or 1.0 since no math is being done on them
👍
You guys should join my support discord and ask for help there to make it less dead lol
How can I get access to a private method within a class that's within a class?
Inner class?
indeed
You dont. Maybe with reflections. Why do you need that?
I assumed they meant reflection
I'm trying to use reflection
Is the class static? Is the class private?
Is it static?
no
What? Why would someone use protected in an inner class?
Could you get the class with Class.forName?
So its not static? I feel like there is another approach to this...
The API has a setSpell method
that is not the same thing
No idea if that causes it to fire instantly though
Ah, it doesn’t trigger it though
wdym
Something like Spellcaster#castSpell
I can look at it sometime
Until then idk, my only idea is to get the inner class using Class.forName and then go from there
well
I'm like 40% sure that I have it, the problem is that the method I'm using doesn't use the object I have for the evoker, it just uses the class itself so it obviously won't be able to cast from that evoker
What does the code look like
EntityEvoker entityEvoker = (EntityEvoker) evoker.getSingle(event);
entityEvoker.setSpell(spel);
Class<?> innerClass = EntityEvoker.class.getDeclaredClasses()[0];
Constructor<?> constructor = innerClass.getDeclaredConstructors()[1];
constructor.setAccessible(true);
try {
Method m = innerClass.getDeclaredMethod("j");
m.setAccessible(true);
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
I feel like that's wrong in every way possible
🚎
You gotta replace that null with an instance of said class
Which I assume you can somehow get from the evoker
You can do Class#getDeclaredClasses
Which will get all internal classes of a given class
Who know how to get advancement type on 1.18.1?
Oh you already are lol
This is basically the way you have to do it
it doesn't connect to the original object at all
Oh
m.invoke(null) invokes the method in a static context
To invoke it on a specific object you have to pass that object
so it would be m.invoke(entityEvoker)
What’s the inner class here
a
Well if you're invoking a method on the inner class
Yeah AI goal
Then presumably it would need an instance of the inner class
So you need to get the instance of that goal from the evoker
this is hurting my brain
first time using a hashmap and no clue why it's returning null
So HashMap<UUID, Long> hm is a private static in my main, with a getter and setter
I have 2 listeners, one for players joining and one for players quitting
On join, it gets the hashmap getHm(), puts the UUID as key and the current system time millis as Long. Then it sets the hm setHm(newHm) with the added key and value
On leave, it uses the player's UUID to get system time millis for getting the session playtime then removes the key and value
why would it return null if the player's UUID doesn't change?
The code specifically looks like this
On join:
HashMap<UUID, Long> hm = TrackPlaytime.getHm();
Long joinTime = System.currentTimeMillis();
hm.put(event.getPlayer().getUniqueId(), joinTime);
TrackPlaytime.setHm(hm);```
On leave:
```java
HashMap<UUID, Long> hm = TrackPlaytime.getHm();
long timeJoined = hm.get(player.getUniqueId());
long sessionTime = System.currentTimeMillis() - timeJoined;
ptd.addPlaytime(sessionTime);
db.addToDatabase(ptd);
hm.remove(player.getUniqueId());```
The getter and setter:
```java
public static HashMap<UUID, Long> getHm() {
return hm;
}
public static void setHm(HashMap<UUID, Long> hashy) {
hm = hashy;
}```
I did read the documentation and #get(K) is supposed to return the value of the key
Is there a channel for advertising our server ?
Who know how to get advancement type on 1.18.1? 😶
I feel like this would be helpful
No
K
Advancement type?
Yes
What do you mean by type
(Normal,goal,challenge)
Bruh, ok
Lol
I can look at adding that to the API
Ok
does this look right
So once I get the method what do I need to pass through to connect it to that object?
Here's my updated code:
EntityEvoker entityEvoker = (EntityEvoker) evoker.getSingle(event);
entityEvoker.setSpell(spel);
Class<?> outerClass = entityEvoker.getClass();
Class<?> innerclass = outerClass.getDeclaredClasses()[1];
try {
Method m = innerclass.getMethod("j");
m.setAccessible(true);
m.in
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
um how to add net.minecraft.server? it says not found
you need build tools
this is what?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Dealing with tripwires, how would I stop breaking a tripwire from changing the state of tripwires near it/connected to it
any help with this?
?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.
I did read the documentation and #get(K) is supposed to return the value of the key
I set a joining player's UUID as a key with long system time in millis as value, and when they leave the server it uses their UUID to get the time they joined
getting the value with their UUID key returns null
Then you didn;t add the K/V or you are referencing a different map instance
I used a getter to get a static hashmap holding all of the keys and values of players and when they joined respectively, and a setter to set the hashmap to that but with another k/v put into it when someone joins
the code segments are there
Nvm, he didn't have a target set
My guess, you are replacing teh map when a player joins so it only ever holds one player
this is what happens when a palyer joins java HashMap<UUID, Long> hm = TrackPlaytime.getHm(); Long joinTime = System.currentTimeMillis(); hm.put(event.getPlayer().getUniqueId(), joinTime); TrackPlaytime.setHm(hm);
yes, you are replacing the map instance
lol
Your Map is STATIC so just get values, don;t get teh whole Map
if your map is static
you can access it from anywhere
why bother making a getter
yes goodnight
you should sleep soon too
yeah thanks for reminding
i should finish the readme first
then ill just gonna go and sleep for 2 hours
bruh nms so big maybe it has some docs? 😶
no
uh
00:23 am lol (12:23)
so I figured out the problem why the hashmap was always null
2 hours later at 1 am
I never registered the playerJoin event
How can I check If an entity is out of player's render/view distance?
Hey, how can I prevent a mob from despawning?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#getViewDistance() you can check any entities within the server view distance radius for players
Is there any other alternatives, I will use this very frequently.
getNearbyEntities method is not really good If I use it every second for example and to all players, correct?
how to build a structure from a schematic file?
Minecraft itself calls this thoussand times per tick
When i want to make my plugin work from like 1.13-1.18, which API-version do I have to set?
lowest
ok thanks
anyone know a fix? been at this for hours
?paste the code where the error occurs
well
So it is okay for me to use that very frequently?
i gotta implement hte methods
alt+enter with cursor on pig and click "implement methods"
and
please
theres nothing to implement
dont name youre classes lowercase
oh i know how to name my classes
i'm just done with this one
it implements nothing
its that the class i need to implement clashes however i can't find any resolution to this issue
as it is with EntityInsentient and EntityLiving having both methods called x()
remapping the jar changes x() to getLeash
yes
Alright, thanks for that.
Implement «Pig»
Basically I want to do something If an entity goes out of player's perspective or unloaded from player's perspective, so what would you suggest on how I do that?
The way you do it really depends on what you’re doing
I want to destroy an armor stand that was spawned with packets, so my problem right now Is I have an armor stand that rides player, and when the other player who have armor stand goes out of vision (unloaded) from another players, the armor stand will be dismounted only on the another players perspective.
Let's say P1 and P2, P1 has armor stand that rides him and P2 can see the armor stand mounting on P1, and P1 goes out of P2 vision (unloaded) and the armor stand is dismounted on P2 perspective but not on P1 perspeective.
If P1 still has the armor stand why destroy it?
It looked dismounted on P2.
There are several ways, whether mounted it back on P2 or destroy the armor stand and equip it on P2 perspective.
Left P1, Right P2
Well you can check for nearby entities that isn’t the player it’s mounted on and if any other player entity is there then do nothing yet
What do you mean? I don't understand.
#getNearbyEntities()
I mean I want to destroy it on P2 perspective not on P1 perspective.
You might be looking at NMS
@ancient jackal can you tell me how to get the exact distance with the maximum view distance?
For the getNearbyEntities method.
Fixed
How can I spawn 12 villagers which ride each other (like stacked)
so I am trying to broadcast this
Bukkit.broadcast(Component.text("updating angles with aspose to " + Math.toDegrees(armorStandPose.x).toFloat() + Math.toDegrees(armorStandPose.y).toFloat() + Math.toDegrees(armorStandPose.z).toFloat()))
I am not getting any syntax errors. But on build I am getting these errors:
Type mismatch: inferred type is TextComponent but String was expected
No value passed for parameter 'p1'
are you compiling against paper api ?
is your server also running paper ?
spigot does not offer first-level support for adventure
can u make an entity ride another entity ( i want to make a villager ride another villager )
setPassengar
hey i can't find why my plugin isnt loading, it may be because of the new config system im trying.
java.lang.NullPointerException: null
at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:28) ~[?:?]
at com.clonkc.vlands.kitpvp.Main.registerListeners(Main.java:32) ~[?:?]
at com.clonkc.vlands.kitpvp.Main.onEnable(Main.java:19) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_311] ```
do u need my class
i can send it in paste bin
adding vector to player location
Deprecated
Java 15+ is your friend
why does everyone have to comment on that
i have my reasons and i need help with this
Because it has smart NPEs, it'll tell you exactly what is null absolutely no need to ask anyone about it
well, thats useful
wait
but i still need to know
what is the best coding website?
depends on what u are coding
get an IDE
Well, what is com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:28) ~[?:?]?
well im new and im trying to disable elytra
i already
If you just want to know java, https://docs.oracle.com/javase/specs/jls/se17/html/index.html is best suited
Plus https://www.oracle.com/technetwork/java/codeconventions-150003.pdf is also pretty important
Guys how can i get a Base64 custom head in an ItemStack?
I want to use this code: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzhmZjQ3M2JkNTJiNGRiMmMwNmYxYWM4N2ZlMTM2N2JjZTc1NzRmYWMzMzBmZmFjNzk1NjIyOWY4MmVmYmExIn19fQ==
anyone know where i can get a json list of every 1.8 sound in minecraft so i can pick a random one when a block is broken
Get a random entry from the sounds enum
how do i do that
i want it to be version dependent because obvs cant run a 1.18 sound on a 1.15 server
anyone know of a way to assign a passive mob the ATTACK_DAMAGE attribute, using the getAttribute() method will return null as a passive mob doesn't naturally have the attack attribute but any other way of assigning one?
NMS
im using nms
Probably have to add the attribute to them
easier said then done
Exactly
please
You are using nms, you’re kinda on your own
i know
See if the forums have anything
already checked
Use the PlayerProfile API
i ask here last if i can't find anything anywhere
there are methods for older versions like 1.16 and 15 but all those methods that i've tested don't work on 1.18
I don't want the offlineplayer i want the encoded 64 player head
technically you could just force set it with sth like reflection, or even unsafe
No one said anything about offline player
oh ok
👀
I can't access the createPlayerProfile method... What server do i need? I tried Bukkit# and Server# but nothing shows up
Latest
what?
Latest 1.18 at that
I'm in 1.17
Then you don’t have it
anyone know why this is happening? i ran it through a yaml validator and its fine
org.bukkit.configuration.InvalidConfigurationException: mapping values are not allowed here
in 'string', line 3, column 12:
goldenheads:```
my config:
```goldenheads:
cooldown-msg: "&cGolden Heads are on cooldown for &6%timeleft% &cseconds"
effects:
- "ABSORPTION:3:120"
- "REGENERATION:3:8"
item-lore:
- "first line"
- "second line"
- "third line"
item-name: "&bHello"
wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato consume!"
throwablefireballs:
blast-radius: 4
cooldown-msg: "&cFireballs are on cooldown for &6%timeleft% &cseconds"
damage-multiplier: 1
fireball-speed-multiplier: 1
item-lore:
- "first line"
- "second line"
- "third-line"
item-name: "&bWorld"
wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato throw!"
may you post entire stacktrace? cuz i feel like it is not all
?paste
it is valid as it seems
yea so i have no clue why
might be snakeyaml error
Is there a way to get material ID in 1.18?
maybe the : ? "ABSORPTION:3:120"
that shouldnt affect it right
its a string placeholder
it should be a string
and im not doing anything with it yet
What is that?
yea it wont
A utility to deal with legacy materials
i saw multiple plugins done it
?xseries
Numeric IDs are dead, don’t use them
IT WORKS! TY
anyone know why my yaml is invalid then?
snakeyaml error then
Your error says goldenheads is line 3
have you tried turning it off and back on again?
What are lines 1 and 2
wait
a comment and a blank line
i updated it, ill send the new one
cooldown-msg: "&cGolden Heads are on cooldown for &6%timeleft% &cseconds"
effects:
- ABSORPTION:3:120
- REGENERATION:3:8
item-lore:
- "first line"
- "second line"
- "third line"
item-name: "&bHello"
wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato consume!"
throwablefireballs:
blast-radius: 4
cooldown-msg: "&cFireballs are on cooldown for &6%timeleft% &cseconds"
damage-multiplier: 1
fireball-speed-multiplier: 1
item-lore:
- "first line"
- "second line"
- "third-line"
item-name: "&bWorld"
wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato throw!"
tjats it currerntly
Make sure the file in your server is up to date
im checkin now
wait i think server.pro and other host is kinda "illegal" right
cause we can download the spigot jar/minecraft jar through their files
lol
But how I get material ID in 1.18 of 1.8 material?
use xseries
@ivory sleet does this looks good?
https://paste.helpch.at/esilekigot.java

i know why, my default config was different from the one stored in the server files. It doesnt regenerate if it its invalid
i might make a util for that
imagine you didnt know that 😒
:(
you can use the update config
o oka
lol ok
But does it heck comments
basically how they work was that they have the config-ver or something in their config, and each startup they check if the config-ver is the same as the config-ver they have
if they arent
they will rename the file to old_config.yml
then generate new one
could use that for my lang file
instead of removing that old config then generate new one
however it just loops through the values so i wont need it
renaming it to oldconfig to help server owners to transfer any important values from the old config to the new config if they need to
@sacred mountain
mk
I think redlib handles it without yeeting the old one
How to cancel player login?
whitelist the server
Isn't there an event for such things?
i have a weird problem where knockback lags from the damage
idk how to explain
the entities take damage first, and then take kb a short bit later
and i have no idea why
anyone?
import com.clonkc.vlands.kitpvp.Main;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;
public class DamageHandler implements Listener {
Plugin plugin = Main.getPlugin(Main.class);
public DamageHandler(Main main) {
}
int explosionmultiplier = plugin.getConfig().getInt("throwablefireballs.damage-multiplier");
double localradius = plugin.getConfig().getInt("throwablefireballs.blast-radius");
@EventHandler (priority = EventPriority.HIGHEST)
public void onExplode(EntityDamageByEntityEvent e) {
if (e.getDamager().getType().equals(EntityType.FIREBALL) && e.getEntityType().equals(EntityType.PLAYER)) {
double d = e.getEntity().getLocation().distanceSquared(e.getDamager().getLocation());
if (d <= 2.0D) {
e.setDamage(16.0D);
} else {
e.setDamage(12.0D);
}
for (Entity entity : e.getEntity().getNearbyEntities(this.localradius, this.localradius, this.localradius)) {
if (entity instanceof LivingEntity) {
LivingEntity le = (LivingEntity) entity;
double dist = e.getEntity().getLocation().distanceSquared(le.getLocation());
if (dist <= 2.0D) {
e.setDamage(18.0D * explosionmultiplier);
} else {
e.setDamage(14.0D * explosionmultiplier);
}
}
}
}
}
}
pure server lag
the server is fine
you are lag
well
i have 1 ping
if they are running on your pc
most of the times that is lag
i wont write a wall of text here to explain why it lag
but basically
Any thoughts?
Caused by: java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:143) ~[?:?]
at com.modnmetl.virtualrealty.commands.test.TestCommand.onCommand(TestCommand.java:35) ~[virtualrealty-2.0.0.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 21 more
Input: /test 2:0
XMaterial.matchXMaterial(Integer.parseInt(args[0].split(":")[0]), Byte.parseByte(args[0].split(":")[1])).get().parseMaterial()
your pc are not good enough to run a server, even though it is 20 tps, it still lag
i havve 64 gig of ram/
i know as in
it usually runs fine
and ghast fireballs work
like from the ghasts
this is pretty much the same thing so idk why its happening
Byte.parseByte(args[0].split(":")[1])).get() is an Optional and calling the get() method when its internal value is null, will result ina nosuchelement exception
matchXMaterial cant find a material that matches your input so it retunrs an empty Optional
^^
Actually more ram means more lag with the wrong GC settings and too much RAM allocated
geol is typing
Intel(R) Core(TM) i7-4701EQ CPU @ 3.40GHz 3.40 GHz
took a while to find it
its just me online
and its a flat world
well i guess i7 should be enough to handle at least 1 player then
yes
yeah, that is a common beginner error
have you seen input?
i really doubt its my pc thats why im asking for help
no i did not
🤷♂️
.
setting the damage of an explosion shouldnt take a long time right
I want to get it thorugh material ID
try use name
But I don't want to..
Since when does parseByte return an Optional?
ah nvm, confused some stuff
Because I don't want to use that. I want to get material from ID. I told you previously.
xd
I dont have choice
looks weird too that method that call
Would it be possible to simply trigger legacy mode?
cant even read
On the bottom
?paste it bro
?
nah dont mind it
im really confused now
so basically
i added some code comments and compiled the plugin
and now it works
huh
like i legit changed nothing
well at least it works now
wym by use anything
like only the server with mc or something else too?
nope, i didnt change anything
(i. e. accidental dos)
yeah well thanks anyways :) at least its fixed now
how can i get the latest accessible inventory slot
can i cast a Object[] to String[]?
like this
and if only one arg is passed in will it be a new String[1]
anyone know how to print colors to the console?
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "yes")
ChatColor#translateAlternateColors is smth too
it works on the windows commandprompt
player.sendMessage("You can't enable your pvptimer for another " + (10000 - (System.currentTimeMillis() - cooldown.get(player.getUniqueId()))) + " seconds!");
Is there anyway to convert this to seconds
would this work
import org.bukkit.Bukkit;
public class Logger {
public static void log(String msg) {
msg = ColorUtil.translateColorCodes("&6[LOG]&r " + msg);
Bukkit.getConsoleSender().sendMessage(msg);
}
public static void debug(String msg) {
log("&6[DEBUG]&r" + msg);
}
}```
I doubt it
just want to make a quick util so ican use it everywhere
just.. math?
math is hard
I s = 1000 ms
Nah, that is 3rd grade math
Okay perhaps not as these are pretty large numbers, but the basics behind it are 3rd grade
yeah idk how america does stuff so i just went with what would be expected from america
we arent that stupid
without syntax highlight i cant even see the code
well some are
cmon most of you are the kind of people that would type EU as a favorite country
classcast exc meh
personally asia is my favorite country /j
No, but paris is one
ah yes
which asia country
Why?
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class net.md_5.bungee.config.Configuration (java.util.ArrayList is in module java.base of loader 'bootstrap'; net.md_5.bungee.config.Configuration is in unnamed module of loader 'app')```
`dataConfig.set("PlayerData." + uuid + ".Punishments.Ban.Initiator", banPunishment.getInitiator());`
PlayerData:
71cd065e-3980-4f06-8da6-769311af1132:
Punishments:
Mute: []
Ban: []
UltraBan: []
IPBan: []
Warns: []
its the country that has america as its worlds
thats the point...
double ban
triple ban
I don't cast anything there
?paste
And what is the datatype of .getInitiator()?
UUID
I think I know why it is happening, but I cannot really put it in words
🤔
It's BungeeCord btw
type stracktrace
Basically https://github.com/SpigotMC/BungeeCord/blob/master/config/src/main/java/net/md_5/bungee/config/Configuration.java#L63 throws the exception
Ah, ban is a list
oh dear fuck
yes, but I can't do it for some reason
how can I
using Bungee API
Declare it is a config section and not as an array
I.e. instead of
PlayerData:
71cd065e-3980-4f06-8da6-769311af1132:
Punishments:
Mute: []
Ban: []
UltraBan: []
IPBan: []
Warns: []
you'd have
PlayerData:
71cd065e-3980-4f06-8da6-769311af1132:
Punishments:
Mute: []
Ban:
UltraBan: []
IPBan: []
Warns: []
What is the class of the Config section?
I tried this
@Override
public void registerPlayer(ProxiedPlayer proxiedPlayer) {
UUID uuid = proxiedPlayer.getUniqueId();
dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Mute", new Configuration[0]);
dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Ban", new Configuration[0]);
dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.UltraBan", new Configuration[0]);
dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.IPBan", new Configuration[0]);
dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Warns", new Configuration[0]);
saveConfigFiles();
}
Basically remove dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Ban", new Configuration[0]);
That declares it as an array, not as a section
How can I declare that as an empty config section?
Which means that key-value mappings can be specified
maybe to put there an empty map?
cause in Bukkit API I do it by new ConfigurationSection[0]
That shouldn't work either
I'd say via https://github.com/SpigotMC/BungeeCord/blob/master/config/src/main/java/net/md_5/bungee/config/Configuration.java#L133 but I never used bungee myself, so ¯_(ツ)_/¯
It is probably best to just not declare it at all
Found it, via config.set("path", new HashMap<>()) (see https://github.com/SpigotMC/BungeeCord/blob/master/config/src/main/java/net/md_5/bungee/config/Configuration.java#L113).
unnessecary toString ._.
can be useful for nullabillity assertions
I'll try it now then
hmm ._.
Does anyone have any negative experiences with Locale#getISO3Language (specifically it's performance)? I do not quite like it's implementation but it also appears to be the only sane way of indexing languages as the others seem to be built on not well defined standards where as getISO3Language is very direct in which implementation it uses
Hi i have a java question: I have a class named CustomEnchant extanding Enchant (Enchant from bukkit method). When i try to call CustomEnchant::canEnchantItem() it call Enchant::canEnchantItem(). And when i try to cast my call i have an error about : Cannot casting CustomEnchant with CustomEnchant
I there some way to call the good class method ?
is there a better way lol?
System.arrayCopy
so
String[] a = new String[args.length];
System.arraycopy(args, 0, a, 0, args.length);
hey my config cant currently be changed when you edit the file, how do i fxi this?
Though if you want to invoke .toString on all the objects, You'd need to iterate over the array
plugin.reloadConfig(); isnt working for me
alright
?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.
java.sql.SQLException: Invalid utf8mb4 character string: 'ACED00'
On
public Rating getStoredRating(UUID player)
{
return getFirstValue("SELECT * FROM {table} WHERE player_uuid = ?", player);
}
why {table}
That is replaced
Uhm, wouldnt thst cause cast errors? He needs to convert objects to strings
why not just "SELECT * FROM " + tableName?
This is more easy
I know, but any answer for my error?
Just keeping the name of your table is easy too 🙂
Wgar data type you use for uuids?
show where you do the replace
public T getFirstValue(final String query, Object... values)
{
List<T> data = get(query, values);
if(data.isEmpty())
return null;
else
return data.get(0);
}
public List<T> get(final String query, Object... values)
{
PreparedStatement preparedStatement = this.database.prepareStatement(query.replace("{table}", getName()));
.....
I feel like that introduces a bigger failure point then just hardcoding the name would be
Have you tried yhis on other databases?
Yes, but if it can be expected that they are all strings, then that is the way to go, otherwise iterate over array
Printed to console: com.mysql.cj.jdbc.ClientPreparedStatement: SELECT * FROM pastseasonratings WHERE player_uuid = ** STREAM DATA **
** STREAM DATA **????
and where does getName() comes from?
That works, that is just a public field with the name of the table
That one is correct in this query
anyone know why my plugin doesnt enable?
[13:19:20 ERROR]: Error occurred while enabling VLandsUtils v1.3.0-CONFIGUTILTEST (Is it up to date?)
java.lang.NullPointerException: null
at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:25) ~[?:?]
at com.clonkc.vlands.kitpvp.Main.registerListeners(Main.java:30) ~[?:?]
at com.clonkc.vlands.kitpvp.Main.onEnable(Main.java:16) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_311]```
java.lang.NullPointerException: null at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:25)
i can see that. i just dont know whats wrong
at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:25) ~[?:?]
whats the code ?
A null value is used
whats in your FireballMain file line 25?
what version is the plugin and the server ?
.
float blastradius = Configuration.get().getInt("throwablefireballs.blast-radius");
Configuration.get() or .getInt("throwablefireballs.blast-radius") is null
Configuration.get() is null i guess
Anyone knows why I get ** STREAM DATA ** if I put in an UUID value?
getInt cant return null
hm
Then this
what does that return?
Have you tried explicitly calling toString on uuid?
Trying...
Hm that works, thanks!
i would do WHERE player_uuid=? instead of using the spaces idk if that would be something
Returns:
Requested int.
what does Configuration.get() returns?
Why? I'd like it with a space
@Contract(pure = true)
public static FileConfiguration get()
Inferred annotations:
@org.jetbrains.annotations.Contract(pure = true)
thast when i hover over it
oh was just wonderinf if that was the problem
How do you set preparedstatement arguments?
for(int i = 1; i <= values.length; i++)
preparedStatement.setObject(i, values[i - 1]);
setString probably
that makes sense
im following a tutorial on config files btw, so this is where i get the code from the vid im watching
you set directly an uuid, not the string representation
But that could also be an integer or long
Yes I thought so
And it probably has some custom adapter
instanceof UUID ?
And that means?
you didnt call setup()
before calling get()
so it is null
and static mehh
A modern fluent java sql library
No need for right now, still thanks for helping me out
i called it in the main class
does it have to be called in all classes using configuration.get?
no
Just don't use singletones
or dojava FIleCOnfi get() { if (customfile == null) reload() return customfile }
public void onEnable() {
this.registerListeners();
this.registerCommands();
//Setup config
getConfig().options().copyDefaults();
saveDefaultConfig();
Configuration.setup();
Configuration.get().options().copyDefaults(true);
Configuration.save();
}```