#help-development
1 messages · Page 209 of 1
tell a man to go learn java and they may become a developer, spoonfeed a man code and they'll call you mommy for a lifetime
i learn well from spoonfeed code
because whhen i dnt understand it
i google
because not understanding makes me anwy
angwy
yes, your manager should hold the List/Map/Set of yoru arenas and the runnable that is going to manage them
i love thread.sleep
How can I store data on an ItemStack that is also stored on the block once it is set?
it's going to be something really simple like java Bukkit.getScheduler().runTaskTimer(plugin, () -> { arenas.forEach( arena-> { arena.tick(); }); }, 20,20);
I missed a )
you said you wanted it to fill a block every second
player can change the seconds for each arena
@eternal oxide is there a way to create send a packet using ProtocolLib that changes the skin of the head in the tab next to the player name, or do I have to use NMS?
so in the tick method of your arena class you have it fill the next block that is required
actually I use TabAPI but I didn't find any methods
Maybe I can find it there?
if it's a question of packet it can be done with TABApi or just ProtocolLib
if nothing else work, well then NMS
idk if that is just math but
I have a variable called ticks
and a Map<Integer, IntConsumer>
what ius love
when the ticks is divisible by the key the IntConsumer is consumed
and the int passed to the IntConsumer is the ticks
and I want to do something like swtich (ticks) { case 0: ...}
how could I fit the ticks into the switch?
you confuse me
?
like
what if the ticks passes 3
like
4
I would like the case 0 to be executed
default
if 5, the case 1 would be executed
oh
if 6 the case 2
Don’t use a switch
if 7 case 3
Use %
then you are going to need modulo
switch (ticks % 4)
better
case 0:
case 1:
case 2:
case 3:
thanks!
Imagine not using java 8
Use a for loop
I already found a solution
Starting download of https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at com.google.common.io.Resources$UrlByteSource.openStream(Resources.java:72)
at com.google.common.io.ByteSource.read(ByteSource.java:296)
at com.google.common.io.Resources.toByteArray(Resources.java:98)
at org.spigotmc.builder.Builder.download(Builder.java:1083)
at org.spigotmc.builder.Builder.main(Builder.java:416)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
sooo
what do i do now
how do set all the blocks to something in a boundingbox
what are you trying to do
Use buildtools
funny
loop the blocks in teh BoundingBox
So, How do I get... the spigot jar then?
?bt
I'm running my way through the spigot plugin tutorial, but i keep getting stuck here.
https://www.spigotmc.org/wiki/create-a-simple-command/#designing-the-command
after adding the suffix implements CommandExecutor i get the error Cannot resolve symbol 'CommandExecutor'. Could i get some help with this?
public class DamageListener implements Listener {
@EventHandler
public void onPlayerDamage(EntityDamageEvent e) {
if(e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
ItemMeta playerTool = p.getItemInUse().getItemMeta();
if(playerTool.getLore().contains("Damage")) {
//nothing yet
}
}
}
}
I started learning this yesterday and I'm not very good with java, how could I read the lore of the tool that the player is holding? For example, if a weapon has lore "Damage " and followed by an unknown number, how could I get that number and store it in a variable?
But then i get a much bigger, and scarier error lool
Class 'firstcommand' must either be declared abstract or implement abstract method 'onCommand(CommandSender, Command, String, String[])' in
Hover and you get the option to implement unimplemented methods
Would always recommend having a good understanding of java before looking at spigot.
Anyway, few ways around this. Either substring after 'Damage' and parse as an int, or using regex. In my opinion it's easier to use a PDC though
That worked, although it added a fair bit off stuff
it should only add one, unless you did something wrong
It imported org.jetbrains.annotations.NotNull;, org.bukkit.command.CommandSender; and org.bukkit.command.Command;
imports are fine
Also, as a sidenote: what you are currently doing is checking if any of the lines of lore match the words "Damage" exactly. You'd need to loop over each line to check that
Yeah I understand, I also understand what you mean by substring and parsing as an int but I'm not sure how I would go about doing that. I'm not too familiar with the other methods you suggested.
It feels like i'm doing something wrong, for every line of code i follow in the tutorial i'm importing something new
imports are fine
welcome to java
ItemStack diamond = new ItemStack(Material.DIAMOND);
required both
import org.bukkit.Material;
and
import org.bukkit.inventory.ItemStack;
Oh okay so this is normal lol
yes
remember that java is just a programming language and doesn't understand the concept of minecraft
so spigot includes these abstractions to make it easier
each import tells that Class what the Object is. ItemStack requires the import so it knows what an ItemStack is
I thought the pom.xml did all that for me, although i just started lol
Builtools is where the error came from
download a fresh copy of BT and try again in a clean folder (not on desktop/OneDrive)
Ok
bit of an oversimplification but the pom tells java that spigot exists, and each import tells java that you are talking about the ItemStack from spigot etc.
Ahhh, i see. Thank you very much
Loop through each line of the lore
strip the chat colour from it if it has some (makes processing it easier)
substring after "damage: "
parse that as an integer, this is your level
wait, does java have a substring after method?
https://imgur.com/a/rfVVUAB
does somebody know how this chatcolor transition is made?
doubt theres a built in method for it, imagine its just made manually using 1.16's custom chat colours
k
Attempting to build Minecraft with details: VersionInfo(minecraftVersion=1.8.8, accessTransforms=bukkit-1.8.8.at, classMappings=bukkit-1.8.8-cl.csrg, memberMappings=bukkit-1.8.8-members.csrg, packageMappings=package.srg, minecraftHash=a0671390aa0691e70a950155aab06ffb, classMapCommand=null, memberMapCommand=null, finalMapCommand=null, decompileCommand=null, serverUrl=null, mappingsUrl=null, spigotVersion=null, toolsVersion=0)
Starting download of https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at com.google.common.io.Resources$UrlByteSource.openStream(Resources.java:72)
at com.google.common.io.ByteSource.read(ByteSource.java:296)
at com.google.common.io.Resources.toByteArray(Resources.java:98)
at org.spigotmc.builder.Builder.download(Builder.java:1083)
at org.spigotmc.builder.Builder.main(Builder.java:416)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
same error when trying to use builtools
Where did you get your buildtools? That address is a 403
?paste your full buildtools.log
nm, it fails for me too on 1.8.8
then MC hosting is down
lol
1.19 seems to be working
probably because it gets it directly from mc
Nvm :)
Is this what you meant?
No errors, just doesn't send the message. Not sure what to do.
getItemInUse() does not return the players current item but an item they are interacting with. The method you are looking for is getInventory().getItemInMainHand()
stripColor returns a new string with the colours removed, so you'd need to assign that to a new variable (unless of course its not needed anyway so you can remove it)
Not something that would necessarily break the code depending on how the lore is set up, but you are checking if the line contains the string "Damage:" but then only taking the substring at 6 characters. If you can be sure that Damage: will be at the start of a line, then startsWith rather than contains probably relays your intent better, but not something that would break the code if it's set up that way
Anyway to negate knockback when a player is using a shield?
Hi, I made a portal using multiverse portals pointing towards my other world named "LoopSpace". I then made a plugin that deletes the world and regenerates it under the same name. My console tells me that when I try to enter the portal that Bukkit lost the world reference, and I am not sure why since it is generated under the same world name. Any help is appreciated!
Here is my error log: https://paste.gg/p/anonymous/6cf3dde9266b4e3fae12c6809303e6da
When you delete teh world and create a new one, it has the same name, but it is still a different world object
Still no errors, doesn't send the message.
ah yes missed that the first time
e.getEntity() on entitydamageevent returns the entity that was damaged and not the damager
I believe
You probably want the EntityDamagedByEntityEvent and getDamager()?
sounds right, thx
I'm trying to access the first arg in the array of args supplied by onCommand and use it to set the amount of items the player will get from .AddItems but i can't get it to work. carrots.setAmount(Integer.parseInt(args[0])); does anyone see what I'm doing wrong here?
How would I avoid this, any examples would be great on how to re-reference the world.
this looks right to me, could you share the rest of your code?
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length == 0) {
player.sendMessage("please supply an arg");
} else {
ItemStack carrots = new ItemStack(Material.CARROTS);
carrots.setAmount(Integer.parseInt(args[0]));
player.getInventory().addItem(carrots);
}
}
return true;
}
Material.CARROT
not plural
I believe that refers to the actual carrot crop, not the item
Yup. That fixed it
One more thing, how can i ask if the arg is an int or not?.. and if so, fail the code
are you familiar with try/catch blocks?
Nope
if you are expecting your code to throw an error for some reason, you can catch the error before it's thrown and handle it yourself. Some methods in java will force you to do this.
In this case the easiest way would be to wrap the parseInt call in a try and catch the NumberFormatException which is thrown if the input is not a number. Probably not the best practice solution, and in that case you should probably loop over the string and check if each character is a digit or use regex
https://stackoverflow.com/questions/5439529/determine-if-a-string-is-an-integer-in-java
Is this right? Still doesn't work, no errors.
So the try section runs the code in the brackets, and then the catch section examines the code that returned?
Very helpful, tyvm
falls through if an exception is thrown
I assume the warning that is given by intelliJ is an NPE?
you're a c#
wdym here?
started okay, then got cursed
Now i run into the issue testing if they even supplied an argument or not, do i nest the try and catches?
Well that's coverred by your first if statement
it's best to avoid nesting if possible as your code can get hard to read
like I said, using a try catch block for logic isn't the best practise but it is the easiest solution. In the case of checking if the player gave an argument, checking the array length is much easier than a try catch
Tyvm. Yeah i somehow forgot that i had already checked the length
Got ahead of myself
Good that you are thinking of edge cases
that's why I like kotlins toIntOrNull :D ashamed i got that function wrong the first time
Hi, I made a portal using multiverse portals pointing towards my other world named "LoopSpace". I then made a plugin that deletes the world and regenerates it under the same name. My console tells me that when I try to enter the portal that Bukkit lost the world reference, and I am not sure why since it is generated under the same world name. Any help is appreciated!
Here is my error log: https://paste.gg/p/anonymous/6cf3dde9266b4e3fae12c6809303e6da
Any examples would be great, still getting used to java development.
what code are you using. Not got much experience with multiverse portals but like elgar said earlier, its likely because when you reset a world it will have a different object in memory
#help-development message
seeing a lot of redundant code here. Why would you create a new location object with all the information from getWorld("WaitingRoom").getSpawnLocation() rather than just using that?
honestly, doesn't look like you are using much of the multiverse functionality here, and programming by just running in game commands is bad practise. Unload the world and delete the world from the filesystem, and then use spigots methods to create a new world.
should avoid those issues
you certainly shouldn't be sending titles this way too.
Ok, ill change some of my code
How am I able to kill a player if they are under a specific Y level in a specific world?
definitely will, but I doubt its necessary for this use case
on it boss.
So should I just schedule a repeating task for every second?
Alrighty, will try it out and see what works better for me 👍
ty for the help!
is there a way to check if a player was sent to a server by bungeecord and get the server they were sent from? (hub, minigame server, survival etc) using just spigot or would i need to have the plugin on bungeecord too using its API
am i missing something or why is every single item meta i get, regardless of the item damageable?
https://beans.i-really-dont-want-to.live/5M9Rz7NuE there is no way this should work
or am i missing something
don't think javas assertions are used by default
I would just replace that with
if(!(stack.getItemMeta() instanceof Damageable)) return;
just threw the assert in there to make it obvious what the problem is
stack.getItemMeta() instanceof Damageable; returns true
and i dont know why it would do that
its just pseuocode
what minecraft version?
1.19.2
nvm irrelevant question anyway
well they definitely should not be
could you send your actual code?
if (!(event.getCurrentItem().getItemMeta() instanceof Damageable)) event.setCancelled(true);```
tried multiple things, but every item i try returns true there
if that if statement returns true then every item IS NOT damageable
mightve worded it wrong
what im saying is event.getCurrentItem().getItemMeta() instanceof Damageable always evaluates to true
hmm I can't see why that would be the case sorry
yeah even after a server restart, still does the same thing
https://beans.i-really-dont-want-to.live/5M9WsZHZf this is the exact code im running, nothing else
prints true
wrong import of Damageable
still though, the item meta shouldn't be a damageable entity either?
his test is sayign it's never an instanceof Damageable. He's using the wrong import so it's never true
that's what I thought they meant initally
but they mean it's always an instance of it
class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
that's the nms implementation of item meta
all metas are damageable
I guess that's the point in hasDamage()
so I guess the javadoc comment isn't really accurate
very vexing that it's called CraftMetaItem and not CraftItemMeta
yes, I'm aware. But what's happening here is intended behaviour
I wouldn't say that all item meta's being damageable is intuitive
I didn't know regular items could store damage data
The way the rest of the page is worded, I'd say that this is saying that only items with durability can have the damage tag
Proof?
Haven't got the game open otherwise I would
so is there a way to check for items that naturally take damage like tools and armor?
if i can’t just check for damageable
what does Damageable#getDamage() return on an acacia plank vs a diamond chestplate for example
since all item metas are damageable you should be able to cast safely
Looking through nms code, it seems the durability given to items when they are registered is the only thing that makes a tool/armor differ from a regular item, so you'd just have to check if it actually has durability with getDamage()
ItemStack item = player.getActiveItem(); is failing with a NoSuchMethodError printed in my server console.. but in my ide everything seems to be fine. Is there a desync between my ide and minecraft?
does 1.8.8 buildtools still not work?
basically i have a spigot plugin that runs code and sends a message when a player joins and i want to get the server they came from so I can add it to the message depending which one they came from
would that be possible in plain spigot or would i need a bungeecord plugin installed too
that would only work for items that have damage already, not for something like a fully repaired sword
so theres really no way other than just checking for every possible item
How can i check what date .getActiveItem was added / removed in paper? Very stuck on this
Material#getMaxDurability() is a thing, might work
String[] args = entry.getValue().split("_");
double weight = Double.parseDouble(args[2]);
items.add(weight, entry.getKey());
}
for(int i = 0; i < amountOfItemsToGet; i++) {
ItemStack is = items.next();
String[] args = allItems.get(is).split("_"); // allItems.get(is) is returning null :(
is.setAmount(Main.ranNum(Integer.parseInt(args[0]), Integer.parseInt(args[1])));
outputtedItems.add(is);
}```
Anybody know a reason allItems.get(is) would be returning null?
I checked and allItems is populated with all the itemstacks I want
yeah this works fine, thanks
is this suposed to be an item pool generator?
Ya thats the goal xd
is it possible that amountOfItemsToGet is greater than the items.size()
therefore items.next() will return null
and unless there is a null key in allItems so will the get call
Has anyone found a fix yet?
like elgar said, the 1.8 hosting is down apparently. not sure there is much you can do. paper might host it differently, so you could try paperclip (I forget how theirs works so you'll have to check)
okie
Probably a good thing 🙃
amountOfItemsToGet is just the number of times we pick a random item from the items list. The ItemStack itself isn't returning null. Getting that itemstack from the allItems HashMap is whats returning null
But the only "modification" that gets done to the itemstack is adding it from the HashMap to a list
Need to ensure the hashmap is not empty
Or does not contain a null value
As stated above. Hashmaps are allowed 1 null key as well
Hello, does anyone know why I'm getting this error:
All I have in this yml file is
vars: '{"hi":{"val":"goodbye","type":"TXT"}}'```
And the code for this is
```java
if(varConfig.getConfig().get("vars") == null) return;```
why you storing json inside yml 😭
I am serializing and deserializing using jackson
Just use json then
Well your definition of serializing is different then because that isn't serialized. Anyways the problem is the : characters. You need to use double quotes. Also note yaml is a subset of json as well and should be able to convert from one to the other easily
If it were me I would just serialize that json stuff into a base64 string.
yeah well I never asked about that but thanks for the solution 👍
I get error:
Operator '/' cannot be applied to 'double', 'org.bukkit.attribute.AttributeInstance'
At line 22
How can I fix this?
playerMaxHealth isnt a number vlaue
org.bukkit.attribute.AttributeInstance not a number
Problem is maxhealth isn't an int. It is a string. So use Integer class to make it one.
In Java, we can use Integer.valueOf() and Integer.parseInt() to convert a string to an integer.
Change AttributeInstance to double 🤔🤷
Above code doesnt use a string tho?
p.getHealth()/maxPlayerHealth.getValue()*10
is presumably what you’re looking for Id say
Yep.
On my phone so can't really check very well. Just assumed attribute was being obtained as a string
Ah fair enough
double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
nice!
is "orb" a typo or did you actually try to import that?
sorry, i deleted it bc i solved it and it didn't register you were talking to me and not asking your own question
i did mistype org, only here though, im not entirely sure what i did tbh, but i think i made a new project and then intelji coppied everything? idk tbh
its working now though
maybe im missing something, but for the tab complete override doing a command, it works for the first argument, but once it's done, it starts suggesting online players still, is there a way to fix that?
Hi a question for md5 hastebin for making request i need to use as User-Agent: Hastebin Java Api as a normal Hastebin or something else?
Hard to know what you are asking
When you try to do a request in the official hastebin website you put as user agent Hastebin Java API
Or something else
You could. But I am not aware of hastebin hosted sites caring about the user agent
Unless you mean actual hastebin site. In which case not entirely sure
I mean the md5 version
?paste
You mean that?
Yes
Not entirely sure. Don't think it really matters. Try it and see
How could I set up a code that sends an action bar about every second or so and lasts as long as the player is online?
Here is what I'm trying to send.
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Health: " + playerScaledHealth));
you would schedule a repeating task for it
?scheduling
yeah but i want accurate blockdata (I have oak trapdoor in blocks) thanks
why pp write codes likes this ?
i have no clue about the benefit of it
and an example of why should i code like that is great
Are you referring to the comments?
If so comments are useful ways to add information for yourself or others. It isn't required either
Comments are one of the most important things in coding
but why tf under the refering statement
if youre talking about the reflection, its probably to make it version independent
but that shouldnt matter except when using CraftBukkit classes now because the net.minecraft.server package is now version independent
yeah they make it look nice
I find comments to be one of the most annoying and irrelevant things
I only comment what is explicitly hard to understand when looking at it
If I have a method called sumStats and it loops over the players stats there is no need to comment anything imo
if you are writing the code it is much easier to understand
but think of it objectively
somebody whos never seen the code before
and is looking at it
do you think they would fully understand it?
comments just help reinforce understanding and provide context for where there isnt
theyre extremely helpful and better to have than not to have
None
spigot be like 😠 rn
?
what lib are you using, ItemBuilder isnt in spigot irrc
While at first it might seem obvious like your example. What would make a comment handy for your example is if it isn't clear where it is used.
Sure I know what happens in the method but that doesn't tell me what is using it.
Did anyone tell me how I setup vote
right click, find usages
why would you add to a method where it is used? you can describe its usecase or even its behaviour, benefits and losses
ah yes
Can anyone help me
?ask
/* Sums the stats */
public int sumStats() {...}
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!
no,
/*
* Bloating up like a bubble until a reachable block is found
* The block itself might not be passable, but at least reachable from the outside
*
* NOTE: The reachable block is not guaranteed to be the closest reachable block
*/
private PathBlock bubbleSearch(PathLocation target, PathVector[] offsets) {
for example
/*
* alternateTarget - Whether to allow the pathfinder to end at a different block than the target if the target is unreachable.
* NOTE: In most cases fallback is the better option since this can be in the worst case a very expensive radical operation
* in addition to the regular pathfinding with only the goal to find an alternate target
* no matter where or in what relation to anything.
*/
``` and where it is used
How I setup vote links and which plugin is Best for vote
/* Loops through the player stats and adds them all and returns the sum
*
* NOTE: The stats will be treated as 0 if they are not set.
*
*/
public int sumStats() {
...
}
that whole comment
is just
common sense
Sometimes a method exists to be used somewhere specific. Helps to know where and why.
@hybrid spoke you are a dev
but then you could just move the method to there
no
Ooo
Depends really. But that isn't really an argument against documenting either
never said that, but you shouldnt really describe where it is used, more for what. that also leads to the where.
@ivory sleet
While most IDEs have this. Doesn't help if just looking at raw source.
I guess but even if you use github you can just search the method name and it tells you which files contain it
so unless someone is using notepad to look at your code it shouldnt really be a problem
They are a helper
exactly
Ooo sorry
Sure, and I am not saying it needs to be documented in all cases where it used as well. It was just an example of how something can appear obvious but not be
One type of commenting I like is examples but that seems very specific to JS
Provide an example of how to use a documented item.
usually I find those more useful than the actual comments but I've never seen them used in java lol
the only gud comment 😔
never actually seen this. will use tho 🙂
except for the fact it doesnt actually exist in java
true, any idea where I can get one of those custom java doc tags?
well I found this but its a bit scuffed ```java
/**
- This is an example to show usage of HTML pre tag while code snippet formatting in Javadocs
- <pre>
- public class Application(){
-
List<Integer> nums = new ArrayList<>(); - }
- </pre>
*/```
it looks a bit scuffed
I feel like I am going insane. I have an if statement to check if a value matches something... Sometimes it doesn't work? I decided to print the value I am checking to see if it's correct, and it's identical. Specifically, I have items with a PDC that stores the string "UnformedVoid", which I check if the held item has when a player interact event is detected. The code is dead simple: java p.sendMessage("§2itemData: " + itemData); if (itemData == "UnformedVoid"){ new formVoid(e); } In the formVoid class I just print that "Hi, User how are you?" message, as a way to show it went through before I keep working. Anyone know what the issue could be? I am completely lost
comparing strings using ==
use #equals
The item it checks is a crafted item, if it matters. When it works the item is freshly crafted, then something happens and it stops working
Thank you, I'll try this
compare strings with .equals()
Strange. Is there somewhere I can read about why this behavior happens? Why would it not be true when using '=='?
== compares the memory locations of the objects
because using == it has to be the same object
== compares memory address (instance)
but not the contents of the objects
also just a suggestion. you should try to name your classes using UpperCamelCase
and why items could be "fixed" by combining into a freshly crafted itemstack
"UnformedVoid" actually gets stored in java string pool, in practical terms its value gets stored before runtime, while itemData one is created dynamically
I will, thank you.
also you can override .equals() method to your code btw, so you can do some funky stuff with that
you could make it only respect an id attribute for example
yea ^ you could for example make the check alot for performant if your object has an "id" for example
beat me to it
smort
smort
only lookin bloat
why not set the lore with an inline if statement
my bad, my bad
if java had pairs i'd just do (lore, consumer) = loc.isWorldLoaded() ? (a, b) : (c, d)
rust 🥺
anyone knows an answer on this tho?
what lib, also hate that its .toItemStack not .build
next level loops:
STEP 1:
for (int i = 0; i < 256; i++) {
System.out.println("world.getBlockAt(new Location(world, 0, " + i + ", 0)).setType(Material.STONE);");
}
STEP 2: copy, paste
https://paste.md-5.net/uxazehotez.cpp
why is that a string
🤔
bigger file = better developer
more lines = more exp on execution
but also higher gold-cost of adding features
then you can just sell the lines
with what periodicity should i spawn particles so that theres no blinking?
you sound like a coke dealer XD
or pepsi, depends on preference
technically, addons are just lines sold separately

and bugs attack you
and decrease your health
and once your health is <= 0 your ide just closes without saving
that's a hell of an LSD trip
you can buy hp potions with gold earned by getting your plugins downloaded on spigot
how would my ide know that
database
it used the "TRUST ME BRO" as a source of data
nah
😮
some bugs you can tame and turn into something called "Features"
just like every class
exactly and they attack the bugs
i need that plugin
aint lookin much better lmao https://paste.md-5.net/qocahuxupa.pl
intellij plugin
with nice sounds and fancy visualization
like the super mario plugin
we would need a texture pack for items and mobs
i've never realised how time-saving insert button on the keyboards can be
welcome to heaven
made it two lines shorter lmao
for the past 10-12 years of my computer usage, i've finally got it what it means 😄
what does insert button even do
lets say you have a text
it can replace letters
welcome to "when your mouse is broken"
ctrl + r
and you want to insert something without breaking the text alignment (if its space aligned)
you can press insert and replace the chars
im an expert in breaking text allignments
it should be called replace mode instead
I'
m an expe
rt at that too
!
because the default writing mode is literally inserting chars at the positions
this is same shit as the naming of iceland and greenland
damn worldedits eval command is even slower than my expressionparser
flex
hehe, java...
worldedit eval should be removed, prove me wrong
eval functions never been very safe in the past or the present
what if parser cant parse properly and the injected code could be passed?
log4j 🤡
sad
i've saw a dude who glued sql statement to drop speed limiter's db tables somewhere on the net😄
🤔
i did something like that before
this block looks cursed lmao
pov: you are a coin
why does PlayerInteractEntityEvent not run when I right click an armor stand and what can I use instead?
must have something to do with the epic in your names
because for armorstands there is the PlayerInteractAtEntityEvent
I've been looking around a bit and can't seem to find it. Is there a way to entirely remove the displayname of an item? I tried setting displayname to nothing, which obviously didn't change anything. Then I tried just a space, but there's still something being displayed. Is it possible to remove entirely?
at inherits the other and contains the version where it got clicked
looked something like
for (int i = 0; i < 256; ++i) {
System.out.println("\"enchantment.level." + i + "\": " + "\"" + i + "\",");
}
thats basically everything
except the thing that armorstands only fire the at event
hey, so i am currently trying to draw 3d objects via particles in minecaft, but there is a problem: particles constantly disappear and reappear and that results in blinking. with what period should i spawn particles to minimize or remove blinking?
probably not except with some client side packet stuff or whatever
how come armor stands only fire the at event?
I'm interested now
Thank you. I made it a tiny bit smaller by giving the displayname a color and having the displayname be nothing. Can't do much better then, I suppose.
smol itemname
idrk, probably makes more sense in some way
maybe because armorstands cant naturally move
ah ok
calling a variable 0
yes, that's the best you can get
Hypixel seems to do it with a space for the DisplayName... But in their main lobby GUI they just have no filler items. Considering switching to something like that instead.
why have filler items in the first place
it is because you guys try to find a lazy way to detect if an item is part of gui 😄 ?
this is what i call a GUI
Hello! I've got a problem, my messages are getting send twice, anyone got an idea?
My code:
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (GameManager.instance.getCurrentGameState() == GameState.PAUSED) {
startReminderCountdown();
event.getPlayer().sendMessage("Test");
// Give player items
event.getPlayer().getInventory().clear();
event.getPlayer().teleport(new Location(Bukkit.getWorld("lobby"),0, 51, 0));
event.getPlayer().getInventory().setItem(4, ItemBuilder.createItemMeta(Material.COMPASS, "KitSelector", null, 1));
GameManager.getInstance().getPlayingPlayers().put(event.getPlayer(), 0);
if (GameManager.getInstance().getPlayingPlayers().size() == 2) {
Bukkit.getScheduler().cancelTask(reminderTask);
startStartingCountdown();
}
}
}```
will you build the resource pack dynamically
if so you can use filebin to automatically host it
how is the event registered
Hello, I have an efficiency question.
I'm getting a list from the config from which I want to filter out illegal values, and then check if a material is there, the question is which is more efficient:
Way 1:
materials.stream()
.filter() //filter illegal values
.anyMatch(configMaterial -> configMaterial == material);
Way 2:
materials.stream()
.filter() //filter illegal values
.collect(toSet())
.contains(material);
collecting it and then calling ::contains would be less efficient in my eyes
couldn't you filter and anyMatch in one?
then it would definitely be quicker since it would return early
My bad, it's a set and not a list
well I prefer to keep my streams readable and divided into steps
How can I get the open sign ?
what open sign lol
collecting to a set would require the hash function to be run for each material first, so it's definitely slower
until a null value arrives
always only compare enums by ==
what if I collect into an EnumSet?
still no performance difference?
why would you
Collecting them first will always be slower
since you only collect, no
no need to collect it as you can just call anyMatch
the only thing faster and more efficient would be a for loop
^^
broh the opened signGUI
or overengeenier and go native async
thinking about it again, even if I collect into a O(1) contains collection, I still need to add all the stream elements into it - which is always less efficient
or even better make a c++ script
just make your plugin native and code it in c++ lol
I will just use anyMathc
hashmap 
It's not always O1 😄 also HashSet is just an HashMap internally
heeheehee 💀
yeah it's horror
for well defined objects a hashmap/set get call should always be O(1)
correct, but it's actually super hard to implement hashCode and equals correctly :/
so filter out the collisions
depends what the object is
not really. otherwise get your object a primary key and hash that
Objects.hash 🤤
public class MyObject {
private static int nextId = 0;
private final int id;
public MyObject() {
id = nextId++;
}
@Override
public int hashCode() {
return id;
}
}
kek
100% success
lets hope copilot has more talents with acf
1.19.1 bukkit removed chat links right
Anyone else love mongo?
Specially when you have that type of problems which the data is not saved/loaded and you dont see any reason
😡
So I got question what would be easiest way to make public api jar
Currently I use interfaces for each class and then I add methods which I want to make public
Thing is that it is annoying to have interface for each class
so any suggestions
Yeah that is really painful
is there any magical way to just to remove all body code from methods and make them return null
I used to read that information and its pretty cool
It helped a lot to understand more about exposing application api(s)
extend class and override
then downcast it if you need and replace field which holds the needed class instance with reflection
Hello, im new to the server and I was wondering if this is the right channel to ask for help with spigot plugin code?
yes, but im currently busy rn so i cant help you
Yeah, this is the right channel
I suggest reading the output from ?ask command and using ?paste command output url for sending code/snippets
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!
Your welcome my guy, if need smth else just ask it. We are here to help each other. Sorry for my bad english but im not english native speaker - hahaha
I'm working on a plugin that's like a racing game, I already got everything working from joining to voting to teleport players on a the vehicle (aka a pig) but i'm having one problem I cant solve right now.. I want to edit the speed/velocity of a pig. I still want to use the Carrot on a Stick, so i'm not looking to rewrite the whole driving mechanic, I just want it to move alot faster. I saw online that on max speed it walks around 5 blocks/sec, and that's to slow for me. I already looked around for events triggering Pig moves with the idea to get the velocity and multiply is but couldn't find it right now. Already used VehicleMoveEvent but that doesn't trigger on Pigs.
TL;DR Does someone know how to increase a Pig speed or an event that gets triggerd when you ride a pig and move?
is anyone aware where i can find old i think bukkit code related to link detection in messages?
bukkit one
Map#putIfAbsent(key, object) doesnt return put and return the object, in case it doesnt exists?
cant i just parse url tho lmao
Because i have done a method Object getOrCreate(String name) { return map.put(key, new Object(name)); } but then when i use it it returns null - LMAO java is so fucking 🤡 with some type of things
java should have methods for that
Which in theory, that method must not ever return null 😡
IIRC when you use .put() it return the previous object, that was in a map
Sorry i get cofnused and writen what ever
So i have read that Map#putIfAbsent() will put the the object and return it, if the map doesnt contain it - So it musnt ever return null
check the docs
Are u trolling me?
I wouldnt be using it without reading the docs
lmao do you think im not checking the docs either?
We started again... i could be dumb but im not idiot
why the question then
Because is returning null, when it must return null!
🤔
wait i think i missunderstand what i read
Let me translate it to spanish tho
🤦♂️
so itt only returns null when the wasnt present in the map
otherwise it returns the already present value
Yeah, i testing it with the key without existing
Oh shit i missunderstand the docs, that the method look for the key, if doesnt exists it put inside the map and finally return the object your passed thru params
you can always check the impl yourself
I have a nightmare now
I know that there was a map method which create the key and assign the value, if it didnt previously exists and finally return the value
oh
Yes you are totally right
Really thanks for both of you
No it wasnt that because computeIfAbsent() ask for a function
still working at that claim plugin thing?
Yup
Since june im with this shit
is that thing even working?
yeah just having some small issues
I have been checking the docs, and definitly there is not method which: "check for key, if not exists create it and assign the value, to finally return the assigned value"
what are you tryin to do
check for key, if not exists create it and assign the value, to finally return the assigned value
But without having hundred of lines
map.computeIfAbsent(key, k -> Object);
for this method, you could do something like this
regions.computeIfAbsent(name, Region::new)
Oh thanks
Guys why getType().getID() is deprecated ? i need it for sending packets
cuz id is deprecated
because its hardcoded
Packets*
He is not working with items
what is he getting type of
i guess
and how can i use Block Action packets because i need > (The block type ID for the block)
Here https://wiki.vg/Protocol#Block_Action
i get this error > Cannot get ID of Modern Material
sad
what are you even trying to do
open chest animation (:
you can hardcode id's yourself tho
afair glass was 40
dirt 2
glowstone 89
maybe you can just find old chest id
and try to use it
i know👀 but when i write it like 54 is the chest id but i get error
This > Field index out of bounds. (Index: 2, Size: 2)
showyourcode
i Can't send anything can you give the website to paste my code (:
?paste
verify yourself
love to see it
yo mike unrelated thing but I'm very sad
apparently I gotta switch plans to enjoy the gifted nitro
I know but why would it be wrong i fill it that way?
rip my 5 bucks
AttributeModifier damage = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 1, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);```
Cannot resolve constructor 'AttributeModifier(UUID, String, int, Operation, EquipmentSlot)'
Anyone?
Kinda stupid tbh. I was hoping you'd be able to just use it rather than that.
declaration: package: org.bukkit.attribute, class: AttributeModifier
How do I make a crates menu with excellent crates/golden crates
Try changing 1 to 1.0
Wrong channel. Stay in #help-server
💀🤓
don't rly know
but size of writable integers buffer is 2
nothing
😅 now its work thanks
What version of spigot are you depending on?
1.12.2
The Javadoc link you sent is for 1.19
The constructor probably does not exist in 1.12.2
Ik, but this constructor exist in 1.12.2
Quick Question, how does one create a custom Async Event?
Just checked... It does not
Something similar to how AsyncChatEvent works
Oh.. How I can change damage in 1.12.2?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/Event.html#<init>(boolean)
Use the booelan constructor
declaration: package: org.bukkit.event, class: Event
Use the other constructors
Which is the contract for not seeing anymore the shity Null annotation?
Because spigot api is so amazing that doesnt have contract in some methods
😡
i'll give that a go cheers
You can always fix that yourself in a PR
I dont understand the contracts that why haha
I will have to read about them
the contract for not seeing anymore the shity Null annotation huh
Because its really annoying having to use Objects#requireNonNull()
You can just ignore the warning or do a null check
ConstantConditions, assuming youre talking about how to suppress the warning
And i have try disabling those warnings thru the IDE and is not ignoring them
it works yay
you shouldnt be ignoring them 90% of the time
thanks again!
So shity spigot should add contracts so
That why they exists!
contracts?
🤔
talking about @Contract("_ -> fail") for example?
Yeah
Spigot should use that, so you dont have annoying warnings telling you that x method can be null
They won't magically fix the issue
The warning you're getting probably won't be fixed with a contract
^^ i see no reason to use those anyways
i only fixed one issue with using a contract annotation
i love how ij infers method contracts tho
example?
You need an example to use a constructor??
Got a question, if read the ask command and told me to just put the question in the chat and not like ping others (seems logical to me because thats annoying to get spammed for). I do notice this chat is very active (Which is nice to see!) is it okay to sometimes like reply on the question to let others see it again, so it doesnt drown in all the talking? or should I just keep being patient?
its fine
You can bump your question or create a thread. Just don't spam
Replying to your question saying bump or something is totally fine if it wasn't answered and got lost
Alright, then i'll wait a while and sometimes bump it so people who maybe know the anwser can help out 👍
You can create thread for that, so your message is not lost
Thread in discord? how does that work>
Oh wow, is this new to discord or something i just never saw before?
uhh its been here for a while
A year maybe less
Oh never knew this / saw this. Alright, I'll make a thread. Thank you very much
Turns out they're newer than I thought
Chance pig movements
Your welcome, you are here to learn as everybody here
Glad to hear that
Hello There!
Could someone mind helping?
Havin troubles with end of parsing
currently this
`package me.renek.tp;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class Tp extends JavaPlugin {
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
getLogger().info("Plugin enabled.");
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
Location location = new Location(Bukkit.getWorld("Lobby"), 1, -60, -1);
player.teleport(location);
}`
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.
The last }
Can't have a public class within another though, right?
can
Did but still
public class MyClass {
public class MyAnotherClass {
}
}```
then in other code you do
MyAnotherClass anotherClass = new MyClass().new MyAnotherClass();
wait you can, wtf, why did I think you werent able to ?!
is this possible in java lol
before i used
MyClass myClass = new MyClass();
and
MyAnotherClass mac = myClass.new MyAnotherClass();
What's your ide
What?
Or vscode
intelijj
NetBeans
Damn 😞 intellij continue I guess
it's not working
🙂
ye
wanted to type same thing
about static inner classes
static inner
Why are always my plugins dont work :C
cuz you bad at coding?
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.
Mongo doesnt parse UUID class?
Bruh
wtf you can do this!?
Because im saving a List<UUID> wihich is saved. But then is not loaded back
no way wtf
There are other discords for learning Java
if you can't use {}
you have much to learn
open{
} close
that term i heard before
nested loops 😵💫
i truely need to search for it
sounds interesting
inner classes
that's developed to be "alternative" to inheritance
me like: 
but i prefer "inheritance or everything in one class" over it anyways
just a design choice
public class Bycicle {
public class Seat {
}
public class ByWheel {
}
}```
yes
How do I keep track of data on players? Like assigning or incrementing a variable on a player when they hit someone
persistent data container
so it's not erased after restart
Maps for session storage
Does Mongo not allow saving UUID into databases?
I'm fine with it being erased on restart
maps then
Maps?
kkk
java collection
@fluid river did you invent a new programming languge? 
probably
fava
F# + Java
I think he didnt learn java
Fava
that sound so cool!
i guess Rava would be better
I started with datapacks so i thought you meant literally storing it on a Minecraft map.. whew
Rustava
FREE JAVA LESSONS
Rust++
in 10 years Rust#
public HashMap<UUID, Integer> playerStatTrack = new HashMap<>();
// somewhere in your code
playerStatTrack.put(player.getUniqueId(), 1);```
What? Translator got broken with that phrase
Translate string to binary array
hey guys when I use the schedule can I use it multiple times or only once?
and store it
oh ok
You can lot of task
?
showcode
and exact problem
no like the code is perfect
byte array
why Integer?
priority?
ez with a bytebuf
but like whenever I use it multiple times it gets with errors
show code then
where
this
I mean like if I copy and paste it again it would bring error
well i guess you can easily kill more than 127 mobs for some stat
I changed the variable name tho
stop copypasting then
so then I don't make another task?
idk what are you talking about
show your code
you can just store task to variable
and run schedule on it
I'm talking about the scheduler
Here we ago again with shity errors!! "Cannot invoke "java.util.Collection.toArray()" because "c" is null"
Were the fuck "c" is cumming from?
bro your c is null
😡
Where is c cumming from?
your list i guess
It's internals might have a c
Hmnn
So what i can do?
Its not my fault
you know
Nerds
depends
quick question
I dont find the reason of the erro!!
I dont even understand why its thrown
that was not to you
well you can write each method on a new line
arraylist
.stream()
.sort()
and find line which throws error
you might have null list
or some of your lines are not uuid format
tho why don't you just use .toList()
instead of collect()
i probably gotta look at the docs
👍
it doesnt allow me to use directly toList()
java8?
Thank you for picture
np lol
maps are also part of JCF, but don't implement collection
tho map's entrySet is a set so actually is a collection
wtf queue
fifo collection
Damm so much stuff i gotta study
Dam i have discovered that MongoCollection#getList() returns null
🤡
In computing and in systems theory, FIFO is an acronym for first in, first out (the first in is the first out), a method for organizing the manipulation of a data structure (often, specifically a data buffer) where the oldest (first) entry, or "head" of the queue, is processed first.
Such processing is analogous to servicing people in a queue ar...

