#help-development
1 messages · Page 1985 of 1
in what world would you pass a uuid as a string 👀
Bukkit.getPlayerExact(args[0]));
Right, so it's a Player
by binary incompatible do you mean only when changing the subclasses sealed under it? or recompiling the class in general
well if it has to be saved to a file for example
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/BanList.html#addBan(java.lang.String,java.lang.String,java.util.Date,java.lang.String)
This requires a String as the first argument, but you are passing a Player
Seeing the issue? ;p
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
probably that the JVM throws an error when a class that implements a given interface is loaded
addBan(target, args[1], args[2])
This is your method. You are doing addBan(Player, String, String), not addBan(String, String, Date, String)
i used that one, but should not i do args
bruh for learn, learn java
yea, but I meant to understand in what case that happens
what
?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.
You can use args, you just have to verify they're the right type
choco explained 5 times already that a player is not a string
ok i see
and those types are,
String: target - the target of the ban
String: reason - reason for the ban, null indicates implementation default
Date: expires - date for the ban's expiration (unban), or null to imply forever
String: source - source of the ban, null indicates implementation default
Given that you're using the name ban list, the first arg should just be target.getName() instead of target
no you should learn java basics
heh
to understand what classes are
I think learning java bytecode is helping more there
Or just the basics of a stack machine to be more generous
Although, learning to read compile errors is also usefull
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
can you pls stop trolling already
those much be instances of those types
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.
okay so
- you're new
- you don't knoiw what you're doing
- you don't want to know what you're doing
- but you still want help here?
Then you will struggle a lot more because converting a string to a date is far more complicated than one might believe
i made a lot more small plugins but haven't played with ban or args before
you don't know the easiest basics of java
like the syntax
or what a class/type is
you'll have a very bad time if you don't look at any of the tutorials I linked
Picture the following
public class MyClass {
public static void hello() {
System.out.println("Hello!");
}
}```
I have a dependent that calls that method.
```java
MyClass.hello();```
Now I think to myself... well shit, that hello method should really return a boolean to let them know whether my hello was successful! So I change it
```java
public class MyClass {
public static boolean hello() {
System.out.println("Hello!");
return true;
}
}```
Dependent now breaks because while the parameters and method name are the same and despite the return value not being used, the method signature has changed. My dependent was compiled against and referring to `()V`, but at runtime it no longer exists and provides instead `()Z` because it has a boolean return now
That's a binary change in its most basic form
do you know how to code in java?
good example 🙂 ||except that your second code wouldn't compile since you don't return anything||
if I'd be choco, i'd call myself cheese instead
Ok
because cheese ise awesome
that answer wasn't directed to you
First you need to get the current date, then parse the string duration to a java.time duration, then add the java.time duration to the current date and then you can use the time in that method
lol
: /
do you know how to code in java
Parsing the string duration to a java.time duration is even more complicated because there are 10 different ways to format a duration
Yes but not that good like professional i made some small plugins before but haven't done the ban and args before, But for some reason everyone is making fun of me. Its seems like really bad community here.
its not a bad community, your asking the wrong questions
we aren't here to spoonfeed
you made plugins in java but you haven't "done args before"?
how did you call any methods?
?paste
Do you mean in the onEnable ?
ToxicMaster you have to understand we will help you with bugs, but we won't help you learn the language or the API, when there are CLEARLY really good guides and documentation online.
you have to understand that
I know that
sorry but this is a waste of time. you clearly know almost nothing about java and keep ignoring the ?learnjava links. there's no point in answering anymore
i just wanted a small answer and how to replace the think with small guide. Im not asking anything else
we are trying to help you with documentation but if your not gonna read them, it's not the community's fault
okay, small answer: pass the correct arguments to the function and it'll work
PLZ STFU with your ?learnjava. you are really annoying. I know you trying to help. But you are not
that is easier said than done
yes, blocking you now
have a nice day
@narrow stag choco has answered your question multiple times
he didn't understand it because he never learnt java and also doesn't want to
here it is again
i did it
if you learned java, then you would know what function parameters are
and the fact that your passing the wrong datatype into the function
I assume toxicmonster only has a javascript-like language background where types are converted automatically
and also the fact that your arguments are incorrect
Im having a problem with a recipe overwriting another, I am not sure why it is like that tho. https://paste.md-5.net/cuqemuduko.cs
Bye : /
dont get me started on dynamicly typed languages ;-;
ShapelessRecipes only support Materials, no ExactChoices
You have to use a ShapedRecipe
or use different materials
oh ok, thanks
I also learnt that yesterday D:
thats sad D:
we've given you the answer like 5 times what do you not understand 😂
yeah 😦 as a workaround you could listen to the ItemCraftPrepareEvent
but then you can't use the recipe book
The answer is not suited to him
he has no idea about java and also doesn't wanna learn it, there's no point in answering to him, all he wants is some copy/paste code
honestly man
just block him and move on
@narrow stag
Picture a method
public void method(String x) {}
The argument x is of type java.lang.String. If you call it with an argument of type int, for example via method(10) it will not compile, as it expect a java.lang.String
This is the issue you experience
🥣
he doesn't understand this, it was explained multiple times to him already
whatever
it's not really spoonfeeding as it does not solve his main issue directly
oh I have to add, I don't wanna make fun of people who don't know basic java. but it's also a waste of time to answer to people who do not even WANT to LEARN IT
even choco spoonfed him and he didn't know what he was doing
just wanted the answer not the logic behind it
yeah he just added "String" as parameter lol
That also was not a spoonfeed
can someone tell me whats the difference between an inventory click event and a inventory drag event?
yes
click = click
drag = click, hold down and move curser
You can distribute items by holding down your mouse button
A spoonfeed would be
"
Use target.getServer().getBanList(BasList.Type.NAME).addBan(target.getName(), args[1], Date.from(Instant.now().add(Duration.parse(args[2]))), sender.getName())
"
this is drag
if you listen to InventoryClickEvent, you also want to listen to the dragevent in 99% of cases btw
and when you're dragging items, is an inventoryclick event fired too or not?
no
only the drag event
at the beginning im pretty sure
that's why I said, you wanna listen to both
ok
nope
really?
also one thing i learned the hard way, if the player clicks anywhere on the screen with the inventory open, it triggers the event, even if they click outside of the inventory UI
Is there a way to get a player from a PrepareAnvilEvent?
and something else, in which situations can an inventory not be the top inventory?
which makes e.getClickedInventory() null
get the inventory viewers
and i guess the slot is then -1 or something?
Oh yes of course Thx!
IIRC it's 999 or -1
no, the inventory is just null
the slot will still be 999 or -1
oh right atleast im checking that :D
@EventHandler
public void inventoryClick(InventoryClickEvent e) {
if (e.getClickedInventory() == null) return;
if (e.getClickedInventory().getType() != InventoryType.ANVIL) return;
// ...
i learned this the hard way
i kept getting NPE lol
but why can you have two inventories in a view?
in what kind of situations does that happen?
the inventory, and the players inventory
for example a chest inventory
top and bottom inventory
ye i get it
yep, works now. thanks 😄
The item changes in the inventory aren't actually applied on the server until the client lets go of its button
Theoretically, for funsies, you chould hold down your mouse button on a single slot for like 10 seconds and it won't update on the server at all until you let go of your mouse button
the hot bar problem
We have this:
https://imgur.com/a/Vt66HIS
Which is pretty hard to look at, if you have a toaster as your pc...
I want to replace all of this by barriers (clientside) as soon as a player executes a specific command.
I've heard about PacketPlayOutMultiBlockChange, but how would that work?
And is this the packet which is being sent when the player enters a world?
why do my config comments get deleted after the second launch of the plugin (bungee 1.18)?
@Override
public void initialize() {
if (!Main.getInstance().getDataFolder().exists()) Main.getInstance().getDataFolder().mkdir();
configFile = new File(Main.getInstance().getDataFolder(), "config.yml");
langFile = new File(Main.getInstance().getDataFolder(), "lang.yml");
dataFile = new File(Main.getInstance().getDataFolder(), "data.yml");
if (!configFile.exists()) {
try {
InputStream in = Main.getInstance().getResourceAsStream(configFile.getName());
Files.copy(in, configFile.toPath());
} catch (IOException e) {
e.printStackTrace();
}
}
if(!langFile.exists()) {
try {
InputStream in = Main.getInstance().getResourceAsStream(langFile.getName());
Files.copy(in, langFile.toPath());
} catch (IOException e) {
e.printStackTrace();
}
}
if(!dataFile.exists()) {
try {
InputStream in = Main.getInstance().getResourceAsStream(dataFile.getName());
Files.copy(in, dataFile.toPath());
} catch (IOException e) {
e.printStackTrace();
}
}
loadConfigFiles();
}
public void loadConfigFiles() {
try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
langConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(langFile);
dataConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(dataFile);
} catch (IOException e) {
e.printStackTrace();
}
}
eh, ```java
e.getInventory().getViewers().forEach(HumanEntity::closeInventory);
That doesn't work correctly.
It gives an error and it does not return the items correctly (You will see the item at first but when you open the anvil again one of the items is gone.)
Err: https://pastebin.com/Sh6hTQTE
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
choco do u know how to use this? the documentation on UnsafeValues is pretty scarce
it just says String arguments
Stringified NBT. So "Enchantments:[{}]" should suffice
Oh so it just adds nbt to it
Yeah
alright
Is this the right way of closing the anvil inv in a PrepareAnvilEvent?
tryitandsee
:)
...
It doesn't work for me, it It gives this error and the items eventually go away.
Hi, how can i get an Inventory from a yaml configuration? I tried saving the inventory and it works (as you can see from the file)
I'm using 1.12.2 btw
you need to serialize the inventory
basically convert the inventory to a string without losing any inventory data
could you please help me doing that? i have no idea of how to do it
for starters
dont store your inventory in a YAML file
use sql
because sql can actually store binary objects
yes thats the issue
saving userProfile.getInventory() converts it to the name of the class in memory
so now
its saved as !!org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryPlayer
which doesnt save any inventory information
it just saved the class name
but there are some values
what values?
the only values i see is !!org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryPlayer
aren't this doing that?
ah sorry i didnt see that one sec
java doesn't know how to convert the yaml inventory into a java inventory object
you need to serialize the inventory in a way where java can recognize the format
and convert it back into an inventory
uhm
you're gonna need to learn how to serialize objects in java
before storing something this complicated
what do you need to store this inventory for anyways?
Thats not the problem but anyways i want to have multiple profiles for players, and each profile has Inventories. Where would i store this inventories? I thought of a yml file
sql is recommended
if you dont want to use an sql server
use sqlite
yaml is very bad at storing big things like inventories
and plus, yaml is for configuration rather then storing things
Ty btw
i can link you some tutorials on sqlite if you need
kk one sec
sender.sendMessage(ChatColor.RED + String.valueOf(player.getInventory().getItem(2)));
sender.sendMessage(ChatColor.BLUE + String.valueOf(player.getOpenInventory().getItem(38)));
ah yes
one null one air itemstack
what's more interesting is that inventoryView.getItem() uses inventory.getItem() internally
could just save the hashmap itself
but somehows returns null
are you talking to me?
indirectly, since I am playing with yaml myself
https://www.sqlitetutorial.net/sqlite-java/sqlite-jdbc-driver/
https://www.spigotmc.org/wiki/itemstack-serialization/
https://www.sqlite.org/docs.html
the first one teaches you how to use the jdbc driver, which can interface with the sqlite3 language
the second one teaches you how to convert itemstacks to strings (serializing)
the third is just sqlite3 documentation if you need help with sending queries and etc
ty
yw, gl with ur plugin
that's current implementation of api
i've decompiled it
that's how api currently works
when is this run
that's not undefined behaviour i've found it how it works
im pretty sure this happens because a blank slot in the OPEN inventory will be air
so the visual inventory
has air
but the inventory in memory
will have null
CraftInventory.class
@Override
public ItemStack getItem(int index) {
net.minecraft.world.item.ItemStack item = this.getInventory().getItem(index);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
CraftInventoryView.class
@Override
public ItemStack getItem(int slot) {
if (slot < 0) {
return null;
}
return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem());
}
the slot will be air, just to make it render as nothing
that's explicitly made up
both return the same except that the getinventory check if itemstack is empty
What would you use as a Alternative to BlockData in 1.8
magic values? nbt tags?
magic values yea
im pretty sure getOpenInventory was meant to be called when the player has to see an inventory visually
so spigot sends an air item
so the client can render it as air
and getInventory was meant for the api
i know but getOpenInventory was meant for the visual inventory
so it converts nulls to airs
it grabs NMS itemstacks from internal Container object
why wouldnt it for inventoryviews
thats my logic anyways
idfk lol
ask like md5 or something
yoo does sqlite jdbc bundle with spigotapi now?!?!
spigot server but yes
finally
really?
Yea
because you inject an instance of a class from your plugins classloader into the server
if your plugin, for whatever reason, disables the server will not enjoy that
not to even talk about reloading
sure but isn't the same thing true for almost everything else? like adding an API?
e.g. ChestSortAPI, ItemsadderAPI, ...
WorldGuardAPI
wat
well
if some plugin calls a method from WorldGuardAPI it also breaks other plugins if WorldGuard now gets disabled
and if some plugin does InventoryClickEvent.getHolder() it returns an inventoryholder, and not e.g. my custom object
well of course it returns my custom object but
it won't break anything
Well the plugins don't care
the server does
all of the sudden it holds onto an instance of your class loader
if you reload (e.g. close and reopen) you now have dangling instances flying around
I've never seen custom inventoryholders break anything and I even do /reload very often to test out things
hi ! i would learn how work this plugin :https://www.spigotmc.org/resources/✅-api-playernpc-✅-1-17-1-18-1.93625/ , can u help me pls ?
what's your question exactly?
tl;dr: it creates entities (NMS) and then sends packets to players to let them know this entity exists
i dont undestand for create npc and that they write in the chat ( im fr i have difficulty to speake english )
you want to know how you can use this API/plugin?
Yes
hm I don't know
they have javadocs available here: https://sergiferry.github.io/PlayerNPC/dev/sergiferry/playernpc/api/package-summary.html
they also have examples o nthe spigot page
but tbh it looks a bit weird, the author even uses weird package names like NPC.Events.Interact
If I was you, I'd use another library for NPCs instead
Citizens
im not devloper , do u have a video
yeah citizens is the de facto standard
Guys in your file "plugin.yml" how many spaces do you use in commands
no
citizens its not in 1.18
spaces? none
wdym "using spaces in commands"?
commands:
health:
aliases: [h]
description: Restore your health
Yes it is
oooh. it doesn't matter how many spaces you use. I use 2 spaces per intend
( what does it mean "wdym" pls x)) )
wdym = "what do you mean"
do u have link ?
Hell it already even supports 1.18.2 lol
oh ok x))
yeah citizens works fine on 1.18.2
if you use 1.18.1, you have to use the second-last version of citizens
hmm
it's a little project between friends and I can't afford 10 euros for a plugin that's why I'm looking for an alternative
com.mojang.brigadier.exceptions.CommandSyntaxException: Expected '{' at position 0: <--[HERE]```
no context
i just get this in console
I mean you can download from their jenkins for free
https://ci.citizensnpcs.co/job/Citizens2/
yeah read the spigotmc page
why do they pay for it then on spigot?
It's for donations
i go check
ohh ok x)) thx
is it important to know how to code to use plugins?
yall know why im getting this error?
[11:41:44] [Server thread/ERROR]: null
com.mojang.brigadier.exceptions.CommandSyntaxException: Expected '{' at position 0: <--[HERE]
theres no context
no line of code
then I confess to you the problem being French is that there is no tutorial
you have more close braces than open
hey cuties
okep 🙂
welcome to java
There should be an error prior to compiling with that stuff
nothing
plus it doesnt even look like its my issue com.mojang.brigadier.exceptions.CommandSyntaxException
it looks like mojang forgot a brace
LMAO
a missing open brace may not generate an error unless the main cannot be closed
whats weird
is the fact that my plugin works fine
no bugs
it just throws this error
i would silence it but i want to know whats going on
Hmmm lol
heck how do i even silence it i dont know whats causing it
Hey \o
I want to change a massive amount of blocks clientside, how would I go about this? 😅
it is likely in a failure statement or a section of code that is not called
most people use world edit or brush
i need to install citizens api ?
ok ill update yall once i figuire it out ig
But I need it to be just clientside 🤔
are you in a single player world?
nms
unless your talking about a mod
No, on a server.
I want some people to see blocks which aren't actually there/different blocks
I know how to change one block at a time, but that's going to drag a massive lag
it shouldnt have massive lag
since its only client side
and for some players
and its nms
how many blocks are we talking about here?
Not the server will lag, the client will.
It's being bombarded my single block changes
At least 100k probably 🤔
what would be the purpose of having specific players see nonexistant blocks?
You could probably be smart about the order of blocks you send, if you send all the outside ones first then the client isn't trying to render them all, because the ones it's receiving are obstructed anyways?
Hey, I'm probably making a really dumb mistake, though the whole event isn't working and intellij says my event was never used for some reason, any help is really appreciated! https://pastebin.com/m86m3xpz
when the players that can see them go and stand on those blocks the server will likely boot them out
You're missing @EventHandler
I have a whole lot of blocks which can lag toaster users.
I want players to be able to hide these blocks if they are experiencing lags
they can manually reduce their render distance in the client ...
virtually replacing the blocks with air does not mean they are rendering any less blocks/chunks
They'd probably still have some lag if they get close though
I mean Litch, try the most straightforward approach before immediately just throwing it away lol
the server will still send them the same amount of data
whats the purpose of this?
maybe we can figure something less lag intensive
Borders of stained glass. (Multiple layers until players can't see through them).
Looks fancy, but toasters die 😅
tell them to turn off shaders
Shaders?
use a worldborder?
you can use nms to send client side worldborders
actually, lets go back a bit. Why are you trying to solve a client rendering issue if it is not directly caused by your server?
If you mean like optifine shaders...
They don't really have enough power to run any of that 😅
Because we don't want to lose players just because we want stuff to look good? 😅
the client settings are their choice, if they do not wish to reduce quality to improve their performance..
if they have optifine installed, make them switch to sodium
that will cut their render distance request from the server in half
MultiBlockChange packet?
And how would I use this?
First, what server version?
1.17.1
fyi it would be easier just to push them a custom texturepack that has no transparent blocks, but that will still not help the issue
Well, they have better performance without the glass, so if it's just because of their transparency, that would be fine
Just doing buildtools real quick to check the parameters of the packet
you can turn off transparency in your client settings as well
You can 🤔
how depends on what you are using for a client
Most of them use Badlion or Lunar Client
Google is your best friend
state machine - if match do this
a switch is a if/else BUT it runs everything from the if it hits until it either a return or a break keyword
no, a switch is not if-else
its called fall through
unless you add 'break' in it
everything from the 'case' it finds first gets executed
including the case: statements below
you can, but maybe you should look into using Tag.isTagged instead of endsWith()
can someone explain to me what a command map is
fruit?
why are you using .equals() for barrels?
find where it is copying the object and destroy the original - likely it is probably fixed in teh official code
on a different topic, does the client send a movement packet when the player is walking into a corner, not moving but holding w?
looks fancy
you get the drop there and it does not destroy the original unless it is deeper
infinite coconuts and pineapples
no
the code you sent even runs for cancelled events
you want to return if the event is cancelled, I guess
for the top if statements you could probably use an or || to reduce "if"
it checks that there is something to harvest and then drops a block if there is. there is nothing about removing the original
ah
will you marry me?
yes
ok. thursday?
bett
that is the event you are looking for
as said - don't run that code if the event was cancelled already
e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), item); there is nothing here that says remove the original...... which leads me to belive the trees do not naturally spawn fruit
if they do not, everytime you destroy the original you will have less fruit in teh world
how do i cancel a bukkit runable from inside itself
(a workaround would rely on yet another static HashMap)
this.cancel() iirc?
huh
might work
imma try
on a different topic anyone knows if i need to set player.isGliding(true) every tick or is it enough to do it once?
(for them to keep staying in the gliding state without having an elytra)
depends
if they are on the ground
they will automatically stop gliding
ah no in the air
but if they are in the air
so i only need to do it once
pretty sure
k
but ive never used isGliding before
try it and see what happens
1 sec
so i just found out
changing a player's attributes is something that persists over relogs
(not sure about restarts yet)
its an intentional clone: "ItemStack fruits = check.getItem().clone();" https://github.com/TheBusyBiscuit/ExoticGarden/blob/master/src/main/java/io/github/thebusybiscuit/exoticgarden/ExoticGarden.java so it is supposed to duplicate it
that isnt that useful
remove the .clone() and that should fix it
Any code suggestions:
https://github.com/2Hex/EntitySerializer/
So it stores entities?
this is more of a help channel not a suggestions channel :)
using the PDC is better
and recommended if you want to store small amounts of data
ye
make an entity into
a namespacedkey
and a namespacedkey into an entity
API and Core should be two different maven modules. Also move that exeption in to the API module
nah
that shouldnt be used
by users
Aight
i did not look for anvils specifically, but this is old code. I saw the reference that it used to use heads
I just guessed it's use by the name
yes, the api is useful like that :)
buy him some coffee and ask him to modify the code to how you think it should work: https://github.com/TheBusyBiscuit
well
time to lag my server by doing some bullcrap in onMove
shouldnt affect your server - and if i recall somoene else's code it gets cancelecd after one tick
the issue is i have no idea how to do that particular code
i thought it was the same as
Map<Object, Object> map = new HashMap<>();
Map<Object, Object> otherMap = new HashMap<>();
map.put("a", otherMap);
otherMap.put("b", "c");```
im fairly sure player.isGliding() returns false in onMove
but the data inside container is empty
how do i then persist the gliding state without it persisting on the ground?
they had to keep the state persistent to prevent the server from canceling it automatically.... i think is how it worked
dont do onMove
make a BukkitRunnable
onMove can call like a hundred times a tick
parameters are 1 and 1 right?
BukkitRunnables can be scheduled to run 1 time a tick
plugin, 0, 1
anyone have a good tutorial on lambdas?
Does it make sense to use hibernate in my spigot projects
im pretty sure you can check Player#isGrounded() in the runnable
iirc
its deprecated because it is dependent on the client
tho what the heck does a player want to abuse THAT for
hm yea i ralized
i can just use that lol
no dont
dont use deprecated methods
i think you should just check if the block under the player is a block
that isnt air or flowing water
^
is there a: Poa @ Me in Reply on any of the servers you are on, they were working with a similar issue
i cant find a link to their github offhand
Hello, whenever I spawn an armour stand using this code (https://pastebin.com/4xmxbBNQ) the location of the particle I'm spawning is at the right location (tip of the arm location), but when I try moving the armour stand using vectors (https://pastebin.com/y70riPLR) the location gets moved further away from the armour stand and the particle isn't getting displayed at the players hand location. I've spent hours trying to figure out what I'm doing wrong but I can't seem to figure out how to get the hand location while the armour stand is moving, if anyone could help it would be much appreciated.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
eh the method you gave me will probably work
also theres still no jump event in the api and its bloody annoying
mhm
wait
let me see if there is a jump event
why would there be if there is a flying event?
tbh PlayerMoveEvent should suffice for a jump event
since the PlayerMoveEvent has a #getFrom() and #getTo()
you can just find the delta y
wouldn't that then trigger if player moved up by piston or bounces off bed/slime
question mark
yes it would
but if you look at it in practice, what plugin wouldnt consider being pushed by slime or etc a jump?
a jump counting plugin lol
or a double jump ;o
that would be so cool doubl jump plugin
Double jump can be done in vanilla. Anyways you can use the jump statistic to detect jumps
you can always test if there was a slime block or piston under the player
define harvest?
isn't it better to setAllowFlight(true) then cancel the changeFlightState event and instead set the player velocity to what it is after a jump?
bleugh
i just realized
you're shadowinging
shadowinging
declaring the same variable in different scopes
wat
thats actually a server side thing too
do you know how to use commands?
your opening the inventory on an async thread
so it wont work
why not just make bpmenu a command lolwtf
just register a command
pizza guy i have sent a message in the thread for when u have answered everyones questions
kk
fruit.getWorld().dropItemNaturally(loc, fruits);
fruit.setType(Material.AIR);
?
you set the item to air after dropping
if you drop the item, you cant change the material like that anymore
you should change the material to air before dropping
while you are fixing it, you might want to switch switch from using Material ....
mr pizza another message in the thread 😔
incidentally, it looks like BlockStorage could use the other version: public static void clearBlockInfo(Block b, boolean destroy) {
clearBlockInfo(b.getLocation(), destroy);
tacos are food?
not really, because frameworks assist you in creating something new
its more of an api because it interfaces with the game
not a complete api tho
actually
how is it an api
well it kinda is ig
u interface with the server
it gives you access to functionality
I know but like
it controls the flow of the software
not you
you only control a certain portion
it doesnt control any flow
it doesnt modify anything on the server
no functionality has changed
youve only added third party functionality
it does not do anything by itself
exactly
"it"
the plugin
well it aint a human
if you just ran the plugin with the spigot "framework" without a server running
it would do nothing
you need a working running server for the plugin to work
which makes it an api
o
it takes a lot of courage to admit your wrong so i respect that
lmao
the blackbox test is usally a good way to determine what you are working with
Some of spigot are framework classes tho
what even is that
Yeah I should have clearified that I meant with command blocks / datapacks
You send a signal in and detect the signal that is coming out without knowing what the internals of the blackbox are.
Your signal is x and your outcome is y. Sometimes this is enough to derive f where f(x) = y from.
if the blackbox does nothing by itself, it is nothing. If there is input and output, it is a function or a class. If there are functions to access that produce a result it is possibly an api or library
you can determine other aspects as well, its just an overview or evaluation
programmers use the weirdest metaphors
what are the benifits/differences of using java.lang.<type> instead of the "int" "float" "double" "boolean"
i know for one that you can null check them
one has more utility functions
the natives are just there to be datatypes
well lang cant be used in Set<E>, you need to use Lang, but that's about the extend of my knowledge
yes
you cant use natives in type parameters
List<int wouldnt work butList<Integer> works, because Integer has utility functions that List can use in it's methods
is there a performance difference or can i just use whichever
ic
alright thanks
i generally use natives
I feel like it would be weird if list uses util functions from integer
As anything can go in a list
Its not because of the utility methods but because int is a primitive type which can not be generic.
would making a class that holds an int in it, and then a list of it, be better than a list of Integer s
google explains it pretty well
int stores the binary data
but Integer is the wrapper for int
Define "better"
If you just do it for the sake of having a List<int> then no.
Integer has features like auto unboxing which you couldnt implement with your own wrapper class.
performance
IntList 😌
it uses very generic utils, like equals and toString and etc
Integer is just the class representation of int
since you cant do int#toString(), you do Integer#toString()
valhalla wen
Non-generic collections are always a lot faster than the generic counterparts
I mean there’s a separate Class<T> instance of int as opposed to the Class<T> instance of Integer
Especially if you are extra specialised they can be orders of magnitude faster
the performance impact is minimal, isnt it?
Integer.class and Integer.TYPE (:
So bassically it uses util functions from Object
"relative"
i guess, since it inherits from Object you could say that
but dont ask me i didnt write java
i just use it and try to figure out its workings
depends, my regionated (int, int) -> Object map is around 1000 times faster than a ConcurrentHashMap<Map.Entry<Integer, Integer>, Object>
So the difference can be HUGE, especially for maps as you avoid all the hashing which can be costly
well yea of course, one line of code runs faster than 2 lines of code lol
Not really
how many people crunch mainframe scale data?
how are they "util" though
Yeah all the unnecessary boxing and possibly unboxing could scale quite badly
int.class 🙂
(~a && ~b) || (a && b) for example is going to be as fast as a == b
or was that sarcasm
maths ew
It is always going to be faster
wha
in small, non-blocking functions on the last few generations of processors, the difference is almost immaterial time-wise
for () {} is basically an iterator, Streams are basically an iterator, with a lot more stuff going on in the background
Oh, you'd be surprised what runtime complexity can do to small non-blocking methods
and eitherway that rule pizzaguy said is really wrong
for example interacting with a database
it should be done off thread
which will take more lines of code
what the hell does ~ do
but would be better than doing it in the main thread
Thing is it all boils down to what instructions the compiler compiles
invert all bytes. That being said my statement only applies to booleans (and thus this statement does not work in java world - only in booleanic algebra)
yes/no
@ivory sleet why hate lombok
oh no
Does the respawn event get called when a player spawns after logging in?
However it also comes down to what sort of database. Flatfile DB queries can be on-thread as ideally you'd have no IO due to caching
i can chck
you can just player join event for this yes?
Lombok smh 
why is lombok bad
Yes but it'd be easier to use one event
poor IDE support
Why does this Lombok conversation happen all the time
IntelliJ is not the only IDE
I mean, you also have records now anyway
it does not get triggered
besides @Delegate not much need for lombok
jdk 8:
Technically Delombok is great, lombok's eclipse plugin is incredibly bad
no
if you still are on jdk 8 you are about to be surpassed by commercial java apps
at which point you know you are legacy
You are missing out on a lot
(that was sarcasm)
my favourite J10+ feature is InputStream#readAllBytes
my fav is var :>
oh yeah, that one is nice too
explain that one
also just all the additions to streams/optionals after java 8
huh ?
what do you need explained about var
no what does that operator do
it infers the variable type at compile time ?
whats that good for?
I mean
Not typing out huge nested generic statements
IOUtils.toByteArray(is);
Because it’s officially essentially truly objectively useless and meaningless and makes Java code unpredictable
Isn't that lib for removal now?
or guava
Would you like to type out
Map.Entry<Map.Entry<Integer, Integer>, Map.Entry<Integer, Integer>> for example
ByteStreams.toByteArray
it looks cool tho
from an idiot perspective btw
aka me
Why write code at all if Lombok does it all for you? "Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.
Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more."
Who cares about aesthetics
I mean, we all have used wrappers around it, but they will all have performance impact as there is no way to estimate the full size of a stream
I hope you’re sarcastic
and if its a file u can use Files class
smh imagine using file instead of path
the method accepts Path tho
Also, I am sure that a lombok hashcode will be less performant than a hand-written hashcode
so u will .toPath()
more so than anyone else
Problem with Lombok hashCode is that I have no clue whatsoever how it deals with the hashing
Sure it’s possible to find out
Probably an Objects#hashcode wrapper
But then what happens when I want to change it

blockstate change is my guess - since there will be a change when the two interface
how could i detect when the line of the fishing rod breaks?
its inside the dropItemNaturally() - and I think I gave you the instruction to fix it abouve
LowOnEspresso — Today at 10:52 AM
incidentally, it looks like BlockStorage could use the other version: public static void clearBlockInfo(Block b, boolean destroy) {
clearBlockInfo(b.getLocation(), destroy);
change the clearBlockInfo to use the destroy version
java is short for javascript
not the word
Java and Javascript are quite different
they are the same i wrote my frontend in java
Not the same
JavaScript is a lightweight programming language(“scripting language”) and is used to make web pages interactive. It can insert dynamic text into HTML. JavaScript is also known as the browser’s language. JavaScript(JS) is not similar or related to Java. Both the languages have a C-like syntax and are widely used in client-side and server-side Web applications, but there are few similarities only.
fake
how about pointed_dripstone
any idea on how to check the first slot of an anvil?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
technically the inventory is the combination of anvil and player inventory
since it's a GUI and not a block with storage
as such the anvil uses the inventory interface with three extra slots shoved in front of the player inventory
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/AnvilInventory.html inventory extenstion
the amount of nested if statements my plugin has would make a competent programmer cry
"Interface to the various inventories. Behavior relating to Material.AIR is unspecified." What a strange note
convert too many if statements to variables and switches if you can
hasn't air not been an item since 1.7
about the same time water sources stopped being a thing i believe
air seems to now be an access rather than an actual block
how to separate flowing water and water? There's just one non deprecated water material
ik its not a programming question, but since git is associated with programming ill ask it anyway
i have added remote upstream to my git repository, i see all remote branches on my pc (local repo) but its not visible on github page, what do i need to run to show all the branches on github repo
thanks
I have not actually figured out how that translates into flowing water on a level surface - maybe any non-zero is flowing?
a level of 0 corresponds to a source block, 1-7 regular fluid heights, and 8-15 to "falling" fluids.
what do you mean in sequence ?
le block b
if(b.getType() == Material.AIR
|| b.getType() == Material.WATER
&& ((Levelled) b.getBlockData()).getLevel() != 0)
afaik the second part will not trigger if the first is true and the third wont trigger unless the second's true
but im not sure
in java I do not think that will achieve what you want
actually
the order of the conditions matter
unless they're mutally exclusive then both get checked afaik
imma just tryy
okay
unless doing (Levelled) block.getBlockData() on an air block returns a non null instance of Levelled
conditions get checked in the sequence they'rein the code
GOD FUCKING DAMMIT
i found a bug
in spigot
well its probably a feature
but its messing me up nonetheless
uuuurgh
what the bug
you dont need to check teh level of teh air
actually i do
i flag a group of players with isAllowedFlight, then cancel that event to trigger another
that way i can detect someone pressing spacebar in the air
uuuurgh
but im an admin on my test server
so i fucked over myself
first world provlems
Listen for PlayerGameModeChangeEvent and then set allowed flight back to true then
if(b.getType() == Material.AIR || (b.getType() == Material.WATER && ((Levelled) b.getBlockData()).getLevel() != 0))
yea correct
if its air
the second part of the if statement does not get run
because a or (b and c) gets checked in order if not a then b, if b then c
i think without the extra brackets limiting the test to water, it will pass on lava ...
actually unless i make sure its a water/lava block it probably will just break
Levelled is a interface for flowing fluids and cauldron height
but there's probably undefined behaviour for parsing blockdata to levelled for anything else
also unsure if powdered snow is now part of levelled
Material#isAir()
is that faster than material == Material.AIR ?
?paste
isAir() is the new method
wasnt the question
It checks all 3 air types
No but there is more than one type of air
say what now?
what other air is there supposed to be
like
air is everythign that isnt
cave air and void air
new generation
For some reason I'm getting this error when I'm trying to change a line of a SignChangeEvent:
https://paste.md-5.net/nivovezuhu.sql
This is my code:
@EventHandler
public void onShopCreate(SignChangeEvent e) {
Player p = e.getPlayer();
e.setLine(4, "---------------");
}
Does anyone know why?
programming languages start counting at 0
signs have 4 lines of text
do the math lol
Well, most of them
zero is a number because it means none!
Niceeee
foreach (String line in plugin.getConfig().getStringList("bossbar")) {
// TODO: write some code
}
line in doesn't work here
Because thats not java
mkmk
for(String line : plugin.getConfig().getStringList("bossbar"))
AI probably isn't meant to be used in 100% of java dev as of today
Perhaps in the future it can be used to develop 100% of the code
tabnine has lots of broken code in it as well
Thanks, I'm always forgetting that it starts at 0
binary start at 0/1 and so do computers
it seems to pull from many places, but it has lots of broken and out dated code. Maybe a bit less in java, not sure
lua would like to know your location
everything i ever did in lua was some kind of variable manipulation
but nothing with counting
Arrays start at 0 because of pointers, not binary
no arrays in assembly
arrays start at 0 because of maths
But there are pointers
Which is all arrays really are
stack pointers, yeah
The location of the memory isn’t critical to the concept of the pointer
In java arrays behave a bit different
Not really
They keep track of their length sure, but that’s the main notable difference
They are more of a vetor of pointers
if I recall, in java the array constructor does not require everything to be the same as it does in other languages
Well, vectors do not need to be resizeable
Define “the same”
That’s what distinguishes them from an array
A vector is a data structure backed by an array
In java that may be the case, but not in mathematics in general
Java arrays are much closer to a C style array than a vector
I used vector quite knowingly because otherwise I had to fall back to list or array, which would basically fall back to array
The only difference is that it has an attached attribute telling you its size
So I'd define x with x
I’m not confident that’s valid syntax in Java, but assuming it is, that’s because Java has an Object type that C/C++ does not
Everything non-primitive in Java extends from Object, so you can have an object array
That’s not the array behaving differently, that’s the language treating many different things as having a common base
well in C arrays are just objects squished together
the pointer of the array is the pointer of the first object
The type tells you how big each index is
C doesnt have objects. You can just randomly allocate 10 bytes in memory and call it an array
Yeah, basically falls back to the same thing
Exactly
This you’re correct about
However in java non-primitive arrays are basically (header <point>, <point>, <point>) where in C it'd be (<instance>, <instance>, <instance>)
You can have a pointer array in C too
Again, it’s not the array behaving differently
Non primitives in Java are always pointers
"In Java, array is an object of a dynamically generated class. Java array inherits the Object class, and implements the Serializable as well as Cloneable interfaces"
Java doesn’t have non primitive values that aren’t pointers
i gud
