#help-development
1 messages · Page 1493 of 1
Since getrawSlot returns the actual slot number.
when u have two inventories it return 0 for top and bottom for the top left slot if using getslot XD
Bstats ?
bStats?
No
bStats doesn't require bungeecord
U get bstats by default on Ur spigot server
LOl
Cuz I always see bstats folder in there
How can I turn off the display of notes when interacting with a note block, but allow it to be destroyed?
PlayerInteractEvent cancelling and BlockBreakEvent, because PlayerInteractEvent calls before BlockBreakEvent
NotePlayEvent ?
@EventHandler(priority = EventPriority.LOW)
public void onInventoryClick(InventoryClickEvent e) {
String Title = e.getInventory().getTitle();
if (e.getSlot() == -999) return;
if (e.getCurrentItem() == null) return;
if (e.getCurrentItem().getItemMeta() == null) return;
if (e.getCurrentItem().getItemMeta().getDisplayName() == null) return;
if (e.getClickedInventory() == null) return;
if (Title.equals(coloredChat.chat("&8My Profile"))) {
Menus.MyProfileActions((Player) e.getWhoClicked(), e.getSlot(), e.getCurrentItem(), e.getInventory());
e.setCancelled(true);
}
}```
It's not working
it does. Tho I have no idea if that would also cancel the particles
that cancelling and right click, and left click?
hmmm
guess that isn't what you want tho
How can I access an offline player's ender chest given I have their UUID?
don't think that is possible with the API
I still got error
probably fix it.
check this source
https://github.com/jikoo/OpenInv
he said check if slot is -999 returns it
but its not working
thank you
YOU ARE FUCKING GENIUS! Thank you
sweet
It's working now lol
ty guys
how i can detect pressing left/right click on block?
interact event
PlayerInteractEvent detects only clicking
it detects both
i need pressing
there is no such information relayed through the protocol
for holding left-click, you may be able to use the block breaking animation packets
but there is no api way
ah, right, protocols. Block digging.
for right click, there is nothing
the client just sends a new click packet every x milliseconds
you can try to listen to them and keep track of the time and try to guess whether the button is still held or not
but it won't be super accurate
i'll detect only left click
right click already working with PIE
Sorry for asking again but PlayerDropItemEvent it's not working
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
if (e.getPlayer().getInventory().getItemInHand() == null) return;
if (e.getPlayer().getInventory().getItemInHand().getItemMeta() == null) return;
if (e.getPlayer().getInventory().getItemInHand().getItemMeta().getDisplayName() == null) return;
if (e.getPlayer().getInventory().getItemInHand().getItemMeta()
.getDisplayName().equalsIgnoreCase(coloredChat.chat("&aMy Profile &7(Right Click)"))) {
e.setCancelled(true);
}
}```
what are you trying to do?
I don't want to players drop item
don't call getitemmeta multiple times
each get is a deep clone of the whole thing
which can be profusely expensive for more complex items
Oh
You are only checking the players item in hand
I didn't know that
Yes i think
the player can drop more items than just the item in their hand
he is check-coding freak
pressing the drop-item on a stack in an inventory drops it
clicking outside the inventory with a stack on the cursor drops it
So what would i do
I did?
if you want to prevent all drops, just cancel the event
try e.getItem().getItemStack(). Not getItemInHand
like I just explained
Okay
there are more ways to drop shit than hold it in your hand
the dropped item is not necessarily in your hand
nor is there any guarantee that at the time of the event firing the item is still in the hand
Yeah
In Inventory
it could be drag drop, pressed Q
package index
also combine the conditions
is there no way to make that more efficient?
Just don’t call it multiple times
making it more efficient could be achieved with like a 2-3 line change to the ItemStack class
or, no, that's actually for equals/issimilar/hashcode efficiency
with the way how itemmeta and itemstacks are laid out currently, there isn't any good way to make the get not clone the meta each time
you just need to be mindful of only calling it when necessary
where is that PR NNY 😭
what is api version for 1.16.5?
yes
ty
always just the major release version
I read the Java docs but still doesn't help for me
bad news.
is there a way to respawn a player while hes alive?
I want to do a simple rtp by extending the minecraft's spawn area
1 sec
if (event.getItemDrop().getItemStack().equals(your item)) {
event.setCancelled(true);```
inside the event
Use ItemStack#isSimilar instead
why?
shouldn't really matter but it's more robust
ignores stack size
^^^ does anyone know?
if he's alive then teleport
I need randomly teleport
Not working
Show some actual code you are using, as "not working" tells us very little.
did you reference your item in equals(your item) ?
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
if (e.getItemDrop().getItemStack().equals(coloredChat.chat("&aMy Profile &7(Right Click)"))) {
e.setCancelled(true);
}
}```
he said use this
not mine
no he didn;t
wait wtf
what is coloredChat.chat?
you are comparing an ItemStack to a String
e.getItemDrop().getItemStack() returns ItemStack
coloredChat.chat("&aMy Profile &7(Right Click)") returns String
itll always be false
would not have happened with isSimilar:>
lol true
What about now?
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
if (e.getItemDrop().getItemStack().equals(("§aMy Profile §7(Right Click)"))) {
e.setCancelled(true);
}
}
Why not get the item in a different way rather than display name?
still wrong?
Like the slot or type?
bruh did anything even change???
smh
Do you know what an ItemsStack is and what a String is?
if you want to
you can do
if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals("BLUH")) {}
What about now?
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
Player p = e.getPlayer();
ItemStack Item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta Meta = (SkullMeta) Item.getItemMeta();
Meta.setOwner(p.getName());
if (e.getItemDrop().getItemStack().equals(Item)) {
e.setCancelled(true);
}
}```
bruh
No
We agree
learn that first probably
before heading into spigotMC
I know java a bit
youll save yourself a lot of time
You know a little. You need to know more
if you learn java first properly
java tutorialspoint
Or order a book
youtube tutorials are bad tbh
Yup
even knowing how to program they managed to confuse me
LMFAO
In this video (Part 1 of 932) we show you how to create an integer in C++.
Me too lol
I didn't know it was a bad idea
Atleast got me interested
its not
@quaint mantle Why can't you just do smt like this:
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
if (e.getItemDrop().getItemStack().getType().equals(Material.WHATEVERMATERIALITIS)) {
e.setCancelled(true);
}
}```
it means read teh javadoc to see if there is an alternative
PlayerPickup has been replaced with EntityPickUp
because you dont want to use any item for that
thanks
EntityPickupItemEvent *
Is there an event for time skip after sleep?
or a way to have a fake player in the server so there wont be time skip when sleeping
🙏 thanks
make all beds explode on bed enter event
random teleport players when entering a bed
ban the player when entering a bed
That would fix it for sure
is there actually an event that gets called when the consolesender is dispatching a command or smt?
couldnt find one
No
fuck
There's only on command
yeah, the PlayerPreProcessCommandEvent or smt
No
huh?
well... there's ServerCommandEvent... maybe that works
That does both player and console
I think
I don't think CommandEvent is documented but I'm sure it's a thing
i hope so
i mean, all i basically want is getting when i send a message from my discord console
what problems do you encounter with 17 ping?
marginally
and my upload is trash
also, pinging requires 2 parties
Lol
trash upload is industry standard
oh wow
your ping depends solely on whom you are pinging
this is really trash
ping your localhost and you'll get 0ms
damn
LIE
ping something across the globe and you're bound to get 50+ on minimum
1ms
depends on rounding
xd
89ms
generally 0-1ms
imagine 89ms to brain
My mom's network is shit
O2 is shit
most times, i dont even have internet
just get your own contract if you don't like the one you get for free
because they do maintenance and stuff
it's not like they cost anything
because vodafone literally only has broken cables
yes, but negligible sums
i pay like 35€ per month for this trash
Hang in let me test again I'm in a good signal area now
i mean, in normal case i could say okay, i dont wanna be at vodafone anymore, theres a reason, please fuck you. but they have the right to say:
noooo, you stay with us. i mean, we give you a free month, but you cannot leave lol
what should i do with a free month or smt, if my free month of internet doesnt work? lmao
feel like they dont care a single bit
nobody does
yeah, but vodafone is worst
literally nobody cares about you or whether the produce they sell you works or what you think about it
We internet flexing now?
the only thing anyone cares about is your money
vodafone's instagram comments are literally only hate
hate, or bot comments
thats says everything
What would I like to have? Internet, telephone and TV, dear Vodafone! For 6 days nothing has happened anymore! The notification of the elimination of problems is extended from day to day. It is also not possible to tell whether work is being carried out on the fault at all. Neither your service number nor your WhatsApp service bring anything! Finally take care, otherwise you will soon have a few fewer customers.
vodafone in a nutshell
they don't care about what you say
ofc they dont
they don't care about your reviews because nobody who doesn't use their service reads them anyway
vote with your money
it's the only power you have in this world
start your own service
Lol
i mean, i probably will go with my lawyer against that dumb shit
Oof speed test VPN is shit
you cant tell me they can go away with such shit like free months if their internet doesn't even work
they have an army of lawyers
you will either lose or win a phyrric victory and it'll cost you several months or years of time and effort
yes, but after how long of a process
4-5 months?
not worth a few dimes
if you already lost your main income and can't afford the $35 bill, you definitely can't afford the process
and if it does backfire, you are royally fucked
I wanna dick measure internet too!
would you look at that
someone who actually links the image rather than the webpage
impressive
wtf is this Wrong location for EntityIronGolem['Iron Golem'/1636, l='world', x=145.51, y=65.25, z=188.54] in world 'world'!
what does this mean? new ItemStack[0]
show code?
in CreatureSpawnEvent i teleport the entity, only this
[] indicates an array
and the zero in it?
google "java arrays tutorial"
zero is the size of the array
ive just seen this
ItemStack[] inv = items.toArray(new ItemStack[0]);
made me confused
List<ItemStack> items = new ArrayList<>(); // initializing the future itemstack array
for(String key : cs.getKeys(false)){ // iterating over the saved keys (itemstacks)
Object o = cs.get(key); // getting the object, String (if empty) or ItemStack
if(o instanceof ItemStack) items.add((ItemStack)o); // if correct itemstack, adding it into the list
else items.add(null); // not an ItemStack, adding null
it's fairly straight forward
but you need to know some things about java and how java does arrays and generics
the zero is the capacity of the array. the reserved place in the heap
basically, don't worry about it for the time being; items.toArray(new ItemStack[0]) just converts a List<ItemStack> to an ItemStack[] itemstack array
you won't understand why you need to pass it a new ItemStack[0] until you get into generics and shit
alright... so is this ok?
ItemStack[] playerInventory = savedItems.toArray(new ItemStack[0]);
player.getInventory().setContents(playerInventory);```
probably
yup
depends on whether your savedItems has the right size and order
but code-wise, it's fine
I dont understand the logic but ill go with it
What logic
new ItemStack[0] is an array constructor, it constructs an array holding elements of type ItemStack, of size 0
due to generics fucknuggetry, you need to pass a list an array of the correct type in order to convert it to an array
since due to type retention it can't actually figure out the type of array it should return by itself
of course that's all nonsense for you if you haven't gotten into generics yet, so just don't worry about it
alright, thanks
hi, to add money in a user balance having vault has a dependencie of my plugin is .deposit?
ok so it wont work
public List<ItemStack> getYamlPlayerInventory(String playerName){
File file = new File(deathGhost.getDataFolder(), playerName + ".yml");
YamlConfiguration yaml_file = YamlConfiguration.loadConfiguration(file);
ConfigurationSection inventory = yaml_file.getConfigurationSection("Inventory");
if (inventory == null){
return new ArrayList();
}else{
List<ItemStack> items = new ArrayList<>();
for (String index: inventory.getKeys(false)){
Object item = inventory.get(index);
if(item instanceof ItemStack) items.add((ItemStack)item);
else items.add(null);
}
return items;
}```
List<ItemStack> savedItems = dataManager.getYamlPlayerInventory(player.getName());
ItemStack[] playerInventory = savedItems.toArray(new ItemStack[0]);
player.getInventory().setContents(playerInventory);```
nvm my bad had a typo
that's the new maven project dialogue
does it mattr what iput
Can someone help me with an error in intellij?
what error
nobody can help you with an error if you don't give any information about it
I had an error when i was trying to install amazon corretto, i fixed it by invalidating cache
How can you determine that this is a specific inventory? For example, in one menu invetnore I have some actions on when I click on the slot, and in the other, others. Right now I'm using event.getView().GetTitle().EqualsIgnoreCase(inventory name) for this
are there any more ways?
Don;t use title, use the instance. getView().getTopInventory().equals
can someone help please? i'm watching a tutorial on how to make an inventory (https://www.youtube.com/watch?v=dEwv7ay1RCI&list=PLDhiRTZ_vnoUvdrkTnaWP_hPmbj2JfPAF&index=8&ab_channel=TechnoVisionTechnoVision)
but i have come across a problem
CODE: (inventory is red)
else if (cmd.getName().equalsIgnoreCase("delivery")) {
player.openInventory(LudicrousyInventories.inventory.getInventory());
}```
CODE: (in other calss)
```java
@Override
public Inventory getInventory() {
return inventory;
}```thanks in advance!
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
^^
i watched a 2 hour and a half video on the basics of java
i didn't know what to do after it so now i'm just doing trial and error
Well you should know that isn't how you access a (non-static) method then
if it's in the inventory class just do this.getInventory() or getInventory()
I'm dumb! Are there examples of how to use this type?
it's in another class
Alr does the class extends the other class
No
Just making sure
what does that mean
._.
what? i am new to java
Please learn Java basics
and i'm used to skript
i have!
Do u not know about abstract classes well anyway it's ClassName.method(args)
You wouldn't be asking these questions if you did
no, the tutorial just didn't include this
Uh sounds like a bad tutorial
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.
Follow these
olivo please, stop helping. thanks!
xd
i'm not kidding
Anyway I told u the syntax
i'm not sure i understand how to use it
If u actually have a instance of that class u can do classInstanceVar.method(args)
what's an instance
oh god
Bruh
Did that tutorial even teach you anything
yeah
Doesn't look like it
my memory isn't quite the best
I mean we've done our best. idkidk123123 has told you the exact awnser
AClass classInstance = new AClass(parameters);
Is how you instance classes lol
Lol
But hey at least that won't be possible to copy paste
could you explain how that works? i want to learn for next time
U need a constructor to instance a class tho but go learn java
olivo i recall asking you to stop helping
Bro I just sent the awnser to your question
no you told me yet again to learn the java basics
i find nothing funny in an insult
That link is the awnser to your question
ok can i get literally anybody else to help me?
help isn't good help if it comes from a bad place
no, both of you are being mean
you just said i learnt nothing
Cuz u did
and olivo keeps telling to learn the basics even though i said i did
Yeah you didn't hence why I told you to follow a better tutorial
Do another tutorial that tutorial u had was bad it didn't teach anything
You don't learn a programming language in one day. It takes time and patience
it took me like 3 days even though it was a 2 hour and 30 minutes tutorial
so... checkmate?
It takes like 2 weeks to learn java a year or More for full java probs
You never stop learning that's the way it goes
yeah but we're talking about the basics
But u need to learn more
Read a basic java tutorial
what is going on
Help with what. No one is going to give you a better awnser than a direct link to your question
@zealous hearth someone's being a ||dickhead||
its got a red underline because its telling you there is an error. hover over it and see what its says, then you can correct it
i did, it doesn't really mean anything to me
He doesn't know what an instance is and is trying to do static access on to an instance method
I know
However he refuses to read the guide about objects I sent ;/
?learnjava @lean gull
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.
elgar do you know how to help?
He needs to learn OOP as its the basics of Java. But until he learns to read his errors he'll get nowhere
Yes, read the error and google it until you understand what it is telling you.
I think everyone should just loose hope on this kid it's not worth it
Floofsy what they are saying is right. Spend more time learning about java. It may seem insulting but trust us, you'll save a lot of time in the long run when you actually know what to do
in a very mean way
And u said my stupid brain can't handle this crap
i said that when exactly?
Learn java basics
nonono wait
i wanna know when i said your brain is stupid and can't handle this
because i have no recollection of that
"you don't understand" = "your brain is stupid and it can't handle this"?
Yes it's the same thing
well then clearly you don't understand :P
It is the same kinda
Not exactly
But it's similar cuz if you don't understand this Ur stupid
I wouldn't say stupid, but rather ignorant to the advice to learn java
Player p = (Player) sender;
Material item = Material.POTION;
ItemStack pot = new ItemStack(item);
Inventory inv = p.getInventory();```How would i give a player a splash pot of healing 1.8.8?
what does description do in command sections in plugin.yml
u might want to do it by id instead of Material.POTION as that might give u more control over that
how is Location#getDistance(Location) actually measuring distance? like for example if i compare two blocks on the same line (left on the pic), it's obvious. but how is this working for example in the right side of the pic? if the blocks are not on the same line, same height, and etc
oh
how would i dod it by id
good to know 👍
new Potion(PotionType.REGEN)
i dont think theres a location.getDistance
there is
oops wrong reply
to see the distance between 2 loc's
idk actually do it like fourteenbrush said idk if that works tho
The distance AB between two points with Cartesian coordinates A(x1, y1) and B(x2, y2) is given by the following formula:
Ye
Well you were wondering how it does it
si this is static abuse right?
a²+b²=c² ?
and its bad
pretty much i think
just pythagoras?
That's for 2d
Player p = (Player) sender;
Potion pot = new Potion(PotionType.REGEN);
Inventory inv = p.getInventory();
inv.addItem(pot);```Like this?
ah
it says on that page AB=(x2−x1)2+(y2−y1)2+(z2−z1)2 so is AB like x and y?
i would probably consider everything as static abuse that is made to simply access it easily lol
ow yes i learned somewhere at school
but thats personal
AB is the distance
oh but what could u name it distanceX and distanceY?
basically all i wanted to know is:
does it go like
o-------
|
|
-----------o
or more like directly via diagonal line
but it works
sure it works
after 6 hours
If it's just 2d use the pythagorean theorem otherwise use the formula I sent
but it's bad
i have no clue how formulas work ahhhhhhh
But that's basic math?
is it impossible to actually return two things in java without making a class with two variables using those or returning a array lol
if you ask me hey, what is 100+300 i can easily say obv, 400
but if you would for example ask me what is 7*8 i couldn't do that within like 20-30 seconds
and now imagine i have to read formulas and shit
i made a GUI but when i execute the command to open it, it sends internal error
ez
Send the error
send the code
That too
https://en.wikipedia.org/wiki/Dyscalculia
there you go
Dyscalculia () is a disability resulting in difficulty learning or comprehending arithmetic, such as difficulty in understanding numbers, learning how to manipulate numbers, performing mathematical calculations and learning facts in mathematics. It is sometimes informally known as "math dyslexia", though this can be misleading as dyslexia is a d...
u probs did something wrong
this is my first gui, i don't want it to be stolen >.<
if its your first gui
no one wants it
haha true
Looking to hire a Server Manager.
Paid Postion
PM me if interested!
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
i can do complicated math in my head it just takes forever for me to process it XD
public void TestEvent(PlayerAdvancementDoneEvent event){
Player p = event.getPlayer();
p.getInventory().addItem(new ItemStack(Material.NETHERITE_PICKAXE));
}``` I want to add only one pickaxe but it adds while advancement is on the screen.How can I solve this?
what are u making
basically veinminer for trees
Hey, I want to get players from a command after the command is executed : Exemple : /team join [TeamName] @p
And I want to get something like "team join [TeamName] [PlayerName]"
Timber plugin?
Is that possible?
Idk but maybe make a hashmap with a player and a boolean to check if the player already has the pickaxe
not plugin, but function, yeah
so what? i have a working timber lmao
so can anybody help?
yes it is
?
player.perfomCommand
grammar lol
Perform command event is processing before the command
also, that plugin makes ads for bisect-hosting. so i would basically not get it lol
you can use args to check the [TeamName] for example
but you need something else, a team is something that you create
add each player to a list
theres probs another timber plugin this is just one i found
for example team1[and all players here]
yeah sure
no if you dont send what we requested
Since you might need some help understanding the formula let me explain it for you.
AB is the distance between the two points A and B.
A = (x1, y1, z1)
B = (x2, y2, z2)
(Just the cordinates)
AB = root of (x2−x1)^2+(y2−y1)^2+(z2−z1)^2
Using the built in java math library you can replace ^2 with Math.pow(<replace this with the number from inside the parenthesis>, 2)
When you've done that take the result from each of the values and combine them and use Math.sqrt to get AB
Hope I explained this well enough ;/
@sullen dome
I tested and it seems that i cannot get players, only @p
use Pythagore theorem
using dyscalculia lol
You don't have to understand what it means just try to translate it in to code and the computer will take care of the rest.
🙄
Player p = (Player) sender;
Potion pot = new Potion(PotionType.INSTANT_HEAL, 2);
Inventory inv = p.getInventory();
inv.addItem(pot);```How would i ive the player a potion
Its something like this https://paste.md-5.net/yalonulege.cs
What i want is to get player name instead of the selector. Exemple : someone is doing /team join testTeam @p, i want to get the player selected by the @p, is that possible?
Player p;
p.getInventory().additem(yourItem);
but its a potion
yes?
oh that way
What spigot version are you on?
give them the potion
Perfect that means you can use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#selectEntities(org.bukkit.command.CommandSender,java.lang.String) to translate the selector in to a list of entities
well you're litteraly doing it on the last lines
It cant resolve the method
do formulas help me measure this fucking motherfucker-trees? xd
they always spread like fuck
If you are messuring the size yes ;/
you can check if the blocks next to it are the same type as the chopped wood?
anyone know why the last line makes it send internal error and stops the function from working?
ItemStack blackStainedGlassPane = createItem("", Material.BLACK_STAINED_GLASS_PANE, Collections.singletonList(""));
for (int i = 0; i <= 54; i++) {
inventory.setItem(i, blackStainedGlassPane);
}```
i mean 2nd last
Out of bounds
Remove the =
Nice, so I just use this function and it will 100% of the time give me the same selected entities than the command?
there wouldn't really be a BlockFace for (y + 1, x + 1) for example
createItem is a function to create items with a name, material and lore
do int i = o i < inv.getSize
inventories max at 53 since it starts a 0
ohhh
public double distanceBetweenPoints(float x1,float y1,float z1,float x2,float y2,float z2) {
return (Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2)+Math.pow((z2-z1),2)));
}``` this?
alright, thank you!
and i work with blockfaces lol
Yea xd
But you can't return a value in a void method
float right i think it probs would be a float lol
i guess thats itemmeta
item meta does
double or float
seems like both does
so? item has Meta
Meta Has enchantments?
yes
double
oh
ok thanks!
Oh and is there an event called after the command is processed? Right now i'm using ServerCommandEvent but this event is called before the command is done
There isn't could you explain why you need that?
[18:00:34 ERROR]: Could not pass event BlockBreakEvent to SurvivalCore v1.0-SNAPSHOT
java.lang.StackOverflowError: null```
all i wanted, joke
rip
lol StackOverflow
oh god, and i know why
Nevermind with the selectEntities it should be good.
no wait, nvm, i did
does this works?
ItemStack potion = new ItemStack(Material.POTION(PotionType.INSTANT_HEAL, 2));
p.getInventory().addItem(potion);
its for @plucky comet
But that's not how you do it
;/
whats the problem?
package index
declaration: package: org.bukkit.potion
It's ```java
new Potion(PotionType.INSTANT_HEAL, 2).toItemStack(1)
declaration: package: org.bukkit.potion, class: PotionData
i get method call expected
Use this @plucky comet
LMAO i did ```java
class Main {
public static double distanceBetweenPoints(float x1,float y1, float z1,float x2,float y2,float z2) {
return (Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2)+Math.pow((z2-z1),2)));
}
public static void main(String[] args) {
System.out.println(distanceBetweenPoints(0,0,0,1,1,1));
}
}``` it gave me 1.7320508075688772 is that meant to happen
Math.round or something
Well yeah
is that correct or no
sqrt(3) = 1.73...
yes
lol
why .toItemStack() ?
Because that's how the Potion object works
It's depricated any way and shouldn't be used in newer versions
aah then say that XD
Since he's on 1.8 it's fine
just saying it's deprecated was enough for me XD
In newer versions you use PotionMeta
Just cast item meta to it and add your potion effects
i sometimes have 69 fps in 1.17
?paste
Hello! Atm i currently use this code to make an api request however i feel it may not be that efficient - i wondered if anyone could have a look over it 😄
ParameterBuilder is normally in a different class
int amount = Integer.parseInt(args[1]);```What will this return if its not an int
NumberFormatException – if the string does not contain a parsable integer.
how do i handle that is there like try and excepts
You come from python?
ye
Ahh, i see
so in java we have try / catch
eg:
try {
int amount = Integer.parseInt(args[1]);
}catch (NumberFormatException exception) {
exception.printStackTrace();
int amount = 0;
}
ooop
You’ll want to declare the variable before the try catch
Also you shouldn’t really be relying on an exception to determine if it’s a number
printStackTrace does not really matter
or use optional
sorry but was just trying to show them everything that they could do
yes - declare b4 the try
and the printStackTrace was just to show them how
please how do I delay ticks
it does not run the code in "public void run()"
however it does tp me to "location"
it is supposed to wait 10 ticks
Cannot resolve method 'scheduleSyncDelayedTask(com.Crota.sylv.events.events, anonymous java.lang.Runnable, long)'
it has to be a plugin
precisely. It requires a plugin instance.
you cant pass in an event class
so use dependency injection where you pass the plugin through your constructor (preferebly), or use a static instance
or use JavaPlugin.getPlugin(yourmainplugin.class)
ok thanks
then again, I did say to use dependency injection preferebly
do you know what that is?
nope, not at all
here's an example
public MyTaskClass {
private final MyPlugin plugin;
public MyTaskClass(final MyPlugin plugin) {
this.plugin = plugin;
}
}
and MyPlugin would be your plugin class
then, when you want to initialize an instance of the class, use new MyTaskClass(...) and pass in your plugin instance in the 3 dots. For example if you were doing this directly in the plugin class you would use new MyTaskClass(this)
as it points to the current plugin instance
That was an example
So you just straight up copied and pasted that ._.
is myPlugin your main class?
is that supposed to be the name of my class?
no I typed it out
No, it was an example
then again, it is strongly recommended you at least learn some basic inheritance in Java first
before actually coding plugins
idk that much java
?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.
start with some of these links
private void cutDownTreePart(Player player, Block startBlock) {
if (isLog(startBlock) || isLeave(startBlock)) {
startBlock.breakNaturally();
for (BlockFace face : blockFaces) {
Block newBlock = startBlock.getRelative(face);
Block newBlock2 = startBlock.getRelative(face).getRelative(BlockFace.UP);
Block newBlock3 = startBlock.getRelative(face).getRelative(BlockFace.DOWN);
if (isLog(newBlock) || isLeave(startBlock)) cutDownTreePart(player, newBlock);
if (isLog(newBlock2) || isLeave(startBlock)) cutDownTreePart(player, newBlock2);
if (isLog(newBlock3) || isLeave(startBlock)) cutDownTreePart(player, newBlock3);
}
}
}
you guys have an idea, why this isn't including leaves? it breaks all logs, but not one single leave
Why my event is not working?
@EventHandler(priority = EventPriority.LOW)
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
ItemStack itemStack = e.getItem();
e.setCancelled(itemStack != null && itemStack.getType().equals(Material.SKULL_ITEM) && itemStack.hasItemMeta() &&
itemStack.getItemMeta().getDisplayName().contains(coloredChat.chat("&aMy Profile &7(Right Click)")));
}```
did you register it?
one sec
yes
public Listeners(LonelyPlugin pl) {
Bukkit.getPluginManager().registerEvents(this, pl);
}```
new Listeners(this);
@paper viper
private boolean isLog(Block b) {
return (b.getType().equals(Material.OAK_LOG)
|| b.getType().equals(Material.ACACIA_LOG)
|| b.getType().equals(Material.BIRCH_LOG)
|| b.getType().equals(Material.DARK_OAK_LOG)
|| b.getType().equals(Material.JUNGLE_LOG)
|| b.getType().equals(Material.SPRUCE_LOG)
|| b.getType().equals(Material.CRIMSON_STEM)
|| b.getType().equals(Material.WARPED_STEM)
|| b.getType().equals(Material.STRIPPED_OAK_LOG)
|| b.getType().equals(Material.STRIPPED_ACACIA_LOG)
|| b.getType().equals(Material.STRIPPED_BIRCH_LOG)
|| b.getType().equals(Material.STRIPPED_DARK_OAK_LOG)
|| b.getType().equals(Material.STRIPPED_JUNGLE_LOG)
|| b.getType().equals(Material.STRIPPED_CRIMSON_STEM)
|| b.getType().equals(Material.STRIPPED_WARPED_STEM)
|| b.getType().equals(Material.STRIPPED_SPRUCE_LOG));
}
private boolean isLeave(Block b) {
return (b.getType().equals(Material.OAK_LOG)
|| b.getType().equals(Material.ACACIA_LEAVES)
|| b.getType().equals(Material.BIRCH_LEAVES)
|| b.getType().equals(Material.DARK_OAK_LEAVES)
|| b.getType().equals(Material.JUNGLE_LEAVES)
|| b.getType().equals(Material.SPRUCE_LEAVES)
|| b.getType().equals(Material.WARPED_WART_BLOCK)
|| b.getType().equals(Material.NETHER_WART_BLOCK)
|| b.getType().equals(Material.SHROOMLIGHT));
}```
could be made with enum's and stuff, i know that
where is that?
holy shit
Ok dude there is quite a bit you can improve here
lmao
- Material is an enum. You don't have to use .equals. Just use
==
- Store all the types into an
EnumSet
instead of having like 20 or statements
where is what
maybe i'll do. but you get what these methods do.
this is constructor
could you like send the full code
for the main class and event class
?paste
so now ignoring because i dont do what he wants lol... love it lmao
How am i ignoring you
lmfao
I will less want to help you if you have that attitude
Tbh, I would ignore you if you ignored the question...
not you
ok
me?
Tag.LOGS.isTagged(block.getType())
^^ also Tag.LEAVES
Idk. Who ever ignored the question. xD
can you make sure the event is being executed?
so what should i do
are you trolling me?
didnt even knew that exists lol. thanks
Its working
that makes it really quite simple
I mean it registerd
tho, i dont think LEAVES includes the nether-tree-leaves?
but not working
to disallow a player to move an item called "My Profile"
Tag.WART_BLOCKS exits
but i doubt you would use PDC anyways...
so use slot ids
instead of checking names
What's PDC?
PersistentDataContainer
basically you store nbt in a item
you can retreive data from it
Hello, I have a problem for my Custom Chat Event. It is not working, someone can help me ?
send the code
public class CustomChat implements Listener {
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent e) {
Bukkit.getServer().getPluginManager().callEvent(new CustomChatEvent(e.getPlayer(), e.getMessage()));
}
@EventHandler
public void onCustomPlayerChat(CustomChatEvent e) {
Player player = e.getPlayer();
if(!e.isCancelled()) {
for(Player onlinePlayers : Bukkit.getServer().getOnlinePlayers()) {
if(onlinePlayers.getWorld().getName().equals(player.getWorld().getName())) {
onlinePlayers.sendMessage(player.getName() + " : " + e.getMessage());
}
}
}
}
}
what is CustomChatEvent
public class CustomChatEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Player player;
private String message;
private boolean cancel;
public CustomChatEvent(Player player, String message) {
this.player = player;
this.message = message;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public boolean isCancelled() {
return cancel;
}
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
public Player getPlayer() {
return player;
}
public String getMessage() {
return message;
}
}
Okay sorry, I do that
all g
private boolean isLog(Block b) {
return Tag.LOGS.isTagged(b.getType());
}
private boolean isLeave(Block b) {
return Tag.LEAVES.isTagged(b.getType());
}
so... are you good now? lol
I think you should use AsyncPlayerChatEvent
I dont think there is a need to create an extra event class here
you can just directly listen to the AsyncPlayerChatEvent event
then you should be okay
Yes but i want to do my Custom Chat Event because I want to separate world chat
ic
Hello! I am currently needing to access an API from my code however i would like to make it as fast as possible:
https://paste.md-5.net/icepixituw.js
i am not really experienced with this tho - wondered what i could improve if anything?
But in the chat there is nothing when i send a message ? Why is it not working ?
perhaps try putting it in another class?
the customchatevent
you cant really optimize web connections
like in your case, i doubt much can be done
Okay, so I have to create another class and past my customchatevent code ?
Yeah try that
Okay, i try that
make sure to register it too
i guess the main bottle neck is just the request getting there and being processed and getting back?
What's the best way to check if a block is a button? (Any button)
Yeah
Gson may also be a bit slow
ill as some sysouts and have a look
ty
oh lmao
if(Tag.BUTTONS.isTagged(block.getType()))
My plugin is named CustomChat, is it possible that my problem come from the name of the plugin ?
No
Okay
then it probably wouldnt even get enabled, if the name would be an issue
To my knowledge, you never registered your custom event handler.
wtf
?eta
There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
oh dude
?1.17
There is no ETA for 1.17. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
i feel like some people really cannot read right
?ban @wintry blaze chill with the troll
Done. That felt good.
oh wow
thank you
i was right before pinging someone lol
wouldn't a kick be better for spam tho?
oh god
?ban @quaint mantle
Done. That felt good.
i never said anything
oh wow
oops forgot reason
I wonder who got the ban 😂
doesnt matter i got
meh, noone is going to miss them
it was a troll so we should be fine
i think*
do you know a faster one lmao - everyone keeps saying gson
What's the point of spamming
he wants to me someone lol
he probably wanted us to think "omg, he's so cool for spamming"
idk people are weird
I changed my class name with ChatCustomEvent but now a message is sent but it's the normal message and not the custom chat
Aww, bot got it before me
lol
People don't have a life
yea
lmfao
Like me 👀
thats why i hate humans
So you hate yourself too?
yea
😅
lol
this is why i identify as a problem instead of a human XD
much humans are just dumb. and just hating everything and everything is pretty much fixing that issues
i found a memory key in the spigot api i like
i identify as a army helicopter to be fair
UNIVERSAL_HATRED
lol
I hate events
only difference is... i can't fly tho
what's wrong with this?
@EventHandler(priority = EventPriority.LOW)
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
if (e.getItem().getItemMeta() == null) return;
if (e.getItem().getItemMeta().getDisplayName() == null) return;
if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase(coloredChat.chat("&aMy Profile &7(Right Click)"))) {
e.setCancelled(true);
}
}```
probably i would more be like a broken army helicopter
There are more than dumb people in the world. Just the dumb people scream louder than the rest. Many people keep the human race alive, like farmers.
you're calling the getitemmeta several times again
that is going too be absolutely horrible
getitemmeta.. it took me a sec to get the meaning of that lol
inventory move item event is called for every individual item that gets moved by hoppers
which is potentially an enermous amount of items
now you're cloning the itemmeta 3 times for each such operation
Is it only for hoppers?
yes
oh
who except players can actually call the InventoryClickEvent?
thats why its not working
a player puts a shulker box full of books in a hopper
and this code kills the server
probably villagers maybe?
player is the only humanentity in the standard server impl and environment
Is there any events like InventoryMoveEvent but for players
tho, why isn't the even instantly refering to the player, but HumanEntity instead?
it reflects how it's done under the hood in nms
so, mojangs fault?
i mean doesnt player extend HumanEntity
what am i looking at
how i can clear Pathfinder b field?
timber
You're looking at Discord
😎
bField.set(c.goalSelector, new UnsafeList<PathfinderGoalSelector>()); is deprecated for 1.16. I need:
bField.set(c.goalSelector, SOMETHING_WHAT_I_DONT_KNOW)
oh god. nms ahhhhh
yup. custom NPC Library.
i'm not seeing any difference between leaves and logs in your code, beyond the involved tag itself
nms always hurts me awful
consider merging the two tags into an enumset and using a queue
thats not the problem probably tho
probably not no but this is kind of illegible
i need some fix for my problem ahhhh
i dont get it
(isLog(newBlock3) || isLeave(startBlock))
newBlock3 vs startBlock
is that intentional
lol
👀
we saw everything
😳
we didn't see anything