#help-development
1 messages Β· Page 625 of 1
Something[] nativeArray = /*your array*/
for (int i = 10; i < nativeArray.length; i++) {
Something smth = nativeArray[i];
}
Array.copyOfRange() returns copy of the array from the specified range what i need in my case is something like List.of(array) but with an argument that allows me to make a list view starting the specified position
wdym by collection view
so like List<String[]>?
but starting from the specified position
or just a list implementation using arrays
I think he wants to wrap an array into a list, but taking the elements from <index> to <array size>
You can't without creating a list object and iterating through the array
hmmm idk of any libs that do, this unfortunately sowwy 
basically something like Arrays.asList() but with a separate argument
to specify from which index to make it wrapped
Arrays doesn't have a "listOf" method
edited
would List.of(array).subList(x, array.length) be good
I mean if you don't wanna make copies Unsafe is the way to go though
you get the memory locations of the elements of the list you wanna 'copy' and transfer them over
.sublist() seems what i need
but how can i create list backed by the same array
without copying
you'll need unsafe as I said earlier, java loves copying and making references. So how do you not get it to do that? Do it manually and ensure it doesn't happen
Why don't you want to create a copy if I'm allowed to ask?
Muh cpu cycles
Oi mate why donβt ya just program in binary
Don't π
I program in HEX
It's shorter than binary and better
Or you could create your own implementation that works over the original array using an offset
public static <T> List<T> partialArrayList(T[] paramTypeArray, int startIndex) {
int length = paramTypeArray.length - startIndex;
T[] arraySegment = (T[]) Array.newInstance(paramTypeArray[0].getClass(), length);
System.arraycopy(paramTypeArray, startIndex, arraySegment, 0, length);
return new ArrayList<>(Arrays.asList(arraySegment));
}```
why do you need this specific behavior?
Guys how i can manage Vault without using another plugin for it?
implementation:
List<Integer> copiedList = partialArrayList(originalArray, startIndex);```
i want to create a provider from my self for manage it
Then you need to look into implementing vault
because im creating my own command api which is based on nodes, and copying the same array for each of the command node would be wasteful, and i want to return what arguments are not matched with nodes
where i can found a wiki for it
Oh thats actually hilarious
We just finished up on our command package for our library and have done something very similar
π
But yeah ur welcome π
Should work for literally any type of array
As long as u dont goof and put a different type parameter in the List<T> bit
Does it suit your needs?
....
intellij doesnt detect built in types
not really
Why?
i found using Arrays.asList().toSublist() works better since it doesnt involve copying the array elements in any shape or form
Erm... toSublist?
am i going mad? Ive never heard of that method and dont seem to have access to it in my List
its just .sublist(x,y)
public static boolean isInt(String s) { try { Double.parseDouble(s); } catch (NumberFormatException nfe) { return false; } return true; }
why does this not properly identify doubles?
method name is wrong, but an int can parse as a double
my brain stopped while naming it apparently, but this doesnt work when i enter strings as well
what are you using as a string?
ah yeah that explains it
what arg specifically are you expecting to parse as a Double?
args[1]
/example example this
?
my brother in christ he was giving an EXAMPLE
like "this is where my double will be "
yes
also ready for a neat trick? (if ur not on ur phone)
How are you writing your double? Using a coma, or a dot?
why not, as long as you are not stealing my account
public static boolean isInt(String s) {
try {
Double.parseDouble(s);
} catch (NumberFormatException nfe) {
return false;
}
return true;
}```
no, i want to check if a string even is a double
i tried to :(
That's why I asked, you said it isn't working
If you are writing a double using "," instead of ".", it won't work and will always return false
yes, but im not trying to do this because this is not the issue
im entering a string
This seems like the perfect time for you to unit test my friend.
Set up a unit test for this method and put a break on the begining and end of the try.
and my code is built to identify if the string is a double
i dont know what a unit test is
Welp
https://www.youtube.com/watch?v=vZm0lHciFsQ
Today is a good day to change your coding life π
Full tutorial on creating Unit Tests in Java with JUnit!
Do you write Java code that you're just not confident is 100% right? You can create unit tests using the JUnit testing framework to verify your Java code, and I'll show you exactly how to do it.
Many beginners don't know there's a great way to test their code with simple, fast tests and...
And what's wrong then?
it doesnt identify that a string is not a double
even though the code seems fine
can you show how your code doesn't work, because that code works 100%
idk wait
if(isInt(String.valueOf(number)))
im using this to check if it is a double or not, before the rest of the code is executed
Of course it will always return true
You are parsing a string value of a number
Aren't you?
maybe :(
An integer will be always a valid double
number is args[1]
so player input
but the player input is exepected to be a double
Can you show the full code?
You should have something like that
String input = args[1];
if (isInt(input)) {
double db = Double.parseDouble(input);
}
guys I love living in the future
Btw, why don't you just?
String input = args[1];
try {
double number = Double.parseDouble(input);
//TODO: work with number
} catch (NumberFormatException ex) {
sender.sendMessage(ChatColor.RED + "Write a valid number!");
}
I don't personally like the idea of making a call to a method with the same argument twice
idk, it just the only way i thought of creating it without changing to much code
It's ok your way, it's just a personal question
everything was already done except this error check
wtf
is this the auto response
or some kind of karen
if im comparing 2 invs i need to implement inventory holder?
no, just compare their instances
Does that really work?
I guess it works for player inventories, but what about custom inventories?
you create every inventory with Bukkit.createInventory, and when you do player.openInventory(inv) it holds inv instance
and same instance will be sent in any inventory event
so basic == would work
What do you check with == exactly? Should you store the created inventory somewhere to be checked for the event lately?
yes, if you create it
So like a chest block?
yes
I knew that the use of InventoryHolder was not "approved", but didn't know the reasons (so I still used it)
I guess it's time to update some code π
InventoryHolder is used to set who holds (entity, block) the specified inventory
not to store metadata
so that's why its discouraged
also this method of storing metadata doesnt work with beacons and anvils afaik
and you need some kind of nms workarounds
llama 2 presented by meta
now 200% more advertiser friendly
Iβm a singleton :(
wow
you can't use that language here
you're going to the gulag
Not the furry gulag
You're a singleton, we are all singletons. Only one instance of us are in this world π
You saying "in this world" implies that there's other worlds and we therefore aren't singletons
Some people believe in the a multiverse and that you exist many times with slight differences in each universe
another world does not mean you would not be a singleton
even in a multiverse with exact copies you are still a singleton
Well you wouldn't be an exact copy that's what I'm saying. Sure you could still implement us in a singleton and make changes before "ticking" every universe but having multiple instances just makes it easier
depends if you were one in the first place. Is there a class "Coll1234567" or are you an instance of human with a uuid?
Since humans have a lot of things in common I'd highly doubt everyone has their own class. If I had to write a simulation of planet earth I'd definitly not use a singleton for each human
But would you have a single human class with all the properties
Or would you make some subclasses
for every race one
Even then highly discouraged
probably dna subclasses and subclasses for diseases
since there is bonecancer, skincancer etc so they can all be a subclass of cancer
Would each body part have a list of diseases
Each bone? Each cell? How specific do we go
each atom?
Are diseases ever that specific
i mean, it all starts somewhere
what if one atom just explodes and thats the cause of the others to have a disease
maybe they just feel grief and thats how cancer arises
Abstract Human Factory that utilises a builder. There ya go
done
Then each sub-type can implement a builder interface and boom
infinite posibiltiies
ez
But imo if we were to design the human race in code, its defo written in fucking VBA
I mean at some point if we have the processing power we will run simulations of the world and make slight changes to see what would have changed if x did not happen
It isn't unlikely we are already in one of those simulations to be fair
Just like people build computers on a computer in minecraft
wHaT wOuLdVe HaPpEnD iF hItLeR's BeEn KiLlEd
if he got into art school
Nope, you have not accounted for the quantum effect
Some stuff you simply cant predict
due to atoms going "lol fuck you no"
Damn that would be one hell of a builder
Ah sub contract the work to amazon like all good developers
Well that's the most interesting part. If they really behave "randomly" you would add randomness to your simulation
i doubt we would construct them ourselfs
gpt 12.5 will do that for us
Bro people have lava lamps in internet security centres because computers cant actually create real randoness
Human.builder().hairColor(BROWN).eyeColor(GREEN).socialSkill(0)
Boy this might take a while
Those constants donβt really work
Should have done rgb
you can still have a lava lamp or a thermometer that measures 30 digits after comma for your random but that doesn't change that you would use randoms for those random events. Although it isn't unlikely that atoms behave deterministic and we just don't fully understand it yet
That we do agree on.
My bet is that there is actually a medium for light.
But it isnt a medium for light. Its a medium for energy. And the reason we keep reading the speed of light in a vacum as constant is because erm.... the clock we use to measure the time is also effected by the medium?
And a similiar thing happens when we try to measure velocity / position as... yeah... the same subtle stuff that effects the electrons we are measuring, also effects the equipment we are measuring it with...
Does sure sound like one of those "oh how did they not realise" things that kids will say in 200 years time.
"It wasnt time slowing down the stupid shits... how can time slow down!?! It was clearly everything else that was effected and slowed"
Which is slightly supported by the fact all the really crazy as hell theories (dark energy and dark matter, various expansion theories, the wacky bits of relativity etc) only exist to explain discrepancies with the base theory of relativity... a theory that is built on the assumption the speed of light is constnat
If it wasnt constant, suddenly all those things that require really wacky cray cray bananas theories to explain away are not nessecary
If you read the documentation it usually states the replacement my man
right
I once saw a video of "why no one measured the speed of light" and that theoretically we would not know whether light moves twice the speed in one direction and instantly to the other direction.
It somewhat confused me.
Sure electricity also moves with the speed of light and therefore we can't simply press a button, store when it was pressed and then check when light arrived at our outer time measuring devices. But couldn't we use something we exactly know the speed of? Like sound?
When I know that 5 seconds after the sound gets there (and I can subtract the time the sound travelled since I know and can measure the speed) the light will turn on... Can't I make an exact measurement?
Entropy looks at fate and laughs
The universe is one giant energy chaos goblin
And we are just latching on for the ride
Plus fate is something to be fought tooth n nail.
"But suppose you throw a coin enough times... suppose one day, it lands on its edge."
Always aim for the edge lads
Honestly if we already live in a simulation it's probably government code and therefore messy as fuck
Probably those black holes aren't features but are instead bugs
black holes are just servers that crashed
Idk if this is a simulation things are still holding up way too well
looks like they lost access since they never reboot :*(
The simulation could crash regularly, we'd never know
Right but what about non crashing bugs
they could even load backups and go back to the 18th century and you would not notice
Like I should have seen the windows blue screen replace the entire sky at least a few times
what if cancer is a bug? How do we know it's a bug? We strive to find a scientific explanation
Bugs like the duck billed platypus? π
uses some attributes to manage this thing which i don't understand, what is attribute?
Attributes are things that modify various stats about an entity
For example, the max health attribute modifies max health
entity.getAttribute(Attribute.blah).setBaseValue is the easiest way
?bing
Bing your question before asking it:
https://www.bing.com/
?jd-s
?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.
Is there a way to change the title of a menu without reopening it?
Hey that's my pr :F finally someone who'll use it
I thought maybe it was just me :P. Animated titles go brrrrr
if(!player.getPersistentDataContainer().has(playerrand))
why is this argument causing problems, the namespacedkey is defined above?
you have to specify data type
what kind of problems first of all
i alr did that before and datatype didnt to anything besides cause errors
"errors"
Caused by: java.lang.NoSuchMethodError: 'boolean org.bukkit.persistence.PersistentDataContainer.has(org.bukkit.NamespacedKey)'
correct
you didn't specify a datatype
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
that doesn't exist
if(!player.getPersistentDataContainer().has(playerrand, PersistentDataType.STRING))
is this what you mean?
yes
wait i will send the error
there is no error, but there is also no nbt data on the player
you know what, the error was so embarraslingly obvious, that i will go sleep now. (its 6 am for me)
thank you for the help tho, you lead me to the right path
cya
it happens to us all, take care
how i can do if i execute a command , execute an animation from file ( .bbmodel ) and run the animation for the player?
Youβll need to implement a model engine
Or use a public one like AquaticModelEngine
ty
Right now im comparing titles and I dont store a list of inventories
but there isnt a way to get the title anymore
my goodness i developed 27+ abilites 9 bosses but dont know how to disable tnt damaging blocks
primedtnt is a entity smh
i tried π
Then idk
From which version is libraries option supported in plugin.yml?
And what if my premium plugin requires some libs I list them in plugin.yml
But as we know plugin should work without Internet acess
What is spigot is not able to get libs because user has no internet
Can I provide those libs with custom link and if yes where do user drop them in spigot folder?
what's the link for mojang mappings?
theres a website with all the classes
i cant find it
this one? https://nms.screamingsandals.org/
entityexplodeevent
chekc if entitytype is PRIMED_TNT
and clear the blocklist
itll still trigger physical stuff like knocking off item frames, pictures etc
or damaging entities
i want tnt damage PLAYER and not damaging BLOCKS
Is PersitentDataContainer not available in 1.8?
no
What's the alternative?
ye
Well, the plugin needs to run on viaversion server thats 1.8.8-1.20
So i have to develop the plugin for 1.8 right
what I was gna say xD
both I think, backwards goes to 1.14 and rewind to 1.8 I think
viarewind is only supported till 1.16
then backwards ih
can#t you do both
not sure
Worth giving a try I guess
i think iwill start with nbtapi first
You need via version + backwards, as depicted by the graph
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
Player player = e.getEntity().getPlayer();
if(e.getEntity() instanceof Player){
e.getDrops().removeIf(e.getEntity().getKiller() instanceof Player);
player.sendMessage(ChatColor.RED + "You have been Kiled by a Player and lost all your items");
}
``` how can i make so player items only if they are getting killed by a player
does it not work
if so, what the error
why are you checking if the entity. from the event is a player?
you already confirmed that when you created the player object
removeIf takes a predicate
It doesnβt take a boolean
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
Player player = e.getEntity().getPlayer();
if(e.getEntity() instanceof Player){
if(e.getEntity().getKiller() instanceof Player){
e.getDrops().remove(player.getInventory());
player.sendMessage(ChatColor.RED + "You have been Kiled by a Player and lost all your items");
}else{
}
}
}
}```
will that work ?
I don't got an ode or I would've checked
you don't need else
no point if it's empty
if you sent some thing, I'd be able to tell you...
What
What do you mean
You can make player items only if they are killed by a player
Yeah that doesnβt make sense
ik
I read Code an decoded
if a play kills the player
he wants to remove the dropw
phone problems π¦
so this is alright ?
how can i cancel vehicles being pushed by explosions?
its not working : (
i want players to lose items only when they die from players and no natrual death but i think ii figured it out
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
Player player = e.getEntity().getPlayer();
if(e.getEntity() instanceof Player){
if(e.getEntity().getKiller() instanceof Player){
e.setKeepInventory(false);
player.sendMessage(ChatColor.RED + "You have been Kiled by a Player and lost all your items");
}else{
e.setKeepInventory(true);
}
}
}
}```
nvm not working :/
nvm iam so dumb
didnt registered the event
let me do that real quick
and it works now : )
does anyone know a simple way to send a string of text to a discord channel with a bot
- in theory all you need is the string, channelID, and bot token, best way to do this without a million libraries and so on?
Feels like you'd get a better/faster response in some discord bot dev related server.
will give that a try, i did before but almost everyone wasnt actually helpful, just insufferable and trying to show off how much they knew
u can probably send a POST request to the channel endpoint
hmmm i dont know too much about this sorry
its easy?
u would send a request to like
https://discord.com/api/v10/channels/<CHANNEL_ID>/messages
with at least the header
Authorization: <BOT_TOKEN>
the POST body would be something like
{
"content": "<MESSAGE>"
}```
how do you format the header, ill havea look at this now
if ur doing it in plain old java with HttpURLConnection, .setRequestProperty("Authorization", "BOT_TOKEN"); iirc
it might be setRequestHeader, setRequestProperty might actually be part of JavaScripts XMLHttpRequest, i mix them up in my head a lot π
how to check if a blaze damaged player with fireball
I believe if you're on java 9+ you can also use the new http stuff
how so ?
ah yeah, that built in HttpClient goes hard
i still primarily target java 8 so i never get to use it lol
try Bearer <BOT_TOKEN> instead of just <BOT_TOKEN>
URL url = new URL("https://discord.com/api/v10/channels/1126426139678744666/messages"); // Replace this with the actual API endpoint
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "TOKEN-HERE");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
// Construct the JSON payload
String jsonPayload = "{\"message\":\"" + message + "\",\"recipient\":\"" + recipient + "\"}";
// Write the JSON payload to the request body
try (DataOutputStream out = new DataOutputStream(con.getOutputStream())) {
out.write(jsonPayload.getBytes(StandardCharsets.UTF_8));
}``` authorisation incorrect
is there a way to make an item completely useless
for eg, red dye wouldnt be able to be put on a sheep or even do the animation and you cant drink or put a mundane potion in a brewing stand
or like a carrot on a stick wouldnt effect pigs
like just a dummy item
You would probably have to listen to a lot of events to check that
what could i do though to make a dummy item
unfortunatly this did not work so im stumped
but the good thing is, if i change the link i get the not found 404, so somethings right
I do not believe you can entirely cancel the animations
At best you'd get a part of it and the server would cancel it midway
I may not know entirely what you're trying to do but I suggest:
Use a resourcepack and
Retexture/remodel commandblocks to anything you want
Command blocks can not do anything in survival, they work like stick
They have no recipes either
Are you inputting the correct token ?
yes i just regenerated it now and made sure
i tried the new one one its own, with Bot in front and also Bearer
how would i do an early return if i'm already returning? lol
return@return is not valid either
override fun getAction(): (Player, Player) -> Unit {
return { killer, victim ->
if (victim.getKitPVPLevel(plugin) < 10) return
// other stuff
}
}
Think what you would return in the "else" statement
since you would need one for sure
wdym "else" statement? this is a guard clause, a singular if-statement, not an if-else
What do you expect to be returned to function if you do early return there
You can just say, huh, don't return anything in this case
well, i'm returning an "action", and i want this action to not go through if the guard clause failed
i could theoretically extract this into
fun executeAction(player: Killer, player: Victim)
then it'd work yeah
Nvm, my bad, you are trying to early return in returning function
I think in that case function have to be inlined, but not sure
yeah i think this approach is cleaner
I agree
π
Hi is possible to scan all the chunks and check if there are a matching block and take the coordinate?
sure, finding and loading these chunks will be up to you however
obviously will not be cheap whatsoever
Hello, i am trying to use NBTAPI. I initially set a value of "uses", it's just an integer. But when i try to update that integer, it doesn't override. anyone have an idea what i might be doing wrong?
private void updateWand(Player p, ItemStack itemStack, int uses) {
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName(formatUses(name, uses));
meta.setLore(formatLore(lore, uses));
//update the value
NBT.modify(itemStack, nbt -> {
nbt.setInteger(WAND_IDENTIFIER_USES, uses);
MessageSenderUtil.sendMessage(p, "set uses to " + uses);
});
MessageSenderUtil.sendMessage(p, formatUses(name, uses));
//this one says the just updated value didnt update
MessageSenderUtil.sendMessage(p, NBT.get(itemStack, nbt -> nbt.getInteger(WAND_IDENTIFIER_USES).toString()));
itemStack.setItemMeta(meta);
p.getInventory().setItemInHand(itemStack);
}
You need to set the meta before you modify the nbt
something, to get if the block is inside that chunk and get coordinate?
event.getChunk().contains() can pick only blockdata, i made it!
Yes that worked, thank you
Y no pdc
1.8 π¦
i have a spigot fork and im not sure how to build it
would anyone guide me in the right direction
Does it have a pom.xml file?
yeah
Then run βmvn installβ
Your Java version might be too new
the build is working rn i just changed the jdk version
yeah it built, thanks @chrome beacon
you would have rather jumped in your bathtub xD
yeah its a 1.7 server but my jdk was set to 1.17
hey guys, if I have on class that uses nms and has to work in different version, how would I do that?
ig reflection and/or abstraction
uh
you need to tell us what nms it uses to get a proper answer
I think I should rather not do that
uh ok. odd response, then we can;t give a full answer
I don't wanna do the project I was working on anymore lol
where can i find a protocolib version that supports 1.7 and 1.8
i had one a while ago but idh it anymore
and i cant find it anymore
look on bukkit
ViaRewind and ViaBackwards
I have a custom item as a stick, how do i prevent that stick from ever stacking, like an axe?
add a pdc tag
like a UUID?
well the thing is the stick is a kind of wand, i now have 2 tags one for its uses and one for the wand id. But if i have 2 wands they can still stack
yeah but if i like copy the item with middle click they will still be able to stack
don;t use creative
can i do my objects with static ?
i don't wanna use getters
wdym for constant ?
yes
btw has any rule like this for static methods ?
static utility methods shoudl be stateless
well what if the plugin user wants to sell a wand in for example villager shop
you can cancel middle click
it's inventoryclickevent
sry @eternal oxide but can u explain me ? "wdym" for stateless
i'm talking about villager shop now, i want to fix the root of the problem.
will be void ?
doesn;t need initializing and nothing passed to the class or changing.
like canceling middle click is treating the symptom instead of the root problem
that's called being a spigot developer bro
well if someone were to use villager shops how would i then treat the symptom
Does middle click have some application outside creative that I'm unaware of?
No i mean like if a villager would sell an wand, it would always sell the same wand, which causes it to stack.
when shift Rightclicking a block with nbt data
will copy it
you
yes
why tf this autocorrect screwing me ovet
i don't think you understand, if a villager sells an item, an admin would have set that item. So if it gets sold it would always be the same item with the same tags
I just need to be able to set a max stack size somehow
After changing version to 1.21.1, ClassNotFoundException: net.minecraft.nbt.Tag appears. How can i solve this
rly, I saw the function on the api
stack sizes are based on Material and not changeable
seemingly didn't compile with the net. minecraft ig
manually change the output of the trade
in some event probably
reobfuscate your jar
can i use spring boot for plugin development?
I do believe so, I have seen it once
i think it can greatly ease a lot of things
?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 would rather use some http library then tossing whole framework in, but you sure can (might have some problem with dynamicly loading dependencies due to spigot classloader, but not sure)
im used to autowire and other things, i think without spring-web it should be fine
Im trying to detect if a player is in a cave, but after a lot of tries, im still not able to archieve it?, do someone know how can i do it?
already doing that , but i want to differenciate houses and caves
Hmm
the easier way, would be that cave_air works, but for some reason is not working :(
Well you could check if they are below the worldgen surface
if that doesn't include trees , it might work
It shouldnβt
how do i get worldgen surface?
Good evening, I am looking for a plugin developer for Spigot, I need you to write me an addition to another plugin, if you want to discuss this, you can write me in private messages, we will discuss the price, terms, and I will explain in detail what I specifically need from you
Check if their Y is below https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getHighestBlockAt(int,int,org.bukkit.HeightMap) using HeightMap.WORLD_SURFACE_WG
?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/
does java reopen a file opened in the program?
I'm not looking for a job, I'm looking for performers
What
you find both on that site
still, detects trees
I suppose you could combine it with the no leaves heightmap
2 ifs ?
Why does spigot respond with an 403 error (Forbidden) when the request is sent from the server? (I'm talking about the download url, works when I type it in)
Yeah you can check that they are below both
sent from the server?
HeightMap.MOTION_BLOCKING_NO_LEAVES still detects leaves .-.
your code sending the request must support redirects
what code are you using to perform the request?
public static boolean isUnderWorldGenBlockPlayer(Player player){
if(player.getLocation().getWorld().getHighestBlockYAt(player.getLocation(), HeightMap.WORLD_SURFACE_WG) <= player.getLocation().getY() ) {
if(player.getLocation().getWorld().getHighestBlockYAt(player.getLocation(), HeightMap.MOTION_BLOCKING_NO_LEAVES) <= player.getLocation().getY() ) {
return false;
}
}
return true;
}
int latestVer = getLatestDownloadVersionID();
URL url = new URL("https://www.spigotmc.org/resources/alixsystem.109144/download?version=" + latestVer);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
even after adding connection.setInstanceFollowRedirects(true); it does not work
connection.setInstanceFollowRedirects(true);
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
connection.setDoOutput(false);```
spigot requres you are logged in to download
log out and try https://www.spigotmc.org/resources/alixsystem.109144/download?version=2.4.5
it sends you to a login page
No, it directly tells you that you don't have permissions
allows you to immediately download
I don't check the version, I check the version id
the one which is necessary for downloading
then you must be using the wrong id when you try from code
it just runs a cloudflare check
I'm using the correct id, that's why it's confusing
Caused by: java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.spigotmc.org/resources/alixsystem.109144/download?version=505209
The id is clearly correct, but I think it might be because of the CloudFlare human check
Or maybe you are using a very old SSL version
Try changing the user agent and configuring your HttpConnection to use a recent version of TLS
how can I check if that's the case?
I don't remember, you can google it anyway
but isn't the cloudflare check the problem?
It might, but also it might be due because cloudflare wants you to have a recent SSL or TLS version
I'm not sure tho
But you don't lose anything (but time) by trying
Also set the user agent to a "more realistic" than the java one
By default Java User-Agent is Java/<version> or smth like that
I don't think that affects anyway, but try it
How would enabling tls (?) fix 403 returned from server
Idk, it's just a possibility, maybe the server is just denying the request because the connection is under a old SSL version
Or is there an specific HTTP error code for that?
Why are you delaying an scheduled task?
It would be handshake failure
so it runs after 15 ticks, then 15 ticks periodically
Why don't make it run each 30 ticks?
its
15 ticks delay -> task -> 15 tick period -> task -> 15 tick period
So it won't run as soon as the scheduler starts
cant say, thats how i would do it but others would say to store it differently
I don't think the problem is on the scheduler, maybe you are calling the upper method (which contains the scheduler) twice at some point?
Is it on the plugin's onEnable?
if its a private plugin just storing b64 is fine, if i was public id say some from of relational db that stores an int id to an id in another table with all the relative stack info
Maybe the problem is on "awardCoins" method, could we see it?
Might be dump question, but where are you giving 10 gold, I only see 100
It's 10D
10D
Lmao
add a sysout with a system get millis and see the different
πΏ
Should buy glasses
As its running every 15 ticks, and you are rounding playtime to int by dividing by 20,it may 2 times be same number
That's why maths are important
me too
π
hi so im currently making my own fork of spigot and i wanted to add my own commands so im trying to use MinecraftServer.getServer().server.getCommandMap() but i get error when i build The import net.minecraft.server.MinecraftServer cannot be resolved [21] MinecraftServer cannot be resolved
Hello, I get this error when I mvn package my multi-module project after adding bStats :re [INFO] --- maven-shade-plugin:3.2.4:shade (default) @ alot --- [INFO] Including fr.paulem.paperapi:paperapi:jar:1.0-SNAPSHOT in the shaded jar. [INFO] Including fr.paulem.api:api:jar:1.0-SNAPSHOT in the shaded jar. [INFO] Including org.bstats:bstats-bukkit:jar:3.0.2 in the shaded jar. [INFO] Including org.bstats:bstats-base:jar:3.0.2 in the shaded jar. Unsupported class file major version 61Build configuration :xml <build> <directory>../target</directory> <!-- Build it one level up, because it is the one we care about --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <configuration> <relocations> <relocation> <pattern>org.bstats</pattern> <!-- Replace this with your package! --> <shadedPattern>fr.paulem</shadedPattern> </relocation> </relocations> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build>My project is on Java 17
It means Java 17 (major version 61) compiled the class file, and if we try to run the class file under Java 16 and below environment, and we will hit Unsupported class file major version 61.
Are you running maven with the correct java version?
Yes
Update to newer shade plugin
Like 3.5
public boolean hasLore(ItemStack itemstack) {
if(itemstack.getItemMeta().getLore().size() != 0) { //Here is my error
return true;
}
else return false;
}
Hello, i dont understand why i have a NullPointerException when the item check has no lore
I'll try
reading docs would help alot
It's working thanks π
"if(itemstack.getItemMeta().getLore() != null)" sounds better, thx
oh damn you right, i create this for nothing
sry
bump
That's not an answer...
It is either yes or no
you can't "kinda depend"
who will help save the class file?
Hello, should I use Bukkit.method or Server.method ?
ok yes i depend
Same thing. Its just static or instanced access
okay thanks
can i save yml async?
snakeyaml is not thread safe
what should i do, it has extereme usage
but yes saving shoudl be async if you can
and the data im saving is not ok for saving on a db
you will have to sync all your saving so you don;t read and write at teh same time
i save it every 6000 ticks
should i save it when modified
?
what data?
actually its ok to save on db
but i dont have time to do it
its something like this
username:
challenge1: 2
challenge2: 3
....
when they get a kill or something
how to save handler??
I wouldn't use yml as a database
i know it should have been with a db, but i dont have time to fix it
store it in PDC and let teh server handle saving
I think you might do
the data is in the file
migration tool
i cant move it to pdc
data is specific to a player so use PDC
Just make a basic read here and save there
is pdc fast enough?
Thanks
Hello, how can I check if the clicked inventory is a the player inventory or the opened inventory in InventoryClickEvent ?
i assume if (event.getInventory() == event.getPlayer().getInventory()) or smth
okay thanks
okay
hello, I'm coding a plugin and I need every player inside a world to hear a sound
I don't want to use a for loop iterating through the players, because if they move, the sound stays behind them, I want them to hear the sound like if it was a vanilla thunder sound
is the sound in a resource pack?
no, it's a vanilla minecraft sound
using playSound on the Player should make it follow the player
only mono sounds will follow
if it's stereo it will play in place
with this code, I can't hear the sound that is played when my friend dies
I only hear it if I get close to him
you are playing it on a location not teh player
oh, that's right, I didn't know I could change the location argument for a player argument
is there a way to disable specific command aliases if another plugin is loaded?
I am making an econ plugin (woah totally original right?! π) and I have under my balance commands alias /wallet & /balance but I want to make those alias usages disappear if essentials is loaded so that my plugin doesn't override it
Iirc load before the other plugin, might be the other way round and delay ur cmd registration a tick
well the command's main usage is /abalance but I have /balance as an alias. I want to disable that alias if essentials is loaded
in my plugin.yml file my command is ordered set like this.
commands:
abalance:
description: view the balance of yourself or others
usage: /abalance [player]
permission: argyle_econ.balance
aliases:
- balance
- abal
- bal
- wallet
I am wanting to remove balance, bal, and wallet if essentials is loaded
in onEnable check if Essentials is there, use getCommand("abalance"), then setAliases as you need before setExecutor
oh I didn't realize there was a method for setting aliases at runtime. That is exactly what I needed then. Thank you
can somebody help me come up with a formula that would graph roughly like this?
i'm trying to make it so that levelling up would increase your bonus more and more, but at a certain point the bonus increase would become lower and lower
e.g.
xp 30 -> 40 would add a bonus of 5
xp 40 -> 50 would add a bonus of 7
(peaks at 50)
xp 50 -> 60 would add a bonus of 6
xp 60 -> 70 would add a bonus of 5
etc
I'm making a UHC plugin and there are 2 worlds in my server, "world" and "uhc"
after entering the nether from the uhc world and then leaving it, a portal is generated in "world"
what can I do so nether portals spawn inside my uhc world only?
oh right brotherx you can look at hypixel's counting levels formula
I'd ask chatGPT or create a linear equations system
hm
Providing instructional and assessment tasks, lesson plans, and other resources for teachers, assessment writers, and curriculum developers since 2011.
oh btw i think i sketched incorrectly
one sec
i think this is more like it
because before gradually decreasing it gradually increases
that's a good resource, ty
though i think i need a slightly different one to approach this
a system of equations sounds nice tbh, just see whether the xp is beyond threshold and use an applicable equation
i'll probably do that, but now i'm curious whether it's possible with one equation
i don't think it's exactly what i need, because their xp requirement does not decrease really
You could sum up two functions to create that
yep, also thinking that
well it increases
you need more xp to obtain a new level
you can somehow reverse it ig
perhaps yeah
but i think i'll stick to the approach of 2 equations
that'll be much easier to figure out
thx everyone π
smh, running build tools with --compile NONE doesn't apply the spigot patches. Why is that behind the "compile" flag?
but I don't want to cancel it, I want the portal to spawn inside the "uhc" world, and not inside "world"
you'd have to cancel the portal in world and create your own in uhc
yeah well just for example if you want a formula where f(30) = 5, f(40) = 7, f(50) = 6 and f(60) = 5 then it'd be f(x) = (-x^3 + 180x^2 - 7100x + 90000) / 4200.
You can basically just tell chatgpt which results you want to for which input and it'll throw it into one function lol
but how can I find the optimal location to place the portal? I want it to have the vanilla behavior
i remember doing this manually in school but I dont remember how it works anymore lol
alright, i'll try to think of my thresholds
yeah i haven't studied cubic yet, i just know how it looks like
been like 12 years since I had to do it by hand lol
can't I disable nether portal spawning inside "world" or smth like that, so they can only spawn inside "uhc"?
when it attempts to create it in the main world you can get teh location
what about the y coordinate? it's not the same between worlds
same bro
select the highest at those x,z
there's a method in World i believe
World#getHighestBlockAt(int x, int z)
thanks, I'll try to do that and see if it works
I wrote this code, but it doesn't seem to work... am I doing something wrong?
your ide literally yelling at you
listen to your IDE
you can not compare strings with != or ==
?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.
use equals or equalsIgnoreCase
I know I should use that, but comparing strings like that in other parts of my code has worked just fine... I'll try that anyways
that you're not supposed to compare string using == is one of the first things your learn in every java tutorial
it might randomly work sometimes if the strings are cached by the JVM
always use equals to compare objects unless you want to check for their identity
I think it was that, now it seems to work, thanks :)
ent.setMaxHealth(); we can set the max health to anything we want right like there no limit right
assuming that "ent" is a living entity, it can be any positive double
we cant go any higher ?
I'm using a custom class loader, and for some reason a clearly existing class (shows up in the loaded classes list and visible when using zip explorer) throws ClassNotFoundException. Does anyone know maybe know why?
you can, after raising the cap in spigot.yml
we can't
Also by minecraft
with default config*
Minecraft limits the max health an entity can have
spigot overwrites it
You sure?
hold on
Because in vanilla minecraft, it's not even possible without a mod
And we all know mod modifies client-side, and spigot is server-side
where i can find that file π
what is bro cooking π₯
help to convert the java file "handler" to a class file
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
Player player =(Player) commandSender;
if(args.length == 0){
player.sendMessage(ChatColor.RED + "You didnt Specify the boss!");
} else if (args = ) {
}
return true;
}``` how can i set args to a STring that a player will type
like /boss (Boss_Name)
args[0]
String boss = args[0]
switch (boss) {
...
a
i'm fucking tired of trying to feed this ai
feed it chat gpt
i cannot, it's unavailable in russia
vpn
requires a registration with a phone number
i already constantly use a vpn because copilot left russia
would my cases be a string
anyway, maybe you know a way to find a function when f(x) is known for multiple x?
i can just calculate it myself if i know the way
like case: (boss_name) ??
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.
its either a string and switch it or you have a way to convert the string to a boss object
ig i will go with string
if(args.length == 0){
player.sendMessage(ChatColor.RED + "You didnt Specify the boss!");
}else{
switch (boss){
case : "Ancient"
}``` ?
you need a string variable or pass in args[0]
.
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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
ik i have to break it
epic, do you have any idea? or at least the google prompt for this lol
and stuff
i havent done shit with that kinda of math stuff yet lol
unfortunate π
or use lambda switch cases
Can you elaborate a bit, I'm not sure I really understand your problem
well, suppose I know f(1), f(2) and f(5). I want to find f(x) that would conform to all of them
switch (boss){
case Ancient:
"ancient"
oh
?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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
for the third time
so it will be equals to args right
like /boss Ancient
and it will run the case right ?
a string cannot be equal to an array
are you gonna keep ignoring the learn java messages?
bruh
but the boss is equals to args
I mean it kinda can
It kinda can
how lol
ffs
Char array π plus a custom equal method
custom equal method
Thatβs why I said kinda
Binary representation
Ik I am just messing around
I feel like there would somehow be a niche way to make an array equal a string tho
Idk how
Reflection with internal Java classes
it may be equal to entry in that array, not the entire array though
yes
After a lot of alpha-wolframing & chat-sonicing, I managed to calculate the formula. It's
-0.000000324442853307079 * x^3 + 0.0002468881202549544258 * x^2 + 0.00864452130783789075246 * x + 0.991108915014155502310563 π
it's kinda stupid lol
wtf XD
yeah..
how can i teleport player to middle of the chunk that he is standing on?
lmao i really think there is no mathematical way of doing it other then guessing
okay im having an issue with #isAnnotationPresent(annotation); which it present but returns false?:
private static @NotNull Field[] getAnnotatedFields(Class<?> clazz) {
List<Field> fields = new ArrayList<>();
for (Field field : clazz.getDeclaredFields()) {
if (field.isAnnotationPresent(ConfigValue.class)) {
Bukkit.getLogger().info("Inspecting field: " + field.getName() + " in class: " + clazz.getName() + " in package: " + clazz.getPackage().getName());
fields.add(field);
Bukkit.getLogger().info("Found field: " + field.getName());
}
}
return fields.toArray(new Field[0]);
}```
then the class:
@Config
public class Testing implements ConfigClass {
@ConfigValue("test-testing")
@Comments({"line 1 of comment", "line 2 of comment"})
private final String test = "test";
@ConfigValue("testing-value")
private final String testing = "ew";
}```
have you looked at jishlib
ask @young knoll if you have any questions
well shouldnt the annotation be present?
no clue
never touched annotations
alr, thanks
there kinda was
i didn't read anything except for the eq system haha
now i have a comical function
/**
* Calculates the bonus for this level.
*/
fun Int.calculateBonusFromLevel(): Double {
return (
if (this <= 200) {
(- 0.000000324442853307079 * this.toDouble().pow(3)
+ 2.4688812025495444E-4 * this.toDouble().pow(2)
+ 0.008644521307837891 * this
+ 0.9911089150141555)
} else (
- 0.0000125 * this.toDouble().pow(2)
+ 0.01125 * this
+ 8.25)
).roundTo(3)
}
when doing paginated Inventories do you guys open a new inventory? Or just replace the contents of the one displayed
replace content
Replace content
otherwise your cursor tps to the middle and its annoying
what are you doing 
writing a library
why do you need unsafe then
because a safe library is no fun
add more
sukketto deez nutz
dw I will have no shortage of NMS
does preconditions not have a nonull
this is similar to the code I contributed to spigot so I just copied the preconditions
it does though
didn't know when I wrote it though
ah
im wanting to write an updated inv handler
that adds some paginated inv pre sets
yeah
hi optic
thx
How hard would it be to make a "proper" physics / destruction engine via spigot?
e.g something like: https://www.youtube.com/watch?v=GJU_P3tnf3A
Looping through every block would work, but the issue there is correct timing for every block as well as poor performance.
Creating chunks of blocks would also work, but the issue there is creating them properly and correctly timing them
sup nerd
pretty hard i guess lol
just like any physics/destr engine tbf
yo Optic you know anything about annotations?
Yea, but minecraft (and therefore spigot) has things like falling blocks.
The issue is uh... making a purely server-side not shit one
yeah but you'd still need to see what blocks to destroy, drop, their velocity including direction, etc
it's still physics
falling blocks just removes one of the middlemen
wait for @young knoll to look at this discord pings
Yea, true. Given how MC is performance is the main issue. It's not really meant to contain an entire physics engine kek
alr
i mean nothing stops you from trying π
GOT IT!
if (sender instanceof Player player) {
double x = player.getLocation().getChunk().getX() * 16;
double z = player.getLocation().getChunk().getZ() * 16;
if (player.getLocation().getX() < 0) {
x = x + 8.5;
} else {
x = x - 8.5;
}
if (player.getLocation().getZ() < 0) {
z = z - 8.5;
} else {
z = z + 8.5;
}
player.teleport(new Location(player.getLocation().getWorld(), x, 100, z, 180, 0));
}
Which is why I asked here KEKW
you can make a server core that has a lot of things stripped out to compensate for the performance destruction
but then well probably the only plugin available for that core would be your engine lol
nice π
I could but I'd prefer base spigot kek
in that case you can just start and see whether the performance gets too bad for it to be reasonable to continue
No need to check location x/z, you shoudl alwasy +8
as the chunk x/z will always be bottom left
Hardcoded animations would be much more performant, but I'd want dynamic
dynamic as in?
most physics engines, e.g. the linked video
i just don't exactly understand what you mean by dynamic. the animation, velocities, etc. will be calculated depending on the context, no?
thats for creating something not public use just teleporting and copying chunk so only personal use, so if it works then you dont touch it. am i wrong?
Correct, instead of the animation, velocities, etc being a single hardcoded animation i.e. the same no matter what, it would instead be dynamic e.g. breaking blocks manually give different values therefore different physics (and therefore destruction) compared to say TNT
ah, well that doesn't seem harder to implement than the physics engine itself haha
The hardpart is not making the server & client commit die
allocate a shit ton of ram haha
but in reality i guess just try and that's it
if the performance is completely atrocious you'll know to stop
@rough drift you like physics, how possible is such an idea w/o ya know, killing everything
Oh god did someone say animations
:p
yes.
e.g. like certain games which play animations when destroying walls or some shit instead of actually doing physics calculations
