#help-development
1 messages · Page 419 of 1
do Sets just store their data willynilly then?
For example a hash set is backed by a hashmap, and hashmap aren’t ordered
A set could look like this
(1, 3, 2)
Then you remove '2' and add '2' and it could look like this
(2, 3, 1)
Sets have no guaranteed order
AsynchronousSynchronousNonBlockingBlockingCollectionQueueSet (:
Some of them may have an order due to implementation but they are not guaranteed to do so
You can technically be really janky and access by index though like
java.util.HashList when? /j
toArray or an iterator
That would be pointless lol
But there is no guarantee as to what’ll happen if you do
If it has an order then the hash does nothing
LinkedHashSet?
no duplicates 
is that a thing
I was gonna say. LinkedHashSet would like a word lol
how do i make something only happen when shifting
Sets are per definition unordered. Some have an order because of their implementation
but this has to be explicitly stated.
^
You check if they’re shifting
how
Player#isSneaking
thank u for reiterating what alex said a solid 2 minutes ago
Check Player#isSneaking()
You are welcome
If we're gonna get technical, this is wrong 
thanks this isnt gibberish at all
its not
Do you know Java?
no
?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.
then that's why its gibberish
Gonna have to learn the language before you can program a plugin in it
?
ye ik i just want this one thing done so me and my friend can play
?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/
you can be sneaking without holding shift
yeah, i sneak with Left Alt
Ok fine, TECHNICALLY you are correct
😄
i meant sneaking
anyone who doesn’t have sneak bound to shift is a dirty savage though
i sprint with shift
like what most games do

This is the equivalent of saying “I don’t know how to drive, but I only need to take the car to the mall so I can hang out with the boys”
You either need to learn or find someone to do it for you
Well no I more meant that you don't have to be holding the key to be sneaking 😛
"Mum drive me to the mall"
better didnt say that
Does you mum know how to code?
but learning would taketo long i just want to edit thisplugin so it only happens when shifting
Say you're under a half slab
& the server doesn't know what buttons you're holding
I can just find someone to learn for me?!?!
Heck yeah, choco learn assembly for me
That sounds like dirty 1.9+ behavior
is there a reason stuff isnt immutable, ive seen the same thing on minestom and im wondering why
What does the server think if you are forced into the crawling state
Does it consider you swimming or gliding
can u do it for me 
Abso-fucking-lutely not
It was worth a try
No I cannot, but you’re now on the right train of thought
no im not doing it for you either
do u not know how?
Does this happen in 1.8? I didn’t think that would trigger sneaking
Use GOTO a lot. It makes your code clean and readable.
Cause we can change it
Dynamic recipe outputs
I know how, I just don’t have the time to spare on that
mmmm ye suree
im wondering what for, cuz does changing it have to resend the update recipes packet?
I dunno. Although what I'm hinting at is that the client has no clue you're pressing the shift key. Your client could send a packet saying you're sneaking no matter what key you press, if any at all. The state of sneaking != holding shift
I'm trying to win on technicality here lol
What kind of assembly, you didn’t specify
Terminology
EXACTLY
i could probably just have an abstract getResult method instead of having a common field which isnt used anyways when overriding it 🤓
can anyone here do some simple codingfor me pls its not a lot its just checking if they sneakin to do the thing in the plugin
?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/
?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 mean... I wouldn't necessarily recommend basing your stuff on CB

The CraftInventory stuff is scary
just need some impl details
gbz80
The impl details are a little sketch too as Minecraft has evolved. null vs AIR constants in 1.14 for instance
When do we get a PDCRecipeChoice?
what would that even be

we have air returning on minestom 
The pdc of the ingredient and the item you’re using have to match
kinda weird to do Arrays.fill(stacks, Material.AIR)
how would minecraft render that
Well, more specially a single key must match
I remember having to do a binary search in ARM for homework, such a PITA
Yeah fair point it would be hard for the user to tell
But I mean, is ExactChoice shown any differently from just a regular material?
dont think so
i think if you had pdc, you would need to also pass a List materials
so cb could tell the server what to render
The recipe book just renders a ghost of an item, right?
who thought it was a good idea to only have light mode on stash
Not the tooltips or anything
cmon man its 1 am
yeah
you have litemode stash?
ratio?
Simply time travel
Not everyone uses dark reader
Or whatever it’s called
What would it do
what api
specify the stone cutting options of an item
woodchopper block when?
Yeah that's done via addRecipe() iirc
ah
messed up stonecutter
I think we have a StonecutterRecipe?
Yeah stonecutters are just a crafting table basically
yas sir
But with a fancy UI and the ability to castrate you
personally, i love it for the second option 🏳️⚧️
Minecraft gender reassignment surgery plugin
minecraft BOOBS plugin
is that a furbee
its 2023 man
im probably making some stupid decisions now which i'll regret later
uh oh craftbukkit doesnt have the group field in the recipe class either :(
am i the only one waiting for c++ style default args in java?
I doubt it’ll happen
same
Java just uses overloading for the sameish result
but atleast we got string interpolation now
Do we?
I want https://openjdk.org/jeps/441
we do?
Looks like we’ll have it in preview soon
what does that one do? ive seen so many pattern matching for switch previews
static String formatterPatternSwitch(Object obj) {
return switch (obj) {
case Integer i -> String.format("int %d", i);
case Long l -> String.format("long %d", l);
case Double d -> String.format("double %f", d);
case String s -> String.format("String %s", s);
default -> obj.toString();
};
}
i have that in java 17 preview afaik
and 21 is lts so we might be getting a java update in 1.20 or 1.21
If we don’t I’ll book a trip to Stockholm
go visit conclure
yeah
or is that another country
both are sweden
i better go to sleep bruh
before i throw my pc out of the windows cuz some dude sealed his interface i was planning to use
I mean idk if Mojang will have any reason to push java forward even more
latest support
Most companies don’t bother
were on 17 atm arent we?
Yes but I assume they wanted something from 16
17 is supported until 2026 and extended supoprt til 2029
Most companies don’t see the new features being worth the effort
so are we jumping to next lts in 2026 or 2029
Granted, for Mojang they don’t have to update a bunch of live software
So it’s somewhat different
Kotlin khm
Hi i have a question about hikariCP what is the best way to get the connection in a Dao for example? if you need more explaining let me know!
In a decentralized autonomous organization?
dao as like DataAccessObject: https://www.baeldung.com/java-dao-pattern
actualy doesn't matter where you get it
TIL this is called dao pattern lol
aynone know the name of the plun that when you get hit out of spawn area you cant run back in and it stopps u
Yeah, it's a very complicated method of doing things. I find that kind of pattern is only useful if I'm scaling a large application
isn't it basically using same interface for multiple db impls
that impression i got from fast look over that page
yess but does anyone know the best practice of getting a connection? i am finding many solutions like:
https://stackoverflow.com/questions/44580501/using-hikaricps-connection-pool-the-correct-way
what do you guys think is the correct way to do it?
anyone got experience with spawners in servers
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
well i cant get wither-skeleton, iron-golem, cave-spider spawners to work they are just pig spawners when you place them have tried mineable spawners plugin and slik spawners all other spawners work just the ones with two words
how is this related to development?
Someone can explainme how to differentiate inventories in inventoryview.gettopinventory()?
like, yes i know it will get the upper inv
but i dont want to make my listener confuse
u know?
So how its supposed to differentiate x inv from y inv?
by using == or equals
Are you doing GUIs?
Yep but being honest i dont understand your post on spigot
I just need to listen to 3 invs
Well then create those 3 invs and check if(clickedInv == yourInv)
Yes, the problem is idk why it doesnt work
it doesnt matter if i click in the player inv or in the custom inv lets say a diamond sword will make the samething
im actually doing this for verification if (e.getClickedInventory().equals(inventoryView.getTopInventory()))
but i know that wont work
because will listen to all the upper inv
not the one i want
there's where my question is
This will be true for every top inventory that gets clicked
that should be an instance of your inventory
If you want == to be true then you can only create your inventory once
And exactly this inventory needs to be opened by players.
Every time you call Bukkit.createInventory() it will create a completely different
inventory and == wont be true anymore.
Hmm
this is my code for another listener if (inventory.equals(resultInventory) && player.getOpenInventory().getTopInventory().equals(resultInventory))are you thinking that?
No im thinking
if(event.getClickedInventory() == yourCustomInventory) {
}
hmm
thats tricky
what i normally will use
a github
for every project
Never tried that
Github isnt a bad option tho
Onedrive, i think that takes files from your desktop and puts them in there
cant remember tho
100% use git
onedrive is cloud
@EventHandler
public void onResultadoClose(InventoryCloseEvent event){
Inventory inventory = event.getInventory();
Player player = (Player) event.getPlayer();
// Check if closed inventory is named "Resultado" and is top inventory of player
if (inventory.equals(enchanterMenu)) {
if (player.getOpenInventory().getTopInventory().equals(enchanterMenu)){
UUID playerUUID = player.getUniqueId();
// Check if the UUID of the player who closed the inventory matches the stored UUID
if (playerUUID.equals(storedUUID)) {
// Drop the item in the player's spot or inventory
player.getWorld().dropItem(player.getLocation(), item);
}
}
}
}````
I just wanna drop the item if the player closes the inv
but is not work
Just use the desktop app
First of all. This line of code is useless:
k
Next: Where is this "item" coming from?
Just a enchantment thing
Yes i know you can enchant with the anvil
i just making a favor for a friend
So its a field in your class.
Then this wont work. If multiple players have this inventory open
then they will overwrite each others items
I thought that
Huh?
No what he needs is a proper GUI setup.
He needs to create one separate inventory for every player.
damn
i thought of that, that should cover that problem?
If you want to write your own then follow my tutorial.
You just need to sit down and learn some more java for that.
imo if you dont want to use a lib, you want a class that implements Listner, constructor with JavaPlugin to register the listener, Save the inventory to a class variable and check if the inventory is the same
Controlling the events is the easy part. Your listener should not be bigger than this:
abstract class
You never thought of making a video tutorial?
Not really... I can see the appeal of videos but thats just too much unremunerated work
text + images is better imo
Okay, question, how does this work?
Map inventories to their handler
this
not the image
Your key is the vanilla inventory and your value is any implementation of the InventoryHandler interface.
This is an example for some implementation
You can just follow the tutorial step by step and change what you need to change honestly.
From here now i can make the thing i was thinking?
I already asked this question before, but seems like nobody noticed so I'll ask again. Given that I know for sure that a block at a given Location is a bed, how do I get the Location of the second half of that bed?
Like, none of these API methods are very helpful https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Bed.html
Some people on the Internet suggest to just check what part of bed it is, and check in all directions where is the another part
But this solution would fail 75% times in cases like this
Idk check how vanilla does it
It extends Directional
So just get the block in the direction that the bed part you have is facing
assuming both parts face inwards anyway.. i'm not sure if that is really the case. it's still easy to work out either way
I believe both parts face the same way
so you if you get the head part you need to get the opposite direction
if I recall
That's right
Thanks, it is the solution
Does TextComponent support line breaks?
It does \o/
hey guys, how do I undo a paste on FAWE(FastAsyncWorldEdit)
with api?
yes
public static void pasteSchematic(String schematicName, Location l) {
File file = new File(getInstance().getDataFolder() + "\\schems\\dungeons\\" + schematicName + ".schem");
ClipboardFormat format = ClipboardFormats.findByFile(file);
try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
clipboard = reader.read();
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
EditSession editSession = WorldEdit.getInstance().newEditSession(BukkitAdapter.adapt(l.getWorld()));
try (editSession) {
// Saves our operation and builds the paste - ready to be completed.
Operation operation = new ClipboardHolder(clipboard).createPaste(editSession)
.to(BlockVector3.at(l.getX(), l.getY(), l.getZ()))
.ignoreAirBlocks(true)
.build();
try { // This simply completes our paste and then cleans up.
Operations.complete(operation);
editSession.close();
} catch (WorldEditException e) { // If worldedit generated an exception it will go here
System.out.println(ChatColor.RED + "OOPS! Something went wrong, please contact an administrator");
e.printStackTrace();
}
}
}```
this is my code to paste a schematic right now
I have no clue how to use FAWE/World Edit
editSession has an undo method
im not sure if you can undo after you close the session though
editSession.undo(editSession)?
yeah
could I do something like this?
public static void undoLastEditSession() {
EditSession editSession = latestEdits.get(latestEdits.size() - 1);
EditSession undoSession = WorldEdit.getInstance().newEditSession(editSession.getWorld());
editSession.undo(undoSession);
}
the docs fucking suck
i found this
yeah lmao
let me try this
ok this works
also for the paste method, where does it paste from
which x,y,z
if youre using ClipboardHolder theres a .to(x,y,z) method
you can append
oh you have it in ur code
yeah, I think it pastes from where I copied it
i will copy it from top right corner so its easier to paste it
it works ok
Okay what the fuck the issue in having, is really stupid. The code is not being executed if i remove a sout(), but if the sout() all the code works pefect
🤡
Is that even possible? 🤔
i saw something like that happen to someone else, the sysout was delaying the follow stuff just enough for it to work
Could caused because of an executor? 🤔
Hi, noob with java but not with programming at all. I'm used to use VS. Just a simple question: How do i find all available EventHandlers? for example there is a tuto that implements "onJoin" which is when a player joins the server but i can't seem to find that event is called or even more when it's defined. Thanks. PD: using intellij
For coding spigot plugins, you should import the spigot api, without it you cant code plugins because its contains everythings the events api, plugins api, etc
Not work? Details please
it doesn't just "not work" so your are doing something incorrectly
package club.crestmc.neptunediscordlink.util;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.jetbrains.annotations.NotNull;
public class ChatUtil {
public static BaseComponent[] translate(@NotNull String text) {
return new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', text)).create();
}
}
👏 Don't 👏 use 👏 legacy 👏 symbols 👏 in 👏 components 👏
&f, etc. = legacy
how would you reccomend making good configuration with components
im pissed off because i spent the past 3 hours trying to fix this error
i could literally punch someone right now
just dont' use components if they have no easy config
so just use the deprecated option?
where you just send a string?
oh then yeah just use the deprecated option
What can cause a code of block not being executed when i remove a system out? Because its happening that on my code, and its really weird
and supress it
Use String, eff paper, this is Spigot
he is using bungeecord
but what doesnt make sense
ah, then learn bungee 🙂
is whenever i run the following command it throws an error related to translateAlternateColorCodes ```java
package club.crestmc.neptunediscordlink.commands.defined;
import club.crestmc.neptunediscordlink.NeptuneDiscordLink;
import club.crestmc.neptunediscordlink.commands.CommandBase;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class DumbCommand extends CommandBase {
public DumbCommand(NeptuneDiscordLink plugin) {
super(plugin, "dumb");
}
@Override
public void dispatch(CommandSender sender, String[] args) {
ProxiedPlayer p = (ProxiedPlayer) sender;
p.sendMessage("dumb");
}
}
its not referenced ANYWHERE
Usually that happens when it's a race condition
Right, could be a completable future causing it?
Its usually when you synchronize on two different objects
different places in your code
makes sense cuz im using CompletableFuture
I think my issue is not correctly explained. Where do i find events handlers at all, like if there is an onJoin i want to know the sintaxis for the event when a player leaves
one locks the other out
?jd-s
Do you want to see my code?
do you use the synchrnoized keyword anywhere?
Sorry im way too new with java and intellij, is that a command?
?learnjava!
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
learn java before using spigot
?paste your code then
just stick with legacy text and delete any component references 🤷🏽♂️ could also be that there is weird compilation stuff going on
right thanks man i have been many hours with this shit
Its really simple what im doing but i cant make it work- haha
and whats the exact issue? I see nothign in there that shoudl be problematic
Im confused too, because some debug messages are not dispayed and some yes
I just invalidated IDE cache, because i thought it was something there can cause this
okay the issue is the next, my code acts like the event wasnt distpached
I'm telling you why it likely isn't working. Legacy text and components do not play well together
Like if the code wasnt even called 😡
he's not calling the method relating to the referenced issue, My guess is compilation issues or simply user error to replace the jars. Unless Bungee just doesn't straight up support legacy
do you have a large enough thread pool?
I assign it as 20 by default, its okay?
should be
Those are the output while executing, but if you see carefully my arrive data debug (a sout, is not displayed)
while its making me think, that the message is not being published
are you doing the send and recieve in the same thread?
no
Im an executor by default in case you dont privde your own
So you can have an idea
get client? shoudl you not be using your own pool there?
I've not used redis but that looks wrong
What? You mixed me there with the question
Im already using JedisPool if thats your question
Yes
Im doing there on the 2nd picture
Inside of try because its auto closed the resource, so then its availabile for next usage
lastly, are you creating a new subscription? or just using one?
when you initialize the lib, im passing the next params, then interally im subscribing to each serve from the servers you given, plus an extra channel named as: plugin-sync:global, in this case
If you are not renewing your subscriber then I see nothing wrong. You'll probably want to wait for 7smile7 as he's a redis guru
okay, aparently i fixed the broadcast part, im happy - Thanks for trying to help
Now i need to fix the part which allows you to forwards message to a specific server
Hmn i cant understand the reason of what happening 😡
Now the messages are received as they want, like if my conditions where insibles 💀
received as they want? Do you mean they are arriving out of order?
intellij?
probably because the power went out right as I was starting up the IDE, my whole pc had shut off.
clean cache
how?
what IDE?
I use Eclipse 😉
intellij :
file -> invalidate caches
its not working.
Restart your pc
i just booted up my pc.
i use vscode for a few other projects in other languages but not java most of the time.
i would probably prefer to not have a headache.
um
how do i fix this, if anyone knows?
I would guess a file corruption
re-install the ide, and do a chkdsk on the command line
somebody might have tripped breaker or something right as i was doing that.
ok and?
i am so annoyed today.
sorry, about that, i just feel kind of stressed out right now.
My logic is the next, im doing it via 1 default channel (used for global plugin communication) and 1 channel per client let say. They looks smth like:
<identifier>:global- Is aways subscribed to it<identifier>:<server>- Its subscribe to each channel getted from the servers you pass before initializing the message broker
invest in a power back up unit
ok the IDE syntax highlighting and autocompletions issues seem to be fixed now.
that aside though.
i am trying to implement an anvil GUI.
how do i get the two slots in the anvil for putting items/enchanted books to combine?
slot 0 and 1
thanks.
should a PreparedStatment be created in an async thread or is it just okay to create one in the main game thread?
not using one, just creating one.
Hey guys! where can i see the tutorial on how to install the plug-in?
you just drag and drop the plugin jar into the servers plugins folder
and then restart the server, if it's still running
spigot plugin hotswap when? /j
thanks!🫶🏻
how do i get the contents of the textfield of an anvil GUI?
if you have an AnvilInventory it should be getRenameText()
do i just cast it to an AnvilInventory?
i tried doing that earlier but it seemed to throw an Exception.
you could probably do an instanceof, depends where you need to get the text
this.inventory = (AnvilInventory) Bukkit.createInventory(null, InventoryType.ANVIL, "[Change Name]");
is that looking right?
just googled some stuff online and for anvil guis you need nms, i found a lib that might work https://github.com/WesJD/AnvilGUI or a class that might also work https://gist.github.com/Scarsz/2524d755fa3e3adddb5dc46890e340f8
the latter is for 1.8 obsfucated nms so idk easy that would be to update
come on you don't need to reinvent the wheel
plus anvilgui is maintained and multiversional
public class RenamingInventoryGUI {
private AnvilInventory inventory;
public RenamingInventoryGUI (Chunk chunk) throws Exception {
this.inventory = (AnvilInventory) Bukkit.createInventory(null, InventoryType.ANVIL, "[Change Name]");
}
}```
ok.
there does not seem to be one for 1.19.3.
im pretty sure 1_19_R2 will be 1.19.3
there is also a 1_19_1_R1.
nms versioning is weird, just checked the pom and 1_19_R2 should™️ supoprt 1.19.3
could probably be easier if i can just get the AnvilInventory object.
ok.
so, um, how do i add it to my project?
maven?
yep.
add xml <repository> <id>codemc-snapshots</id> <url>https://repo.codemc.io/repository/maven-snapshots/</url> </repository> to the repositories tag and ```xml
<dependency>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui</artifactId>
<version>1.6.3-SNAPSHOT</version>
</dependency>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.40.0.0</version>
</dependency>
<dependency>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui</artifactId>
<version>1.6.3-SNAPSHOT</version>
</dependency>
</dependencies>```
is this looking right?
do i need to do anything else to specify that it is for 1.19.3?
shouldnt need to, im guessing it grabs the version from server ver
ok.
You should setup some shading for compiled dependencies
In order to avoid conflicts
(If you haven't done it yet)
https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
um, how do i get these red underlines to go away?
ye. if you just get the itemmeta and null check it then the compiler warning goes away
i dont really use third-party libraries all the time.
no? The warning tills saying its could be null
Also tried moving !hasCustomModel() return; to an if under that one, but same shity warning
how could it possibly be null if you null check it yourself, lol
ItemMeta meta = item.getItemMeta();
if (meta == null || !meta.hasCustomModelData()) return;```
depending on what you are doing or how the code is setup, sometimes the IDE can't always tell if something isn't actually null
however ide warnings are not compile errors
yea, the IDE can't tell when it comes to methods like #hasItemMeta
different things
right, but that why shity @Nulleable exists 🤔
there's some exceptions tho like Optional#isPresent/isEmpty
I mean spigot api is weird they use @Nulleable and @urban grotto hen they shouldnt use them, but when you need them to be on they dont exists
Maybe my ide is bug 😂
I will try invalidating cache
whats the textfrield? Its smth newer?
even with those annotations there is still some stuff that can't be predicated that it will or will not be null
I always do null checks on stuff that is outside of my programming
because you just never know
but the IDE is only so smart
^ i.e.: @NotNull and @Nullable can't tell the IDE to infer that #hasItemMeta relates to the nullility of #getItemMeta, lol
uh.
new AnvilGUI.Builder()
.itemLeft(createItem(Material.RED_STAINED_GLASS_PANE, 1, "[Cancel]"))
.itemOutput(createItem(Material.GREEN_STAINED_GLASS_PANE, 1, "[Proceed]"))
.onLeftInputClick(player -> {
player.closeInventory();
})
.interactableSlots(AnvilGUI.Slot.INPUT_LEFT)
.interactableSlots(AnvilGUI.Slot.OUTPUT)
.title("[Change Name]")
.text("")
.onComplete(completion -> {
player.sendMessage(completion.getText());
return Arrays.asList(AnvilGUI.ResponseAction.replaceInputText(""));
})
.plugin(ChunkClaimsPlugin.getThisPlugin())
.open(this.player);```
how do i prevent the player from taking the item out?
and why is the item in the output slot not displaying?
also, the textfield is not empty.
i might not be able to get it working properly.
Remove interactable slots, those make the player able to interact with them and for so able to take them.
If you want to allow the player put the item but not take the modified item, remove the interactableSlots(AnvilGUI.Slot.OUTPUT)
Btw, Interactable slots seems to be an array, so instead of calling it multiple times, you can directly put the slots separated by coma
You're iterating over a list and trying to remove elements from said list while still iterating. Hence the ConcurrentModificationException error.
Take a closer look at the lines variable you have and what you are doing with it.
thanks
Kotlin, the only language that will still make u use nullsafe indicators when you already make sure its not null, nice.
anyways seems fine
fr i hate that
could probably make a method like fun giveBow(player: Player) so u dont need to repeat the .addItem code
but just nitpicking
u mean make the function and call it when i wanna give the player a bow?
yeah instead of copypasting the 2 calls to addItem
like a really really really small and unimportant nitpick
Player.giveBow() smh
It usually doesn’t.
PR'ing this method into API, gives player a bow.
Kotlin extension functions nub
True
i did not have them and i could still shift-click to get the items.
the library might be broken.
i just need the text from the anvil GUI textfield, how do i get it?
how i can override a command? (/help)
like this?
it seems EssentialsX is overriding my command
Yo what do i put there
In kotlin you check null value with !==, after that, compiler won't complain
And it makes sense, because === translates to == in java
after what
after EssentialsX?
like after ess yeah
yeah
nice, how?
scheduler
waiting for ess to get enabled?
make ur plugin load after essentials ezpz
soft depend and/or delay stuff by a few ticks
depend controls load order, softdepend doesn't
Other option would be to listen to AsyncCommandPreProcess and if the command is /help or /essentials:help, modify it to be /yourplugin:help
That way if the server doesn't use essentials but other similar, it will still override the /help command
yea thanks to all for the help, but the main problem my command was not working, i didn't registered it in plugin.yml
after registering help in plugin.yml my command overrides Essentials /help command
Happens a lot actually
yea
is there a way to batch spawn particles rather than sending a packet for each when using World#spawnParticle
I don't think so, if you want to send a participe to everyone, then you will have to send the packet to everyone.
If you just make it appear server side, the client will see nothing, as he doesn't actually have knowledge on what's going on on the server until the server tells the client
I'm trying to remove an ArmorStand entity using remove() but it doesn't work. I know armorstands are kinda wacky but like...
ArmorStand armorStand = loc.getWorld().spawn(loc, ArmorStand.class);
armorStand.setSilent(true);
armorStand.setSmall(true);
armorStand.setVisible(false);
armorStand.getEquipment().setHelmet(eye);
mob.setPassenger(armorStand);```
In the event where its vehicle (the mob) dies:
``entity.getPassenger().remove();``
store your armorstands in a list
get the armorstand from there and remove it that way
so using for(Armostand ... : entity.getPassengers()) should work?
Or the amor stand UUID which persists betwen restarts
that's smart too
it's interesting that it doesn't work only on that specific stand
on other types of them it's fine
Try adding some debug to your code, and see if it's actually being run
?paste
getting this error:
java.util.ConcurrentModificationException: null
at java.util.HashMap.forEach(HashMap.java:1432) ~[?:?]
idk why tho this is my code:
https://paste.md-5.net/xenomemaju.java
your modifying the map while in a loop
can i not do that?
need to use an iterator if you need to do stuff to all entries
like this?
for (Map.Entry<String, Integer> entry : cooldowns.entrySet()) {
if(entry.getValue() > 0) {
entry.setValue(entry.getValue()-1);
}
if(entry.getValue() <= 0) {
cooldowns.remove(entry.getKey());
}
}
need to use an iterator if you need to do stuff to all entries
how i can put this:
ConfigurationSection:
FieldOne: 50
FieldTwo: 100
...
FieldSixtyNine: 3450
in this?
HashMap<String, Integer> map = new HashMap<>();
ive never used iterators in java, no idea how
for (String key : section.getKeys(false)) {
map.put(key, section.getInt(key));
}
right, thanks
can you ConfigurationSection.getValues() and cast the object or use Integer.valueOf
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
//Implemenr your logic
}
while (iterator.hasNext()) {
String key = iterator.next();
cooldowns.replace(key, cooldowns.get(key)-1);
if(cooldowns.get(key) <= 0) {
cooldowns.remove(key);
}
}
got this but intellij tells me i can use a for loop
for (String key : cooldowns.keySet()) {
cooldowns.replace(key, cooldowns.get(key) - 1);
if (cooldowns.get(key) <= 0) {
cooldowns.remove(key);
}
}
Well, in this case yes, you can use a for each loop, but usually you will use a while
alright
hi i need help how to covect CustomNPC extends EntityPlayer class to bukkit Player?
getBukkitEntity() (if you spawned it)
Hi there! Is there any chance someone can guide me through plugin development? I have a great idea and need some direction. I have followed tutorials and all led to errors that could only be diagnosed by someone who has java skills.
for the people that still use 1.8:
How on earth do i make items unbreakable on bukkit?
can someone help i want make player summon an entity will have all them item like armor , sword and shield can someone help
but when i use "player.getInventory().setContents(p.getInventory().getContents());
player.getInventory().setArmorContents(p.getInventory().getArmorContents());"
an entity not wearing armor just put them into inventory someone help please
How can I cancel a BukkitScheduler task? Here is my code: https://paste.md-5.net/uhidujilow.java
Use overload which have consumer as arg instead of runnable
I'm using scheduler
Not runnable
Anyways how do I do that?
hi, does setVisibleByDefault work on players?
i am aware, but one of you args is runnable
change it to consumer
https://goksi.tech/ this is runnable
its void functional interface with no arg, consumer is same but takes one arg
and that one arg is BukkitTask
which you can cancel
kinda sucks that you cant modify a map within the callback of computeIfAbsent
i mean point of computeIfAbsent is to put something if it isn't present
how would you modify it
i forgot what my usecase was but it was smth with removing data related to eachother
also i just noticed, you are pretty much abusing arrays here lol
like transitive dependencies within the same map
is there an event for players trading with villagers?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/TradeSelectEvent.html is this it ?
declaration: package: org.bukkit.event.inventory, class: TradeSelectEvent
ok.
You should seriously not use a lambda for this. Here is what you should do instead:
https://paste.md-5.net/izabakaveg.java
Ugh the spam..
?paste
Using this is now as simple as
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0 || args[0].length() > 0 && args[1].length() == 0) {
sender.sendMessage(ChatColor.RED.toString() + "You need to provide both a selector and text.");
return false;
} else {
if(sender instanceof Player player) {
UUID ownerId = player.getUniqueId();
DialogueTask task = new DialogueTask(args[1], ownerId);
task.runTaskTimer(plugin, task, 4, 4);
}
}
return true;
}
Probably cause of ConcurrentSkipListMap and ConcurrentHashMap
(I mean still possible, but discouraged)
In what way? It already modifies the map...
question, how do i get the location of the merchant from the TradeSelectEvent?
.getLocation() most probably
After getting the merchant
there is no function like that i found.
if(event.getMerchant() instanceof AbstractVillage villager) {
villager.getLocation();
}
why not just Villager?
Because WanderingTrader is also a Merchant
ok.
And both are AbstractVillagers
could do it with two calls but whatever
loadTag mutates the tags thats why
So this should be my code instead?
Dont use lateinit if you are not 101% sure that you are initializing the value at the right time
what can i do? i aint rlly good in this stuff
even the lateinit got it form the web
Dont use lateinit for now
i am using it so i can access the class in another class, got any other way to do that?
it does not seem to be working.
how do i prevent players from doing villager trading?
what event do i use?
you could probably just cancel the PlayerInteractAtEntityEvent so the menu wont pop up
not sure tho
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Do you want to prevent them from opening the trade menu or do you want them to not be able to trade while the menu is open?
is there anyway to get a player device info ?
I seen this in bedrock plugin development so how about java?
just not trade, does not matter if the trade menu is open.
might get this to work though.
ok it works.
is there an event for player killing a mob?
i ussually use EntityDamageByEntity for that and check if the mob will die by the damage done in that event
Afaik no
EntityDeathEvent -> call getKiller() on the defeted mob
doesnt work well in multi module project
for gradle -> same
Works great for me
do u have any public repo using it
is there an event for lava spreading or fire spreading?
BlockFromToEvent for Lava and BlockIgniteEvent for fire
Second one is a guess
does that work for fire as well?
.
If fire spreads then it ignites nearby blocks
hm.
ok.
another question.
does event.getToBlock(); return the block that was there prior to the event occuring or after the event occuring?
👍 i was missing the configuration part
The state of the Block returned by getBlock() will have the state prior to the event.
This way you can cancel events and prevent the Block from changing in the first place.
is the PlayerTeleportEvent Class triggered before or after the player enters a teleport command?
- command is entered
- teleport is attempted
- event is fired
- if cancelled -> dont tp; else -> tp
makes perfect sense, could have figured out that one on my own, thank you!
Hey @lost matrix i have a question, where should i make all the processes for getting the button lets say and stuff?
MainGUI?
public class MainGUI implements InventoryHandler{
@Override
public void onClick(InventoryClickEvent e) {
int slot = e.getSlot();
Player p = (Player) e.getWhoClicked();
}
@Override
public void onOpen(InventoryOpenEvent e) {
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&f> &aOpened Anvil GUI"));
}
@Override
public void onClose(InventoryCloseEvent e) {
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&f> &cClosed Anvil GUI"));
}
}
Are you doing a menu api?
ye some guis
yesterday he told me my code would bug if multiple players are in the same inv
so i did his tutorial but im trying to understand whats going on
Yes guis are not so easy as they seen to be
yep
Which tutorial?
Can i get it, because i will in some weeks recode my menu api (which im doing public maybe)
So then if you want you can give a try once i recode it
Thanks i appreciate it a lot
Hello i am wondering why i am getting a error message in my code "public void onPlayerRightClick(PlayerInteractEvent e) {
Player p = (Player);
Location loc = p.getLocation();
Player player = e.getPlayer();
if (e.getAction().isRightClick()) {
if (!e.getItem().getType().equals(Material.FIRE_CHARGE)){
{
p.getWorld().spawnEntity(loc, EntityType.FIREBALL);
}
}
}
}
}"
Wdym? sorry if im dumb im new to coding
you dont need it either
You should learn Java before trying to code plugins, not being rude
just delete that line
yes i do
??? hes not being rude
because otherwise i get this error:
Location loc = p.getLocation();
it doesnt understand what p is
He? I didnt said he was rude, you mis read the text
and i want the p do be player
replace Player p = (Player); with Player p = (Player) sender;
some hacking clients are able to detect which potion effects player have. how do they do this?
its PlayerInteractEvent
you dont need a sender
you don't have sender
the sender is in the colour red
it's an event listener method, there is no sender
my bad, didn't see that, yeah, you don't need that since it's not a command ;-;
so i should replace the p with e
What api version are you using?
no, e is the name of your event and is already defined
rise 6 and future client on top
i've seen videos that shows other players armors and potions
?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.
What i said from the start - haha, i said not being rude, but if you are new, you should learn java before coding
Sry i dont understand what that means
yeah i did that but nothing changed it still doesnt know what p means
some hacking clients are detecting other players potions and showing on screen. how do they do this?
Location loc = p.getLocation(); it eoesnt understnmad what the p means in this statement
you just have to write code with sunglasses on
They simply listen to incoming meta data packets.
If an entity gets a potion effect then all players
are notified of that.
That's not possible if you changed it correctly.
i can show you my new code
then do that
Dude you should really learn java first, you are making job harder for both you and us
¯_(ツ)_/¯
true
sorry
- Never use single letter variables like "e" or "p"
- You really need to learn the very basics first. Do yourself a favour,
Sorry, not trying to be rude, but you don't even know concept of variable
fixed it
it was my own stupidity
thanks
Sorry for asking you, but i know you have xp with Redis, im having issue while posting data to each server channel, because they listen to the self data they publishing but also, all servers received the data. But the most weird thing is that im using different channels for them
Which redis library are you using?
Jedis*, i know its really bad, but just for starting, then i will update it to Lettuce
So i have the next channel pattern: <identifier>:global for all servers data and <identifier>:<server> for each server data
Show some code of your publisher and subscriber
right
So yesterday i followed your tutorial for GUis and i wanna rlly understand whats going on for just replicating in another plugin but by myself, so, i wanna understand what class is doing. So i have some questions, you matter if you can solve it to me?
Sure
So, the classes GUIListener and GUIManager are equal to the forum post, but what are they actually doing more than register and unregister the active inventories?
https://paste.md-5.net/keyovaguke.java - There you have the subscription and publishing logic
https://paste.md-5.net/wedajukeko.java - There you have the message listening from redis
https://paste.md-5.net/zahunihimo.java - Basic implentation example if you are not sure how it works
This is such a stupid question but i have nightmare. Currently ive been around 4hrs trying to fix this problem
Im just trying to implement, that each server doesnt listen to his own published data and also when im sending to a specific server channel, all of the servers receives the data
does anyone know of an easy way to use anvil GUIs?
Where you doing those diagrams? I always want something like that app name
There's not. You must mess up with nms,, use a library or use chat
Why chat?
This is the most prominent library currently:
https://github.com/WesJD/AnvilGUI
You cant
If you want to catch an input of the user, you can use the chat, cancel the chat event and read the input
i was shift-clicking and i could take the items out.
i can show on video.
Then you misused the library
I have been using this for years and never had any issues
Doesnt TextField exists? for anvils
Lucidchart is cool
new AnvilGUI.Builder()
.itemLeft(createItem(Material.RED_STAINED_GLASS_PANE, 1, "[Cancel]"))
.itemRight(createItem(Material.GREEN_STAINED_GLASS_PANE, 1, "[Proceed]"))
.onLeftInputClick(player -> {
player.closeInventory();
})
.title("[Change Name]")
.text("")
.onComplete(completion -> {
player.sendMessage(completion.getText());
return Arrays.asList(AnvilGUI.ResponseAction.replaceInputText(""));
})
.plugin(ChunkClaimsPlugin.getThisPlugin())
.open(this.player);```
Oh ok thanks
That requires NMS or use a library, if you don't want to use them, the only option is chat, a book, or signs, but no one would use sign to catch user input
Hypixel has entered the chat
Anvils do work
Yeah i mean with NMS, because by default api "you cant" do that
how do i use it?
Yo, how can I make a clickable text in books ?
You are just doing a wrong implementation, most of the problems are caused 99% by us, devs
I don't exactly know how, but I wouldn't recommend neither. Anvils are a pretty good choose.
https://www.spigotmc.org/threads/solved-open-sign-gui-get-input-from-player.380079/
what is the right implementation?
Spigot doesn’t have api for components in books yet does it
No, i dont think it has
Which of those items could be retrieved? The left or the right one?
NMS or some third party API
left.
wait
let me just launch minecraft.
Delay the close by one tick. I dont think you are allowed to close the Inventory in the click event
ok.
You could use BetterInputs it allows for Anvil UI usage atleast on 1.16.5-1.19.3, just check for it on spigot
I think 1 tick won't be enough, if it doesn't work, try directly with 5
Bukkit.getScheduler().runTaskLater(ChunkClaimsPlugin.getThisPlugin(), () -> {
player.closeInventory();
}, 1);```
This does not make sense. 1 tick delay is based on the handler being unregistered on close.
Always kind of annoying to delay stuff by a tick
Maybe, but I had problems delaying 1 tick to re open an inventory after being closed, I had to delay at least 10 ticks
Gotta have your plugin instance :/
DAMNN THANKS
You should not close inventories if you want to open another one.
Just open the other inventory right away. It will simply replace the current
inventory (and not reset your cursor as well)
huh, that seems to have fixed it.
Had a good guess then
that was a guess?
You aren’t meant to open an inventory directly in the click event either
Not when the client closes the inventory
My guess was that the handler was being unregistered on close which prevented the click from being cancelled.
Smile, something weird is happening, for some stupid reason the data published to global channel is correctly, but when publishing telling the receiver server, the JedisPubSub listener acts like if nothing wasnt received
Channel name mismatch
Print out the channel names for pub and sub
Anyway, main problem fixed, yay!
Guys, how do I fix tabs in commands? When entering a command, it returns a list of arguments to me, but it is "static". Let's say it returns me a list of the words "apple", "orange", "lemon". And when I start typing "le", the list of hints does not shorten and hangs on the very first option.
In my case, this is a tab at the command /warp, I attach screenshots below
anyway, how do i get the text from the textfield?
when the green glass pane is clicked.
Im printing out the channel from JedisPubSub onMessage() and is seems not being called
StringUtil.copyPartialMatches
i just wanna get the text only if the green glass pane is clicked.
if that is possible.
Where should I apply it? Before return?
You are not handling your CompletableFuture exceptions
Iirc you can return the result of the method directly
right, thats true
I will handle them
Since it returns a List<String>
public CompletableFuture<Void> something() {
return CompletableFuture.runAsync(() -> {
// DO stuff
}).whenComplete((result, throwable) -> {
if(throwable != null) {
throwable.printStackTrace();
}
});
}
Example
Right i should add to each publisher right?
okay, thank you
I usually append a handler for exceptions in my CF before i give them away so that i dont forget them.
So yeah, right when they are created.
Had too many cases with hidden exceptions 🥲
okay now yes
😡 shity jedis pool
Thats causing the issues, its said me that it has the max jedis pool usage that he can use
how did this person do that with the anvil GUI?
Bottom is the players inventory. Then he simply checks when the input field changes
and re-evaluates the content that is being viewed
AnvilInventory#getRenameText()
welcome to futures
how do i get the anvil inventory?
I made my own future class that just delegates to CF but doesn't hide exceptions
I call it FancyFuture
i was not able to type cast the inventory object earlier.
it also has helper methods like thenSupply(newValue)
✨Fancy✨Future
yea
CF? Whats that weird slang
CF -> CompletableFuture
oh bruh, you must write a book for those type of words, POO, CF, NPE
my favorite
please a book for how patch spigot xd
Tbf I think it’s because it has minimal examples
I made my own conversation api
It took a bit to figure out how to use it
I don't like spigot's that much
my servertutorial plugin uses it
it just doesn't vibe with my code style
and that is what I use to point to people for examples
@lost matrix, GUI manager is the one in charge for processing all the events, right?
Been working on a scripting system lately
it has like 20 different functions, not just the 2-3 shown in the sample
Compiled or interpreted?
The GUI manager doesnt have any logic in it. All it does is look at the map, check which inventory
was clicked and forward the events to the handler of those inventories. Each handler can now
decide for itself what to do with this event. The manager's only role is to transport events to where they are needed.
the text line gets converted to an object that looks like this
Hmm okay
To play, I just have a List<CompiledObjective> and each objective should call incrementStep to play the next queued objective
So for example, the wait 50 ticks method just calls incrementStep 50 ticks after
It's just something quick that I came up with in like an hour
Ok so I applied and adapted this code, but now, when I run the command correctly, the task is not triggered, and it does not give me an error message. I tried putting code before and after running the task, and that code ran. DialogueCommand: https://paste.md-5.net/foduvubiko.java DialogueTask: https://paste.md-5.net/pukitizaro.java
wtf
Remove that method, (lol !?)
So the one that has logic in it is the Listener, and then in the Handler interface i code in it or where should i code the logic?
https://pastebin.com/raw/SwPTkAUJ These are not warps, but the essence is the same (my other plugin).
Don’t pass the same list for both params
The listener doesnt need to be touched. The manager doesnt need to be touched.
All you need to do is:
- create an inventory
- create a class which implements InventoryHandler
- register this inventory with this handler
- open the inventory
Pass an empty list for one of em
oh, okay
Okay
You will always only have 1 listener and 1 manager.
But you will have a lot of different InventoryHandlers (like shown in the diagram)
return StringUtil.copyPartialMatches(args[1], artifacts, Collections.emptyList()); that will be okay?
Yess
Thanks
Finally understood
Probably not since Collections.emptyList will be immutable
But now the second task is underlined red in DialogueCommand? task.runTaskTimer(plugin, task, 4, 4);
Okay, guys
Ah yeah. You dont need that.
task.runTaskTimer(plugin, 4, 4);
It's work! Thank you much
So all the errors are gone including that one, but it gives me An internal error occurred while attempting to preform this command.
Then solve the error
There is none
Look in your console/log file. There is one
Nope thats not normal. This means you are giving too much time to the plugin
config file
Are you running paper or spigot?
are there any good methods to sort of benchmark how much bits of code are contributing to overall server lag? right now im just recording the system nanos and comparing it to various places in my code, but this seems to indicate accessing a simple map once takes 0.15ms which seems like a lot for such a simple action so i figured it must be coming from the logging process
MaxMillisPerTick: 22.5
AsyncChunkLoadingEnabled: true
HighAsyncPriority: false
Spark
spark only shows the classes that are contributing to the lag, but i already know these classes