#help-development
1 messages ยท Page 10 of 1
perhaps
Something something house of glass something something cast the first stone
what
Orbit he must be trolling I can asume because i didnt smoke much wheel
bet you didnt smoke wheel
Wth am I reading
Isnt wheel?
Ohh
i said that spigot doesnt allow u to have 2 classes extending javaplugin when they reach the heap in the jvm runtime area
Yea due to the diamond problem
and idk what the heck people are saying ๐
I know that but as you said you Where refering more to the JVM
Conclure
you asked about spigot
Yes
ok tf is this
It shouldnt even compile to begin with
conclure im right, right??
Its illegal java
ohh nvm
But yes the runtime does catch it also iirc
ffs finally
Wait for when 2 classes cannot extend a parent?
in spigot
Never
Oh okkk
you said you were fluent in english just this second and were flaming me a few moments ago
I finally catch it
๐
there should only be one JavaPlugin
Its not a thing in Java, you have multiple inheritance with interfaces
man
Not for classes
i lost like a few million brain cells today
yup
@ivory sleet and btw
you said learn to java
Oh yeah only one class with the JavaPlugin derivation also
like it was a java thing
2Hex is correct
You literally said I should learn java
The classloader explodes
Dafuq is DI
I donโt know if theres much to be said here
nice
then u clearly dont know java?
Learning java is fundamentally integral
@tardy delta And also, if assign the class to 2 players, when Player1 edit a value, that edit also to Player2 or just player1?
Ok bruh, I don't know Java
Dependency Injection
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.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Dude, do you know a super niche thing in java
dependency injection, passing dependencies (objects used in the instance) to the instance constructor
you don't know the entire language
No it's not
wydm by 'assigning' those classes to a player, are those islands for one player or smth?
ok
imagine how much damage I could do if I" knew "it
what is "wydm" ?
that doesnt matter at all to me
what do you mean
Hex calm down mate
im feeling like i might get muted for arguing more
Dont be rude
verano bro imagine 2 people
Stay mad 2hex
won argument
Guys both drop it right now
Well, if 2 players are playing together on the same island, the same class should be used,
so if Steve changes something, does it change Alex's too?
This will only escalate
It's a java thing that 2 classes can't inherit from 1 class 2hex
that's what you said
heyo. i want to cancel item durability damage event if the item's durability is equal to 1 or 2. how can i go about doing this?
if there is nothing like a protection system, yes that stuff will change for another player
?learnjava @grim ice
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.
?kick @native talon
Done. That felt good.
๐ฎ
This feebly useless debate is ended now
lol
Dont start it again, move on thanks
daddy conclure here to break up the scuffle

ive been banned once i know what "drop it" means ๐
verano im pretty sure he told us to drop it
๐ค
specifically items starting with netherite. would this work?
yeah i know bad code but im just testing rn
Hey I have this code for transferring all items from a stored inventory to a player's inventory, but it's not giving me a single item. The code is being ran (Added a few sout statements)
ItemStack[] contents = stored.getContents();
for (int i = 0; i < contents.length; i++) {
if (contents[i] != null && player.getItem(i) == null) {
player.setItem(i, contents[i]);
} else if (contents[i] != null) {
player.getHolder().getWorld().dropItem(player.getHolder().getLocation(), contents[i]);
}
}
would someone be able to see what's not transferring?
oops, i forgor to setItemMeta.
uh clean that by extracting the && part
ItemStack[] contents = stored.getContents();
for (int i = 0; i < contents.length; i++) {
if (contents[i] != null) {
if (player.getItem(i) == null) {
player.setItem(i, contents[i]);
} else {
player.getHolder().getWorld().dropItem(player.getHolder().getLocation(), contents[i]);
}
}
}
and do a continue
does anyone know why setting the BookMeta doesn't work? ```java
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
meta.addPage("Foo\nBar");
book.setItemMeta(meta);
plr.openBook(book);```
where?
if contents[i] == null continue
Is there a way to store an Object Array in a database? (H2)
it should automatically continue tho?
byte array?
but you're saying like this?
ItemStack[] contents = stored.getContents();
for (int i = 0; i < contents.length; i++) {
if (contents[i] == null) {
continue
}
if (player.getItem(i) == null) {
player.setItem(i, contents[i]);
} else {
player.getHolder().getWorld().dropItem(player.getHolder().getLocation(), contents[i]);
}
}
Nah, I just have about 20-25 Home objects I have to store. Though they're rather small
print stored.getContents()
oh i didnt see array
as well as player.getContents()
per user btw
thx, I'll try it with that. Because If I try to put in an object array, it won't let me
mye dont have my project open with h2 code
Well even with the array type...
lemme switch anyways cuz this project sucks
xD Thx
[19:48:24] [Server thread/INFO]: [Lorg.bukkit.inventory.ItemStack;@15555f61
it just gives an object reference
there's no toString for inventories that actuall gives the contents
i've found a PreparedStatement#setArray(int, sql.Array) but that array thing is an interface and idk if youre supposed to implement it or what
Yeah, honestly I'm not even sure what type array is supposed to be. I mean int arr or boolean, yeah sure but array?
setObject(int, Object) with an array seems possible too
what are you even trying to save?
I mean I could make an object in which I store the other objects ig
Home objects, which contain location of the home, name etc.
is it necessary to remove the packet from player when leaving?
yeah, Ig. I think I'm gonna try the object in a object things first though, because it seems more organized
I appreciate the help though.
I'll take a look at that. Thx
how do i compile my plugin that uses java 8 with a library that is java 16?
if u use intellij, u can do it in Project structure
how
Just set the target java version in your project
it has to be java 8
and its set as java 8, but when i compile it says that it can't "understand" the library because its java 16
Yeah set the java version in your pom or buils.gradle
smh
Then use a modern jdk to compile
i'll try
is it necessary to remove the packet from player when leaving?
what packet?
PacketPlayOutPlayerInfo and PacketPlayOutNamedEntitySpawn
by doing this i'm compiling the plugin as java 8 but with java 17 so it can understand the library, but it doesn't recognize Unsafe
why
its a java class
uh in what context?
create a npc
ah uh idk
Why not use Citizens?
i've changed it so it prints every itemstack individually
ItemStack[] contents = stored.getContents();
for (int i = 0; i < contents.length; i++) {
System.out.println(contents[i]);
System.out.println(player.getContents()[i]);
if (contents[i] == null) {
continue;
}
if (player.getItem(i) == null) {
player.setItem(i, contents[i]);
} else {
player.getHolder().getWorld().dropItem(player.getHolder().getLocation(), contents[i]);
}
}
and apparently every single itemstack is null
i'm setting the PlayerInventory data like this corpse.setMetadata("inventory", new FixedMetadataValue(plugin, player.getInventory())); (in an player death event listener)
and retrieving it like this (PlayerInventory) entity.getMetadata("inventory").get(0).value();
What version are you on
1.18.2
?pdc
what's a better way?
If you try to read the corpse inventory you might endup with the player inventory
Which is empty
This is the better way. Also store the items not the inventory
i want the location of the items to be stored too so i was thinking of storing the PlayerInventory object to make it easy to reference it
that way the restoring of the inventory puts it all in the old place (or drops it if it doesn't fit)
Just store an array
Anyways for PDC you can use https://github.com/JEFF-Media-GbR/MorePersistentDataTypes
how do i get the color of a glass pane in a player's hand
What version
1.19
so do the .getContents() and store said array?
Yes
What is the event when cobblestone was generated by water and lava
declaration: package: org.bukkit.event.block, class: BlockFormEvent
Thanks you
how would I load a world? I tried java World wrd = Bukkit.getWorld("the_void")which returned null, then I found out that I need to load it, so I changed it to java World wrl = plugin.getServer().createWorld(new WorldCreator("the_void")); plr.teleport(new Location(wrl, 0, 64, 0));; which just creates an empty world instead of loading the already existing folder
https://media.discordapp.net/attachments/729496708186374145/1001193673473662976/unknown.png anyone see anything wrong here? wont even send the message for some reason
no, separating the event into another class didnt help
You should definitely separate the event and the class anyway
yeah i know this is bad practice lol
did spigot break? hehe
i seem to have figured it out, thanks
use some json library, create a new file with player uuid serialize the object inside the array
java.lang.NullPointerException: Cannot invoke "com.arr4nn.townyteleportunlock.models.UnlockedTowns.getUnlockedTowns()" because the return value of "com.arr4nn.townyteleportunlock.utils.TownsStorageUtil.getPlayerData(org.bukkit.entity.Player)" is null i dont even call the methord and it is angry
the only issue i'm having now is that the event still causes the items to be dropped, even if i'm clearing the inventory of the player before the end of the event
i am trying java if(getPlayerData(p) == null){ plugin.getLogger().info("Towns is null"); }
event.getDrops().clear()
Assuming death event
yep, okay thanks
what data are you trying to save, are you using json
so you want to create a JSON file with the UUID of the player as name
and then write the data into it if they dc or periodically
u need some library like gson
there u can create new json file and write into it
i think if u Google how to serialize object into json
u should find a guide
so when the player connects again
it checks if there is a JSON file with the same name as their uuid
and if yes u can set their stuff
Just use SQLite jeez
Well SQLite would be better than generating an entirely new file per user
you have to start somewhere
can help my
i got recommended to use files first by 7smile7
no
Rq, when I use the SQL WHERE I can just use PreparedStatement#setObject(), to compare uuids right?
No. Look at their code ๐
quick tip
if u r using instanceof
you can already do sender instanceof Player player
don't have to do that in next line
if he's making plugins for 1.16+ it works
You appear to be replacing the placeholder in the path to the messages rather than in the message
You might need 8 for old versions
Netbeans ๐
Just use intellij 
^
Not bought they just took it over since oracle abandoned it iirc
??
You don't need to pay anything
yes
eclipse is way better than netbeans
and intellij is thousand times better than eclipse
why do you need that?
yes
same thing
you just alt tab
don't have to click
?
how is that weird
workspaces are utterly disgusting
they're a private company
netbeans is funded by gigant
eclipse is funded by gigants
their ide is still superior
yes they do
you can use the community version
or click
are you a student somewhere?
damn was going to say students get all premium jetbrains IDE's for free
atleast use eclipse...
I use eclipse ๐คทโโ๏ธ
It's nice to know your IDE
But really netbeans is so behind compared to eclipse
and even more compared to intellij
The only thing I like about Netbeans is their swing ui editor
Intellij is better at everything else
nvm resolved
well im counting blocks in a editSelection and i need to mask the blocks i want to count
basically its sorting the blocks in different sections
Hello there. I wish create a tournament. I create and store a List of Fight but i don't know how can i launch a Fight and when it's finished (all players in a team was dead) launch another Fight
Someone know how can i do that ?
List<Team> coliseumTeams = coliseum.getTeams();
List<ColiseumGame> fights = coliseum.getFights();
if (gamemode.equals(ColiseumMode.MG)) {
for (Player player: coliseum.getPlayers()) {
player.getInventory().setArmorContents(coliseum.getStuff()[1]);
player.getInventory().setContents(coliseum.getStuff()[0]);
player.teleport(coliseum.getSpawnPoints()[0]);
}
} else {
if (gamemode.equals(ColiseumMode.ONE)){
for (Player player: coliseum.getPlayers()) {
List<Player> playerList = new ArrayList<>();
playerList.add(player);
coliseumTeams.add(new Team(playerList));
}
} else if (gamemode.equals(ColiseumMode.TWO)) {
for (int i = 0; i < coliseum.getPlayers().size(); i+=2) {
List<Player> playerList = new ArrayList<>();
if (coliseum.getPlayers().get(i) != null && coliseum.getPlayers().get(i++) != null) {
playerList.add(coliseum.getPlayers().get(i));
playerList.add(coliseum.getPlayers().get(i++));
} else {
playerList.add(coliseum.getPlayers().get(i));
}
coliseumTeams.add(new Team(playerList));
}
}
for (int i = 0; i < coliseumTeams.size(); i += 2) {
if (coliseumTeams.get(i) != null && coliseumTeams.get(i++) != null) {
fights.add(new ColiseumGame(coliseum,coliseumTeams.get(i).getPlayers(),coliseumTeams.get(i++).getPlayers()));
} else if (coliseumTeams.get(i) != null) {
fights.add(new ColiseumGame(coliseum,coliseumTeams.get(i).getPlayers(),null));
}
}
}
}```
That my code
I registred all Fights ^^
Maybe can i do that with PlayerDeathEvent ?
```
Which versions are supported by plugin-annotations?
?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I see the initial version was for 1.8, but is it still supported?
I would expect it to still work
You just won't have the api-version property
Which might be a problem
@tardy delta Like this ?
What are you doing?
Maybe i can help you
hey For my egggun plugin I dont want the eggs to hatch chickens, so im thinking I need a projectilelaunchevent but how do I get the player inside that event, because I want to see if they were holding the eggun or not if(player.getInventory().getItemInMainHand().equals(EGG_GUN)){ if (gunCore.getConfig().getBoolean("EggGun.Enabled") && (player.hasPermission(gunCore.getConfig().getString("EggGun.Permission")) || !gunCore.getConfig().getBoolean("EggGun.Needs-Permission"))){ e.setCancelled(true); player.pro player.launchProjectile(Egg.class);
yes, and want a file for defaults function exemple: Name, Upgrades, Quests ect and the class exemple NetherIsland have this beacause extended
(And i'm beginner in java, i'm a PHP at base)
Do i explain?
okay!
Stell also if you are a begginer i really recommend reading because it will make you get things easier
Not saying that you have to learn or that you dont know
no problem, I meant in the Spigot world, because I'm a bedrock dev but I have big bases in each language so I'm not lost and on the other hand I'm watching a java training ๐
I just a recommendation like they said in high school, "if you want to improove you have to study"
Oh nice the best thing for learning in my case is reading and creating projects to apply all what i learnt
would someone be able to give a hint to where one would set a pose for a zombie (so i can make it lay flat on the ground)?
that dead pose?
yeah just make the zombie lay on its back
if you want the sleeping pose just make an npc with a zombie skin
for corpses I just use https://github.com/unldenis/Corpse
it's simple
and you can shade it in
In this episode of the Spigot MC Plugin series, I start a new plugin called Bodied. This plugin makes it so when a player dies, an NPC is spawned using NMS and is made to lay down and have no nametag. In the next parts of this plugin's development, I will show you how to put items in the body once the player dies, and if no one claims it after a...
oh yeah i quickly saw that but it's NMS
i'm not sure if i want to get into that yet
I am trying to recreate some aspects of a game called Hypixel Skyblock, such as Strength, Defense, Intelligence, and am wondering how I can set those attributes to a player
like player.setAttribute("strength", 50); or something like that
setVelocity
What I need to put in brackets?
Do I need to multiply the direction?
There is a method like the opposite of Multiply?
Yeah that's my question.
uh k
Like -0.2?
I think it will speed up the projectile
what's the best way to make a /daily command?
would make teh projectile travel at 90% of its current speed
I need to like stop the projectile.
Set the speed at 20%
20% is not stop
Yeah I know
Then multiply it by 0.2
Hoping it will not speed it up.
of course it won't
Didn't see your code
you have to multiply by over 1.0 to speed it up
It's the direction of the projectile not the shooter's one
so yeah it's correct
forgive me, thanks btw
mark the time it was last used in millis, next time someone runs it compare the current millis with what was saved. If it comes out to 24 hours then its been one day
alr
and another question
how would i format that into like 5m 15s left
there is 1000milliseconds in a second
Lot's of division statements
Duration?
you can just use math or make use of Java's Date api stuff
public static String timeLeft(int timeoutSeconds)
{
int days = (int) (timeoutSeconds / 86400);
int hours = (int) (timeoutSeconds / 3600) % 24;
int minutes = (int) (timeoutSeconds / 60) % 60;
int seconds = timeoutSeconds % 60;
return (days > 0 ? " " + days + " day" + (days != 1 ? "s" : "") : "") + (hours > 0 ? " " + hours + " hour" + (hours != 1 ? "s" : "") : "")
+ (minutes > 0 ? " " + minutes + " minute" + (minutes != 1 ? "s" : "") : "") + (seconds > 0 ? " " + seconds + " second" + (seconds != 1 ? "s" : "") : "");
}
ig that'll work
I use this, yeah https://haste.miketheshadow.ca/edadehibob.nginx
that'll work
ty
It should hasn't be tested too much
has anyone a idea why the event is double triggert? ```java
@EventHandler
public void onClick(InventoryClickEvent event) {
if (!event.getView().getTitle().equalsIgnoreCase(chestShop.getShopTitle())) {
return;
}
if (event.getView().getTopInventory().getSize() != 27) {
return;
}
if (event.getRawSlot() > 26) {
return;
}
if (event.getRawSlot() == 20) {
return;
}
event.setCancelled(true);
if (event.getRawSlot() == 21) {
System.out.println(1);
ShopConfig.setAnkaufen(chestShop.getAnvilGui().getPlayerBlockMap().get(event.getWhoClicked()), !chestShop.getShopConfig().isBuying(chestShop.getAnvilGui().getPlayerBlockMap().get(event.getWhoClicked())));
event.getView().getTopInventory().setItem(21, getBuyItem(chestShop.getAnvilGui().getPlayerBlockMap().get(event.getWhoClicked())));
event.getWhoClicked().sendMessage(chestShop.getPrefix() + "Test");
}
if (event.getRawSlot() == 24) {
event.getWhoClicked().closeInventory();
chestShop.getAnvilGui().inputPrice((Player) event.getWhoClicked());
}
}```
Anyone have a genius idea of how to loop through this?
hive-rewards:
- type: gold_nugget
name: '&6Golden Nugget'
amount: 1
chance: 25
lore:
- '&eA golden nugget... how original.'
- type: gold_nugget
name: '&6Golden Nugget 2'
amount: 1
chance: 25
lore:
- '&eA golden nugget... how original.'
it doesn't count as a normal configurationsection
don't make the types a list
what should I make them?
just a config section
I was told not to use an ID as a key
yeah I was told not to do that
cause then you have to go through and change things manually
what do you mean change things manually?
like if I have 1,2,3,4 as the root
and I want to add a different 2
I also gotta rename 3 and 4
you can use the types as the keys
not sure why that wouldn't work
then you put everything under the types that belongs to that type
What if I want like.. multiple gold_nuggets though
then make 1,2,3,4 under the types
different lore, displayname etc
I will show you how I did it with servertutorial
ok
feel free to look through the other classes
mine actually moves the id numbers around though ๐
so if you delete a tutorial, it will go through and renumber them
hol up you're onto something there..
Mans got a spelling error in his first method. Smh.
is that in this file?
Unless Iโm the idiot and โcasheโ is a word that relates to caching.
For the renaming, couldnt you just like check.. if this int != last int + 1, this int = last int + 1
or something
@wet breach you aware of that or?
yes I am aware of it
This is not pretty code
No
You want to see beautiful code?
This is beautiful code
It doesn't get any better than this
lol
How does the file renumbering work.. ๐ค
Well regardless my code works and that is all that is needed ๐
cause u cant modify the list while looping over it
anyone knows why the Inventory automatically clloses? ```java
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerUse(PlayerInteractEvent e) {
Player p = e.getPlayer();
World w = p.getWorld();
if (w != null && w.getName().equalsIgnoreCase("the_void")) {
e.setCancelled(true);
Inventory inv = Bukkit.getServer().createInventory(null, 36, "Cool Hub");
p.openInventory(inv);
}
}```
cause ur inside a portal
does it actually turn off inside of a gateway
Is it in a portal or in the end void?
overworld - end gateway
but if it is in a cache you can though ๐
Because in the end portal its right it close but in the void its not. If u are in the void then maybe the world names isnt the_void
never sleep threads
the_void is just the name of the world
wait
it doesnt have to do anything with the end
True
bro ur pfp ๐
oh my god you're right
๐
is there a way to still have that end_gateway cool thingy on my screen tho
you just don't make the main thread sleep. There is times where you want a thread to sleep. However most people here don't mess with threads lol
scheduler delayed task?
so what should i do?
scheduler if you want to wait a single tick
put your code in the scheduler
or you can make your own thread that just waits 50ms since that is approximately 1 tick
assuming server isn't lagging etc
so add the runnable in while loop? Or put the while loop inside the runnable?
what is your while loop waiting for?
depends what you are doing, might not need the while loop not sure
well im making "pets" which will teleport an armor stand beside you
and?
well im doing while it's alive im teleporting it
odds are you probably only need a repeating delayed task
and i need to wait 1 tick or the server will crash
or teleport it only when a player gets 10 blocks away everytime
thus no scheduler needed
wouldn't i need a scheduler to check that?
player movements are part of the events
yes, however you'd then be having to track player movement in teh MoveEvent and calculating distance
you just need to check the distance everytime the player moves to see if its 10 or greater
if so, move the pet
wouldn't that be more laggier?
no
the event fires whether you decide to do something or not
if you just run a TaskTimer every 40 ticks or so, teleport the Pet. Its not a really heavy task as it calls the moveTo in NMS
either method works just fine ๐
okay so the movement event doesn't lag? im jsut doubling checking because if not ik how to do other things now
well, it all depends on your code
yeah ig
Yep, don;t use any while loops. Just check distance if you go the distance route
okay ๐
and only when the player has moved a full block, not every event
ye
nevermind it's because im constantly running Player#teleport
yippee I can keep the end gateway stuff
how do i hceck for age of wheat?
you mean growth percentage?
yes
this yea its also more precise
this shouldn't lag the server correct?
@EventHandler
public void onPlayerMovement(PlayerMoveEvent e) {
if(e.getFrom().getX() != e.getTo().getX() || e.getFrom().getZ() != e.getTo().getZ()) {
Bukkit.broadcastMessage(e.getPlayer().getLocation().toString());
}
}```
why doesn't it work when i use .getAge()
getBlockX and getBlockZ
it seems to be working great
show your code
it shouldn't, but if you are going to go this route you need to have an object that persists so you can track the distance
ye ofc, i was just testing the performance
first
i added a library jar to my libraries in intellij and i can use the api perfectly fine all the imports work fine but when i try to compile the plugin i get an error saying the package doesnt exist... but it does
use maven or gradle
i cant it has no maven
how do you compile?
maven
then add library to your pom.xml
the library doesnt have a maven
its saying unzip isnt a command do i need to install something
my own one
then you built it?
Jitpaaaack
then all you need to do it mvn install in that projects directory
intellij cant use mvn
install puts it in your own local .m2 repository
mvn : The term 'mvn' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
You need to use it in the maven tab
theres a M button
you need to install maven or inside intellij
yeah thats all i need
but if you wanna use it in cmd.exe you actually need to install maven on your device
i dont see any M button
right of screen
i need to open ide
oh mb got it
id run the command in the api or the plugin i want to use the api?
you run mvn install on your library project
oh shit
thats smart
idk why im not doing that
im an idiot i build my jar and move it to a /libs folder in my project im working on and install-file it 
๐
still doesnt work same error after installing, is there some kind of repository or smthn i need to add?
you have toi then add it to your dependencies in the project you want to use it in
remove the manually added jar
ah works now thanks
Heyo just out of curiosity is it possible to make a mob that is only visible to a certain player?
declaration: package: org.bukkit.entity, interface: Player
run that on all the players except the one you want to hide it from would be the simplest way
wait
wrong method
one moment
sorry
all good
i cant seem to find the non deprecated method ๐ค i just saw it the other day
That method will likely still work. Its just draft API
Ah okay, weird i never noticed it was marked deprecated before
?paste
okay ty will use this then, or attempt to anyways
ty Buchard37!
I'm making a custom item system in my plugin that includes a waypoint staff, the bed is suppost to teleport them to there bed location
GUI class: https://paste.md-5.net/ziyakelaho.java
ItemListener class: https://paste.md-5.net/olanovejil.java
very interesting way of telling what items are what using CMD
I would be concerend using it cause if another plugin makes and item with the same CMD set then your method will fire, which it shouldnt because theyre 2 seperate items, i reccomend using PDC for this (Hoping you are on 1.14+)
^ also your code will only work for a single player
what exactly is pdt? also why only on singleplayer?
?pdc
ill work on using that
You set bedNotSet when ANY player triggers it. from that point every player has it enabled as its a class level field
Don;t bother with the bool. Just test (player.getBedSpawnLocation() == null) when you need
also do you guys know why it doesnt work?
just relized that
when i click the bed the cancel event thing doesnt work and it does nothing
Honestly seems like an issue with the underlying class, or the events arent registered
don;t check the slot that was clicked, check the item
(Assuming you dont get these logs printed)
if you flag the items PDC you can check the PDC on click
woulnt that be way less performant?
for now my method works though
they do actually
Im not sure, but the void always cancels the event so it should be cancelling the click at the least
once you remove the boolean value
you use event.setCancelled(true); three times, but your code only has a single exit point., you can delete two of those.
and do what edgar said, youll be okay i think
i was testing yeah
but i will remove it
?
this part here specificaly, when checking if the bed is set on click use this instead of the boolean + the PDC item checking
yeah ill try that
lastly, do not call event.getWhoClicked().closeInventory(); inside the InventoryClickEvent
Read teh javadoc on it https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryClickEvent.html
where should i call it?
Also as an appeal thing
May look nice to schedule to close inventory, then send your message, then schedule again later to teleport the player
run it in a runTask or runTaskLater with a delay of one tick Bukkit.getSchedular()
Yes, with those fixes it will work
okay
You haven't actually told us what isn't working, so we just told you whats broken
well the bed click event isnt working
i beileve the issue was teleport() not calling/working
Then yes, all the fixes above
well it didnt even cancel the event but maybe
did you check console for an exception
if one generates the event will return out instead of running the rest of the code
no exception
once you get it workign, you need to add a drag event listener too, and cancel it
?
oh yeh drag clicking in invs
you cancel a click event, but players cna still drag items around your inventory
then why does canceling the event with the glass work?
because the glass isnt firing the un-scheduled teleport() and closeInventory()
oh
it ignored slot == 1 and just cancels the inventory click
Will a yml still load if theres a comment on the same line?
(after the stuff you want loaded)
load-this-line: 'test' #comment
yea ok cool
what are some cool things you can do with the spigot build tools?
build spigot
@sterile token How can save my data from my class, and restore when player reconnect and reopen the island?
Build spigot without malware
Uhm mojang remapping
Uhhhh that's about it
dang
yeah I'm loving the mappings
wait, whats mojang remapping?
The fact you asked that makes me think this man's downloaded an illegally distributed copy of spigot and is only just now realizing you have malware
no lol
Not played with NMS until 1.19 and been doing plugins since 1.4? ish
I build my spigot
any reason why spawners are only pigs? Its not a permission issue. after this codeblock i set the itemmeta ofc ๐
remappings are so sick
is jitpack free for private repositories im confused because some sites say it isnt some say it is
there is a search top of Discord you can find who mentioned you
Where?
the box marked Search
You can either use database or flatfile for peristant storage. If you want to use flatfile (save data in json or yaml files) your class should implements ConfigurationSerializable and you must register the class with a method i dont remember
UUIDs are supported
Elgar
Do you remember that someone tell to me use Bukkit#OfflinePlayer() by passing a UUID#fromString(args[0]) for example?
I dont think its okay doing that because i tested and i get some exceptions
No, but you can yes
From what i have tested it doesnt apply doing that
only if you typed the UUID string incorrectly
attributes
and apply that information to a player
I dont know the player uuid that why
I just know his/her name
theres no info on attributes ive looked
or im blind
care to share?
lets say a sword gives + 10 speed, how do i get that to a storage spot thats easily accessible by using anplayers uuid from any class file?
ty
If you don;t know the players UUID theres no way you can construct it from arg[0] like that
how would i map the word โspeedโ to the number 10, just asking for specific so i can understand better
I've no idea what you are asking
so i want items to have certain stats on them that buff things like speed, damage, and other custom stats i will use
and basically i cant figure out how to get the stats from the item and armor, and transfer it onto the player profile
thats the big picture here
if you have ever played Hypixel Skyblock, then this is exactly like their stats system. (using theirs as a model which i will change later)
here is their damage calculation page: https://wiki.hypixel.net/Damage_Calculation
@eternal oxide u understand?
sorry for pinging u again after safeanin i didnt see
๐
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
ItemMeta meta = boots.getItemMeta();
meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, new AttributeModifier(UUID.randomUUID(), "Speed_boots", 5, Operation.ADD_NUMBER, EquipmentSlot.FEET));
boots.setItemMeta(meta);```
Thats speed boots that add 5 to your speed
If worn in the FEET slot
This is basic java
So only alternative is doing OfflinePlayer#getPlayer(name) right?
Bukkit.getOfflinePlayer(name)
what if i want a custom stat? like intelligence, for example? how would i do that? as it has nothing to do with vanilla minecraft
That yeah my bad got concused
Inteligence is not a Minecraft thing
ik. its a custom stat. how would i make that a thing?
If you are adding custom abilities/skills/stats then use the items PDC
elegar consued isnt to get knocked?
never heard of it
?pdc
also thanks uve been a HUGE help โค๏ธ
You would have to manage writing the lore on items
i spent like 1.5h on this xd thanks
Hello, im working on a feature where you can teleport in the direction you are looking and is using vectors and so on. Is there anyone who knows why it makes me tp like 2000 blocks up in the air when i tp to a block infront of me?
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.
eyeloc.toVector().normalize().add(...
if you are calculating distances alwasy normalize vectors so they are Unit vectors and not location representations
didnt fix it, not i just end up in the middle of nowhere
and still far up in the air
oh I see what you are doing.
yeah don;t normalize that part
What is your Abilities.Dranwen.Teleport.distance value?
30
Why are you altering the Y on travelVector?
because if the person is looking upwards they should still go up
SO? theres no reason to alter the Y
they will go in whatever direction they are facing
maybe, im kinda new to coding and used some inspo so some of this i have no idea what im doing ๐
so i can just use the original vector, the "travelvector"
or should i just leave that be
eyeLocation.getDirection()
thats a unit vector pointing the direction they are looking
if they look up or down it still points the way they are looking
i guess so, i just don't really understand how it gets the y-value at the correct distance
you can also simplify gettign the final Location by Vector#toLocation(World)
so in your case java p.teleport(hitPosition.toLocation(world), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
it still teleports me far up in the air, did i miss something? https://pastebin.com/nET3H13R
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.
delete .setY(eyeloc.getY() * 0.75)
that fixed it, but how do i add the pitch and yaw in a good way? Cuz that resets
destination.setPitch(eyeLoc.getPitch());
destination.setYaw(eyeLoc.getYaw());```
that solved it. Thank you very much
I have a few other things struggling around the same event, are you able to help me with that aswell? It's two small things and i might just be blind
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
fair enough then, thanks ๐
On row 62, Im trying to check for action but i dont get the right_click_air to work and i have no idea why https://pastebin.com/Z8ZSEmWm
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.
I also didn't get the cooldown to work and im not sure if its the cancel that doesnt work or if i put the value in the wrong way
.getType().equals(Material.AIR) use .getType().isAir() for starters
there are currently two types of Air
did not know that one, interesting
not generally in inventories but good to use so you don;t make teh mistake in other places
thats fair
does teh Hand is empty debug show?
yes
I can do it when i hit on a block, thats why i was able to test it earlier
just not on right click air
so im guessing its the action in some way
yea, do i need more? thought i only needed one wraping the && statement
if ((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && p.isSneaking())) {
you do want it only when sneaking?
either action but only when sneaking?
if it was hitting a block i wanted the person having to sneak
or is that not possible, it doesnt really matter, was more me testing out
if (e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK && p.isSneaking())) {
still nothing
It should fire. It will fire as cancelled as you are clicking air
And the event is registered?
his debug on line 59 triggers
it doesnt seem to fire the event at all when i click on air
but works when clicking a block
right-click-air doesn't trigger if you're not holding any item
the client doesn't send packets
Only reason I can see it doing that is if you are ignoringCancelled=true
oh yes
empty hand will not work. you have to have an item
I had to make a whole trippy system because of that shit
where we had an invisible armor stand
interesting, but then i know how to fix that
that would pop out slightly depending on where your cursor was pointed
so that it would have click priority over other armor stands
then that explains things atleast
though, i still dont know what i did wrong with the cooldown
was a royal pain in the ass that took me like a week to fix
had to raytrace client-sided entities and hitboxes
yea, thats fair. I just got into spigot coding so i have no idea how to even start on that
there are a few changes I'd do to your code
like using uuids as keys on a map
and removing cooldown stuff
you can probably use a Cache<UUID, Long> from guava
then set it to expire after write
and see if the cache contains
Yea, ill have to learn how to use Cache then. But im guessing that works the same way as map?
similar
I copilot made this class in like 30 seconds
could be useful for you
Cooldown<UUID> cooldown = new Cooldown(3, TimeUnit.SECONDS);
cooldown.insert(player);
boolean isOnCooldown = cooldown.isCooled(player);
long millisLeft = cooldown.getTimeLeft(player);
I'll try to learn that. Could be useful
hol'up gonna make a tiny change
sure
I have to get more used to using multiple methods tho. Have just started with that
yea, thanks
I think ill use that
the Cooldown method at line 11, is that just to create the cache or?
so that will be kind of the same whatever i do?
How can I return if the server is up to date?
public static void check() {
new UpdateChecker(NeoPerformance.getInstance(), 103183).getVersion(version -> {
return isUpToDate(NeoPerformance.getInstance().getDescription().getVersion(), version);
});
}```
thats an example, you cant return in a lambda
you can indeed return on a lambda
just not on a consumer or runnable
a function, for example, allows it
well
you can't return a value in a consumer
because the return type of a consumer is void
So how would I getVersion and then process with isUpToDate and return the value?
so use a function
in the class you made me about cache= what do you use the "timeout" and "unit" for?
is it just for the constructor?
ye
for indicating how long the cooldown lasts
ConfigurationSection mainGuiSection = guiItemConfig.getConfigurationSection("gui-items" + ".main-gui");
String mainGuiName = mainGuiSection.getString(mainGuiSection + ".gui-name");
mainGuiSection.getKeys(false).forEach(hiveInfoItem -> {
String itemType = mainGuiSection.getString(hiveInfoItem + ".type").toUpperCase();
gui-items:
main-gui:
gui-name: '#c35bfbโฏ#b65ff8ใ#a963f6C#9c67f3a#8f6af0d#826eedi#7572eba #6776e8H#5a7ae5i#4d7ee2v#4081e0e#3385ddใ#2689daโฏ'
hive-information-item:
type: book
Why is the String itemType = mainGuiSection.getString(hiveInfoItem + ".type").toUpperCase(); line an "invalid configuration section"?
okay, im gonna try to get it working and otherwise ill just tag you here if thats okay
trying to switch to lambda loops instead of the regular fors.
cause it looks cleaner
ConfigurationSection itemsSection = config.getConfigurationSection("gui-items");
ConfigurationSection mainGuiSection = itemsSection.getConfigurationSection("main-gui");
String guiName = mainGuiSection.getString("gui-name");
Material type = Material.parseMatrial(mainGuiSection.getString("hive-information-item.type").toUpperCase());
clean, simple code
is best
that is a horrible idea btw
why
overhead
?
Yes
forEach, stream, map
Or well the finer name is higher order functions but no one uses that term here
i love when ppl tell me to do something so I start using it then get told its a bad idea
๐คฆโโ๏ธ
How Java 8 lambdas and streams perform compared to longstanding implementations? Lambda expressions and streams received a heartwarming welcome in Java 8. These are by far the most exciting features making their way to Java in a long long time. The new language features allow us to adopt a more functional style in our code [โฆ]
the performance difference is negligeble
but I still vouch for simple code
I mean it will be pretty competitive once valhalla is fully delivered
you'll end up making fancy workarounds if you want to use variables inside a lambda as well
due to that "all values must be final within anonymous classes" thing that java does
for(String itemLine: mainGuiSection.getKeys(false)) {
Material materialType = Material.getMaterial(mainGuiSection.getString("hive-information-item.type"));
int itemAmount = mainGuiSection.getInt(itemLine + ".amount");
String itemName = cadiaBees.colorUtil.color(mainGuiSection.getString(itemLine + ".name"));
List<String> mainItemLore = mainGuiSection.getStringList(itemLine + ".main-lore");
List<String> upgradeItemLore = mainGuiSection.getStringList(itemLine + ".upgrade-lore");
alright back to the old method then.
But like
I also recommend you make a class for parsing items out of configs
You are reading that maybe once?
So in that case a stream is beneficial since it reduces boilerplate
It's more about maintaining consistency
Nothing to lose
stream won't reduce that much boilerplate
Consistency?
like
if you only show him streams because of this specific instance
man will figure out that streams are fine to use everywhere
Not really
if you stick to for loops everywhere, sure it may have that tiny extra boilerplate but he'll get used to for loops everywhere
I dont see your point here honestly, streams are fine in bootstrap cases certainly, knowing both is good generally, nothing here implies they ought to use it everywhere nor nowhere
I mean sure you dont see the fuck ton of extra objects the jvm creates depending on stream pipeline operations which is a downside sometimes, but that just shows us that streams should not be used everywhere
With this code do I seriously need to make a functional interface?
public static void check() {
new UpdateChecker(NeoPerformance.getInstance(), 103183).getVersion(version -> {
return isUpToDate(NeoPerformance.getInstance().getDescription().getVersion(), version);
});
}```
the Function functional interface already worky
I don't see your problem
I thought my answer solved your issues but you're still stumbling around
Replace your Consumer<String> with a Function<String, Boolean>
your done
yay I'm done

๐ฅฃ
the isCooled method, how does that work?
the cache automatically removes stuff
so isCooled just checks if the cache contains the key
yea, and it returns true if it doesnt contain the key?
...
sorry, if im tired, its 3 am and im trying to finish ๐
copilot inverted it lmao
ok
invert that statement
rename isCooled to isInCooldown or something
for a clearer naming
So what I understand is the consumer doesn't return any value, I need the lambda express to retrieve the version. So change it from a consumer to something else, getting its return value and then passing that to my isUpToDate Util will do the trick?
A function is a consumer that has a return value
Function<Player, Boolean> isFlying = (player) -> player.isFlying();
boolean flying = isFlying.apply(player);
Apple
shutup
๐ฆ
that's a lil harder to explain
Thanks, maybe next treat me less like an idiot and more like someone that is learning.
im getting "Expression expected" for this line of code:
if(player.hasLineOfSight(target) && target instanceof LivingEntity && !target.isDead() && target != player && target != ArmorStand) {``` anyone know solution?
how do i fix this error now again "java.lang.NullPointerException: Cannot invoke "com.cradlenetwork.CradleAbilities.Main.getConfig()" because "com.cradlenetwork.CradleAbilities.Dranwen.DranwenEvents.plugin" is null"?
show code
Show the screenshot of the ide error
figured
ArmorStand isnt a valid thing to check against
its not your statement thats the issue, its the ArmorStand
Thats not how you check if something is an armor stand
you either check the entity type of check of the Entity is a instanceof ArmorStand
also mixing like 5 boolean checks in one if is messy
and can lead to debugging issues
its better to use guard clauses
its alot smaller tho
what is that?
i started java like yesterday so i dont know much lol
if (!statement) {
// handling if statement is false
return; // return to prevent from running
}
if (!statement2) {
// handling if needed
return; //return to prevent from running
}
// now that all checks have ran execute code
Bukkit.broadcastMessage("Guard clauses checked!");
a lot easier to debug, and detect issues with