#help-development
1 messages · Page 459 of 1
Are the names of the beacon sections unchangeable e.g. Primary Effect Secondary Effect they are called iirc
alr just making sure
I'm going to get addicted to doing spigot PRs
I just need feedback on this one to make sure there are no stupid ass mistakes like formatting wise before I go crazy
Did you google it?
?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
no but can u tell me???
Maybe ask google first
....
I'm being 100% serious
Google your question before asking it:
https://www.google.com/
I just typed in your question and it pops up right there highlighted
no
yes
how to resolve it no
type in cannot resolve symbol into google
and then cannot resolve symbol how to fix
i cant fix it
i cant find an answer
Show your code
package me.adamel.gam;
import org.bukkit.event.Listener;
public class BlockBreakListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material material = block.getType();
for (player : Bukkit.getServer().getOnlinePlayers()); {
if (player.hasPermission("admin")) {
player.sendMessage("A block was broken by " + event.getPlayer().getName());
}
}
}
}
}
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
import org.bukkit.event.Listener;
public class BlockBreakListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material material = block.getType();
for (player : Bukkit.getServer().getOnlinePlayers()); {
if (player.hasPermission("admin")) {
player.sendMessage("A block was broken by " + event.getPlayer().getName());
}
}
}
}
}```
ooops
forgot to put java
Oh lol you did actually grab alex's code
import org.bukkit.event.Listener;
public class BlockBreakListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material material = block.getType();
for (player : Bukkit.getServer().getOnlinePlayers()); {
if (player.hasPermission("admin")) {
player.sendMessage("A block was broken by " + event.getPlayer().getName());
}
}
}
}
}
?
Here is your problem. Google how to properly do a foreach loop:
do i need to just put Player in front of it?
Try it out. This will lead to a different problem
What do you not get?
i see that i have to put (Player player, instead of just (player
it might help if you say what those are occuring on
on a lot of things
Well then you are calling a method that doesnt exist.
Learn the very very basics of java before you jump into spigot pls.
hover over anything red and press import class
Then you didnt even add Spigot to your project
i did
its copied and pasted code so imports wont exist auto
bukkit spigot
you need to import the clases
where
yes
and press it
they should appear when you import the classes
Anyone had success using native code in a spigot library? Been thinking since I have some stuff I'm worried about performance for
ok
FWIW, I'm primarily a C++ dev nowadays and therefore not a huge fan of Java anymore, so if I could offload performance-critical code to a language I actually like...
Imagine liking to write C++ in 2023
Java has the JIT compiler which optimizes your code on runtime.
Partially to the point where it matches the performance of low
level languages like C++. The overhead of calling native methods
does not justify using a machine code compiled language like C++.
The C compiler also optimizes for exactly your system. There is a good
chance that your code will run much slower on other systems and
for a different OS it wont even run in the first place. I can almost guarantee
you that you will lose performance by using C++.
does getchunksAt automatically unload when no players are there to load them?
Yes, depending on your chunk caching leniency, the chunk will be unloaded shortly.
You could prevent this by holding a reference to the chunk (not recommended) or
adding a chunk ticket to the chunk.
Ok sweet I'm trying to have some chunks load so that players don't fall through the ground whenever they switch servers
That might be a bit difficult. Because you cant just request the chunk and then immediately tp the player.
am I not able to do that through plugin messaging
like say to the proxy hey load these chunks and then send the player
Because the server does exactly that. So your approach would be:
- Communicate to the server that a player wants to connect
- Find out where the location would be
- Load the chunk
- Send feedback from the chunk loading server
- Send the player to the new server after the feedback
here i wrote material, but i wrote after A block was broken, how could i set, that he says me the block
should i just remove A block and place it with block.getType?
right?
Did you already add Spigot to your project?
Otherwise you wont come far.
i downloaded the minecraft development plugin
then created a project with spigot
Alright that should do it.
You can tell a player which block he broke by getting the Material of the broken Block
and appending it to a String.
String message = "You broke " + material;
Then simply call Player#sendMessage(String)
waiting for the "why does it error"
lemme try
Maybe we should just spam basics for questions like this...
they've been asking questions like this or worse all day
spamming basics does nothing they won't listen or read
i dont know where the problem is
you wont listen
I'm confused on softdepends
Is it just like, so long as I avoid using classes from a non-existent softdepend, the plugin is allowed to run?
yea basically
Yeah. You just need to be careful and not load those classes with the ClassLoader.
A bit tricky at times
You didnt register the listener probably
where do i register it?
google is my friend
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Scroll down here. All you need to know about commands, events etc
a quick question
How do I show text when a user is entering an argument without providing tab completions?
Where do you want to show the text?
as i showed earlier i put the string for the registration of BlockBreakListener, is it the same as the registration of Listener?
Where the tab completions would normally show
Then... use a tab completion
but I don't want the text to be tab completable
I've seen it done in plugins before
It's like, darker gray text
like <name>
but it doesn't actually tab complete anything
You need brigadier or another command API exposing this feature.
I dont think Spigot has anything beyond simple tab completion.
But double check. I havent touched spigots command features in ages.
I cant make any sense of that sentence.
''' public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvents(new BlockBreakListener(), this);
}'''
oops
ive put this
like before i even tested it
can anyone pls test the plugin and tell me the problem?
i tested it lol
no it says enabled
Show your current code then
?paste start with your BlockBreakListener
you have issues with your encapsulation
yes
Hi
how do you publish a multi-module gradle project into one jar
look at epic spigot lib
I did
should this work?
By compiling?
I'm not sure what I'm doing wrong
is it on github
yes
because nothing in my project is showing up when implementing it
lemme try
I left the block stuff in as I guess you are going to do something with it later
?paste
does this look right https://paste.md-5.net/odakafoder.cs
I mean I mostly referenced your lib.
I'm publishing with
publishShadowPublications
ok thx
use publish instead
but u removed player
but that looks correct yeah
yes, you never used it
looks fine
you need to restart
or do i need to remove it and place it again
stop/start yoru server
so it will update alone?
if you set the build path sure
if i click on save all
on the server?
if not no you have to manually move the new jar onto the server
no save all doesn;t auto build, unless configured to
how do i do that?
bc i dont have an out folder
the way you have up until now
what?
are you the person from yesterday using export?
have you ever had an issue with aggregateJavadocJar taking a long time
yes
then do an export
they moved to maven and intellij
stop server, upload jar to yoru plugin folder and startup
i dont think so
I'm confused why its taken 5 minutes then lol
wonder what is wrong
oh they moved to IJ 😦
dafrick?
Don;t worry over time I'll call you every pronoun there is 😉
guys, export files or something to HTML, project to eclipse or project to zip files?
run mvn package
what?
on the right of your screen do you see a maven tab
yes
dopen it
if you are now on InteliJ, right of screen is a maven window
yes
then open the drop down, then open life cycles
package
package
it opened the cmd
now look in your target folder
/target/
wherever your project is saved
i dont know where he saves the projects
it should show in the project structure on the left of your screen
you made the project
yes
correct, now you copy the jar YourProject.jar into the plugins folder
look in your target folder, not your src
there should be around 4 folders and 2 jars in the target folder
whats it called
GAM-1.0
use it
so test it
is there an event where if player obtains item through creative menu or /give do something?
There is the InventoryCreativeEvent for creative actions and you can listen for commands
okay
Do be aware that every item move in the creative inventory will trigger that event
Since the client deletes the item and then spawns it back in
what a jerk client
boycott the client. Server-side minecraft only from now on
It works finally
but
i would like to add that who has the "admin" permission, and breaks a block, they dont get the message
Then add that
yes
i wrote a code but idk if its correct
and i tested it but didnt work
can someone check if its correct?
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
if (event.getPlayer().hasPermission("admin") return;
only that line?
at the very top
ooooh really?!??!?!?!
to be read with a sarcastic voice
?tryandsee
?basics
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.
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
?issamreal
Yes Sam is real. I was not programmed to say this by Sam.
i wonder if sam is real...
No, Choco is not real. I was not programmed to say this by Sam.
good question
guess not
oh dang
on top the imports' lines?
lol
eventhandler?
so funny, right?
in the event method body
They couldn't be bothered to learn Java when we told them yesterday
the next line after the {
They require spoonfeeding of code
after implements listener
Is this acc run by a group of people?
he doesnt know my pronouns
so thats why he uses They
wtf... you guys are joking, right?
no
no in your method, the one you annotated with EventHandler
Nope, we use whatever seems correct. don;t give two shits about pronouns
?
on top of that?
@EventHandler
public void onEvent(SomeEvent event) {
// <-- here```
thx
no prob

idk if it's really spoonfeeding i just have no clue how to describe it otherwise so 🤷
is it ok to put Player player = null; before that?
it suggests me to do so
Just looked it up in the dictionary. They is only used to refer to a group of people.
We would need to see the full code in order to answer this
if you were to e.g., talk about someone who left their umbrella somewhere but their coat was obscuring their face, what pronoun would you use seeing as you can't identify their gender?
https://youtu.be/gq5xLI77TGA
A sequel to: https://www.youtube.com/watch?v=iQNdkdqoIdw
Thanks to my patrons!!
Patreon: https://www.patreon.com/user?u=73482298
Special thanks to Calvin for pestering me until I made this video.
Sources:
Baron, D. (1981-2015). The Words that Failed: A chronology of early nonbinary pronouns.
Baron, D. (1986). Grammar and Gender. New Haven.
Bar...
generic "he" i suppose?
hm, i see
You are German and german is a very gendered language. You shoudl be good at this
most people would use they
i use always he
👀
There are no girls on the Internet so I use he/they/them when talking to people
Anyways. Your code makes very little sense.
You are iterating over all players on the server but you always check the
permission of the player who broke the block.
mmmh
...that is indeed true, the rules of the internet do state that there are no women on the internet
And you return in the middle, which makes half of your method useless
yeah, he changed the code. thats not what I showed him
yea bc i got problems with "player"
Go back to the code I gave you, it works and it only needs you to add the single line I just showed
You are being unpolite by not learning the basics of the language
but asking us to practically write the code for you.
ok
That linguistically makes sense.
Ill always use thone from now on.
add the line I gave you a minute ago
You are contributing to him coming back for more grießbrei to be fed on a spoon
yep, I'm hoping he learns a little
At least he seems able to handle jibs and jabs.
how do i tell it to use the updated version of my root module?
its all in the same project
ofc its not on maven
You need to publish them to your local maven repo
It would be an idea for him to spend an hour learning the basics
ok and?
btw going to test it
one of those?
totes, g'luck calling people that in the modern day
And this will lead to you not learning anything.
If you would sit down and learn the basics of java then
you would be doing all of this on your own by now.
It only takes maybe an hour to learn control flow
and loops.
i am learning something, wdym?
The one you appended the publish task to
install should work
package = just build it.
install = clutter up your local repo,.
Why are you using gradle for a multi module setup?
I feel like thats a weakness of gradle.
thats maven
Just realised
kekw
lel
Werent yout talking about gradle earlier?
that was y2k
In that case you should just run the parent project task
so when you only want that module?
well it works
Yes if the other modules didnt change then you dont need to build them again
alr
how come ClientboundSetEntityDataPacket(int, SynchedEntityData, boolean) is not a valid constructor in 1.19.4
migrating my code from 1.19.1
In 1.19.4 metadata is packed into a List of delta values.
sendPacket(sp, new ClientboundSetEntityDataPacket(armorStand.getId(), armorStand.getEntityData(), true));
that's what i have
how would i change it
How dare you
i have not touched java in a few months
Uh oh... Mr gradle woke up
run
SynchedEntityData data = this.nmsArmorStandBackbone.getEntityData();
return new ClientboundSetEntityDataPacket(this.nmsArmorStandBackbone.getId(), data.getNonDefaultValues());
Or
SynchedEntityData data = this.nmsArmorStandBackbone.getEntityData();
return new ClientboundSetEntityDataPacket(this.nmsArmorStandBackbone.getId(), data.packDirty());
smh i always forget one thing when pushing a commit
Writing a comment thats no "Added some stuff"
For me its "Batch update" for the last 17 commits
would i need the true at the end anymore
i forgot what it did
its kinda better for me
I often forget to check the commiter email so sometimes it is the BT email.
guys
?paste
Hello I am having some problems. I want to make a command where a person have to enter their coords and the blocks in the coords will become unbreakable meaning after breaking it. it will replace itself. here is the commands class:
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("setup")) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be run by a player.");
return true;
}
Player player = (Player) sender;
if (args.length != 6) {
player.sendMessage("Usage: /setup <x1> <y1> <z1> <x2> <y2> <z2>");
return true;
}
int x1 = Integer.parseInt(args[0]);
int y1 = Integer.parseInt(args[1]);
int z1 = Integer.parseInt(args[2]);
int x2 = Integer.parseInt(args[3]);
int y2 = Integer.parseInt(args[4]);
int z2 = Integer.parseInt(args[5]);
for (int x = Math.min(x1, x2); x <= Math.max(x1, x2); x++) {
for (int y = Math.min(y1, y2); y <= Math.max(y1, y2); y++) {
for (int z = Math.min(z1, z2); z <= Math.max(z1, z2); z++) {
Block block = player.getWorld().getBlockAt(x, y, z);
BlockData blockData = block.getBlockData();
BlockState blockState = block.getState();
player.getWorld().getBlockAt(x, y, z).setType(Material.AIR);
blockState.setBlockData(blockData);
blockState.update(true);
}
}
}
player.sendMessage("Setup completed!");
return true;
}
return false;
}
}``` After fullfilinTheRequirmentItshowSsetupCompleteButItDontWork
how would i remove player info
doesn't work now either
ClientboundPlayerInfoRemovePacket
i believe i use that
My guy is skimming all my updated code...
new ClientboundPlayerInfoRemovePacket(List.of(this.serverPlayer.getUUID()));
do i have to run the command or are you smart enough to know whats coming
already did alt enter
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
goodmorning
there is no bukkit import for block
only html
so you have a broken dependency
what does that mean?
unsure if this is related but
[19:33:14 ERROR]: Packet encoding of packet ID 82 threw (skippable? false)
java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "trackedValues" is null
i get that whenever i join
So what you are currently doing is this:
- Set the block to AIR
- Set the block back to its original type
This does exactly nothing
and how do i resolve the problem?
either maven has not downloaded the dep right or you have dep info wrong
because bukkit has the Block class
lol
im trying to get the block in the coordinate and replace itself
if broken
how can i do that
This packet does something. ID 82 is 0x52 in hex
order matters
is it ok if i write Block block = null;
it wont work and you will get an npe
first learn java then you can answer that yourself
oh it works now
in yoru paste you try to get teh BlockState from block before you created the block variable
thx guys <333
pls someone help me
You need a manager that keeps track of all marked blocks.
Then you need to listen for events like BlockBreakEvent and
check if a marked block was broken
All the code you have there runs in an instant. Just a millisecond.
There is nothing that actually tracks broken blocks or respawns anything.
rate my strat (I have never tried this before so lemme know if its trash or good)
I have created a seperate package named "Helpers" and in that I have diff classes for diff kinds of functions which are mainly just meant to do repetitive tasks
whenever I have to say, just send a custom error message to the player and know what the name of the error is, I have a function to which I supply the name and it takes care of it instead of me writing the code over and over again
I know that this is supposed to be good cuz it follows D.R.Y. but im not sure if there is an even better way to do it
utility and helper functions?
its mostly good
but its good to know the difference between helper functions and utility ones
so like would my error function thing come under util or helper?
cuz i think util is like opening the same type of inv or sumt over and over again no? (example)
It’s a good practice to avoid repeating code and to keep your code DRY. It makes your code more maintainable and easier to read. You can also consider using a library or framework that provides the functionality you need instead of writing your own functions. This can save you time and effort in the long run.
It depends on how you want to organize your code. You can use either “util” or “helper” depending on your preference. Both are commonly used to store utility functions that are used throughout your codebase. You can also create a separate package for error handling if you have a lot of error handling functions.
Yes, it’s okay to use “util” to store functions that perform similar tasks. The difference between “util” and “helper” is mostly a matter of preference and how you want to organize your code. You can use either one to store utility functions that are used throughout your codebase.
that was from ChatGPT wasnt it
Bing haha. But i curated it obv.
should I name the currency in my plugin "boops" :p? lol
Sure! Here are 20 outrageous names for an online currency not connected to any real money, but used in-game:
Zappies
BlastBucks
ZapCoins
BoomBucks
ThunderTokens
LightningLoot
ShockShards
BoltBucks
ThunderTreasure
ElectricEarnings
SparkSavings
ShockingShillings
ThunderousTollars
BoltBling
ElectricEmpire
ShockingSovereigns
ThunderousTreasury
BoltBounty
ElectricEconomy
ShockingSavings
I hope you find one that you like!
Received message. Sure! Here are 20 outrageous names for an online currency not connected to any real money, but used in-game: 1. Zappies 2. BlastBucks 3. ZapCoins 4. BoomBucks 5. ThunderTokens 6. LightningLoot 7. ShockShards 8. BoltBucks 9. ThunderTreasure 10. ElectricEarnings 11. SparkSavings 12. ShockingShillings 13. ThunderousTollars 14. BoltBling 15. ElectricEmpire 16. ShockingSovereigns 17. ThunderousTreasury 18. BoltBounty 19. ElectricEconomy 20. ShockingSavings I hope you find one that you like!
Shocking Shillings kinda fire
is possible to save information relative to the player not inside a DB or a yaml file, but like in .dat file or in file that you normaly you cannot edit or see
why
I'm saving from advanced slime world, the world string, and its unique for every player instead of saving it inside a yaml that will take many GB saving in sections like .dat file or any other to make lighter everything else and not accumulate string over strings
okay, then yeah, you can use pdc
pdc is for newer version like 1.16 and im making a plugin for 1.12.2 for a client
i don't know he just asked for this
real chads only support 1.20 snapshots
then just write to a file
if you are working with a legacy version you should be paid twice as much
im getting paid 50 bucks for a easy job
how easy
just loading a world with slime world and then tp the player inside an save it when the player quit
I'd ask for 100
because 1.12
but why not use yaml, have you tried?
yes, but gets a mess after 2 player
in what way does it get messy
like this
uuid1:
world: "eihfhsuvgyryghgnrfhiht==EUEUIHTUET4845==Fihughrhfujvgjgbidjbjfuht9uhuhdh99uhu9hbjhbcujh9udt9hu ... and for other 30 lines"
what even is that
Looks fine to me
that does look pretty cool
but my eyes would prefer the "normal click left/right arrow buttons and the thing slides away completely" more
but yeah that does look good tho
public void showPlayerBank(Player player, UUID targetUUID) {
Inventory inv;
OfflinePlayer target;
if (player.getUniqueId() != targetUUID) {
target = Bukkit.getOfflinePlayer(targetUUID);
inv = plugin.getServer().createInventory(null, 27, "&a{name}'s Bank".replace("&", "§").replace("{name}", target.getName()));
} else {
target = player;
inv = plugin.getServer().createInventory(null, 27, "&aYour bank".replace("&", "§"));
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
PreparedStatement statement = plugin.getConnection().prepareStatement("SELECT purse, bankStored, bankLimit FROM pdata WHERE uuid = ?");
statement.setString(1, String.valueOf(targetUUID));
ResultSet results = statement.executeQuery();
Integer purse = results.getInt("purse");
Integer bankStored = results.getInt("bankStored");
Integer bankLimit = results.getInt("bankLimit");
for (int i = 0; i < 27; i++) {
ItemStack item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("");
item.setItemMeta(meta);
inv.setItem(i, item);
}
// Purse item
ItemStack balanceItem = new ItemStack(Material.PAPER);
ItemMeta balanceMeta = balanceItem.getItemMeta();
balanceMeta.setDisplayName(("&6Purse: &a{purseMoney}")
.replace("&", "§")
.replace("{purseMoney}", String.valueOf(purse))
);
balanceItem.setItemMeta(balanceMeta);
inv.setItem(11, balanceItem);
// Player head item
ItemStack skullItem = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) skullItem.getItemMeta();
skullMeta.setOwningPlayer(target);
skullMeta.setDisplayName("&f{name}".replace("&", "§"));
ArrayList<String> lore = new ArrayList<>();
lore.add("Total Money: {amt}".replace("{amt}", String.valueOf(purse+bankStored)));
skullMeta.setLore(lore);
skullItem.setItemMeta(skullMeta);
inv.setItem(4, skullItem);
// Bank item
ItemStack bankItem = new ItemStack(Material.GOLD_BLOCK);
ItemMeta bankMeta = bankItem.getItemMeta();
bankMeta.setDisplayName(("&6Bank: &a{bankMoney}&7/&a{bankLimit}")
.replace("&", "§")
.replace("{bankMoney}", String.valueOf(bankStored))
.replace("{bankLimit}", String.valueOf(bankLimit))
);
bankItem.setItemMeta(bankMeta);
inv.setItem(15, bankItem);
} catch (Exception e) {
e.printStackTrace();
}
});
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inv));
}
how does it look
(opens an inventory with items that show the player's purse balance, bank balance and their head with total balance)
i have also just noticed that my R key is starting to malfunction, time to claim that warranty ig
- Dont compare UUIDs by using == / !=
- Dont use wrapper for ResultSet returns (use
intinstead ofInteger) - This entire method should 100% be split into several sub-methods.
Never write an uber method like that. A method should only have one goal
and not 20 like yours.
how can you split it up in a way where this method doesnt have these goals
I mean I agree with most of what you said, but in the end this method will still do all the things it does now, directly or indirectly
For example:
public BankData requestBankData(UUID playerId) {
//...
}
public ItemStack createBankItem() {
//...
}
public ItemStack createBalanceItem(BankData bankData) {
//...
}
that itemstack is always the same too
well yes but then the showBank method will be a chain of these sub methods right?
Yes ofc. In the end, everything is done by a single entrypoint in every application. Thats the "main" method.
yeah so it will still have these 20 goals, but just divided into multiple methods
i mean thats fine but I just wanted to clarify
itembuilder 🙏
Anyone here know if its possible to have a Generic "Event" in an abstract class so when extending i can declare the event? (Using it for a Quest system that will have different types of events)
is this what you're looking for? (scroll down to part 3) https://www.spigotmc.org/wiki/using-the-event-api/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Not exactly - Basically i have a class like so
public abstract class BaseQuestListener<T extends Event> implements Listener {
private final Quest quest;
public BaseQuestListener(Quest quest) {
this.quest = quest;
}
@EventHandler
public void onEvent(T event) {
this.runQuestEvent(event);
}
public abstract void runQuestEvent(Event event);
}```
however i get the error about static handlers
you cannot listen for the Event base class
what should i use instead?
cant you have a QuestEvent class or something that all your quest events extend?
then have a listener for that
so like a custom event?
ig thats what you're trying to achieve
alright yeah ill give it a go
got it.
You should not dynamically register listeners like that
ok so im trying to make another method for grabbing the actual bank data and I am confused as to why it says "unexpected return value" when i am returning a ResultSet when i am supposed to return a ResultSet
This what you are trying to do:
"Execute the query in the future, but give me the result right now."
If you remove the scheduler then the one calling this method has to make sure that its not called from the main thread.
What is the earliest version that has remapped mojang?
how should I do that?
2 options:
Also pass a Consumer or return a CompletableFuture
I believe 1.17
So with remapped-mojang I don't need to make separate maven module for the other versions right? For 1.17+ versions.
public static ResultSet grabBankData(UUID targetUUID) throws ExecutionException, InterruptedException {
CompletableFuture<ResultSet> result = new CompletableFuture<>();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
PreparedStatement statement = plugin.getConnection().prepareStatement("SELECT purse, bankStored, bankLimit FROM pdata WHERE uuid = ?");
statement.setString(1, String.valueOf(targetUUID));
ResultSet resultSet = statement.executeQuery();
result.complete(resultSet);
} catch (Exception e) {
e.printStackTrace();
}
});
return result.get();
}
is this the right way to do it?
Those versions still change a lot.
So you will have to create a module for each version either way.
But in many cases you can just use the same code.
doesnt make a lot of sense
return the future and dont call .get() on it
Also not after returning it
ok so I removed the .get()
return CompletableFuture.supplyAsync(() -> {
//..
return resultSet;
},runnable -> Bukkit.getScheduler().runTaskAsynchronously(plugin,runnable));
now when I get the future after running the method, will it just work like a normal resultset or will I have to extract the set from it in some way first
Guys
Oh no...
class myListener implements Listener {
/*
Le hashmap sono delle variabili che associano
un oggetto chiave ad un oggetto valore. Per
questo codice assoceremo una Location (posizione + mondo)
al Player che controlla quel blocco.
*/
HashMap<Location, Player> placedBlocks = new HashMap<>();
@EventHandler(priority = EventPriority.Monitor)
public void onPlace(BlockPlaceEvent event) {
// Se un altro plugin ha cancellato l'evento ritorna
if (event.isCancelled()) return;
// Registriamo il blocco assieme al proprietario
placedBlocks.set(event.getBlock().getLocation(), event.getPlayer())
}
@EventHandler(priority = EventPriority.Monitor)
public void onBreak(BlockBreakEvent event) {
// Se un altro plugin ha cancellato l'evento ritorna
if (event.isCancelled()) return;
Location location = event.getBlock().getLocation(); // Prendiamo la location
Player player = placedBlocks.get(location); // Prendiamo il player
// Se non l'abbiamo mai registrato o il blocco è il suo ritorna
if (player == null || player == event.getPlayer()) return;
// Ormai è stato rotto quindi lo togliamo
placedBlocks.remove(location);
for (Player player : Bukkit.getOnlinePlayers()) { // Per ogni player nel server
// Se è admin manda il messaggio
if (player.hasPermission("my.permission.admin"))
player.sendMessage("Un malandrino ha distrutto " + getString(location));
}
}
private void getString(Location location) {
return "x="location.getBlockX() + ", " +
"y="location.getBlockX() + ", " +
"z="location.getBlockX();
}
}
Ignore the Italian script
?paste
Should this work?
I wanted something like; if player breaks a natural block, then don’t send nothing
nvm I have to run .get() outside i think
cuz its still a future
If instead is a block placed by another player then send me a message like; player broke “block”
Why not test it yourself?
The CompletableFuture contains a value somewhere in the future.
You can use this value by describing a pipeline.
This pipeline will be used as soon as the value is available.
And never call .get() on the CF
I’ll be always here dear
I think you have to store all player placed block's coords somewhere
or location data
Yea I should
But how?
How do I store it
ChatGpT helped me a lot
But how do I store infos?
Ask ChatGPT
sword, pickaxe, helmet, leggins etc is repairable?
id use
public static CompletableFuture<ResultSet> grabBankData(final UUID uuid) {
return CompletableFuture.supplyAsync(() -> {
// code
});
}
if you want it instantly you can call .join()
Meh. This uses the common fork join pool.
You usually dont want that.
ok then specify executor
use a database
Can anyone check if I wrote the script well?
I’ll use a .txt document
ChatGPT wrote the script well*
bruh
No?
What
No need to store anything for now.
Make sure what you are trying to do even works in the first place.
this.playerArrayList.forEach(tp -> {
Player player = Bukkit.getPlayer(tp.getUniqueId());
int spaceCount = 20 - player.getName().length() - Integer.toString(tp.getTokens()).length();
String finalString = player.getName() + StringUtils.repeat(" ", spaceCount) + tp.getTokens();
player.setPlayerListName(finalString);
});
Hi all, I'm trying to display the player name left-aligned and the number of tokens right-aligned in the tablist, however the final tablist does not display the correct number of spaces.
Is there a limit to how many spaces can be placed consecutively?
It works, don’t u follow my messages???
I told u guys that everything works fine
Thanks to my dear friend
(ChatGPT, but shhhhhh)
if everything works fine then congratulations, this channel is of no use to you
No
Sometimes I need your help as well guys
ok so everything doesnt work fine
:DD
No because I would like to put a storage thing as u said
The default minecraft font is not monospaced. This means you cant just align text by using spaces.
what is .ade you ask? Well, it's just a .txt file but with the first 3 letters of my name in it
?kick @quaint mantle trolling/unserious
Done. That felt good.
damn
ok so do you want a message to be sent to a specific peson instantly or store/log it
i need some help revolving the JNI, say i have this wrapper ```cpp
JNIEXPORT jlong JNICALL Java_IniParser_new(JNIEnv* pEnv, jclass cls) { return reinterpret_caststd::uintptr_t(new IniParser()); }
I would like to have it stored in a .txt file
based
oh lawd hes back
I was just being serious, and I asked for help
why would you ever want it stored in a .txt file
Because it seems the easiest way
just use a damn database
a local one even
technically using a database is more complicated than saving text to a text file
Based
but it is better no?
Nop
is it better and easy to do? absolutely, and I am not agreeing with their point
the least I'll ever do something out of laziness is store things in json
Nah, I’ll store it into a .txt file
like my shitty discord bot, saves server configs in json (not great, but I don't have access to the server it's hosted on anymore so it's whatever)
i want to die
Well why would I setup a database see if it works, when I could simply save it into a txt file?
signed/unsigned just defines how the actual bits are interpreted. Could you explain this part a bit more?
"which would be the correct datatype to return a pointer in a number to compensate for javas signed only nature?"
This sentence makes no sense to me
ok bro go ahead live your life how you want to 👍 👍
Yes, that’s important
@ivory sleet can you type the funny command again
/goto take a shower?
Egitto, use this channel as a serious means to get assistance, thanks
as in is there a datatype that automatically adjusts itself to the architecture? in size
nice banner.
thanks :3
He asked for a funny command
What is wrong with that?
Btw here is how you would use the CF:
CompletableFuture<ResultSet> future = requestBankData(...);
future.thenAccept(data -> {
// Do something with the data. This will be executed somewhere in the future.
});
You define what to do with the data, as soon as its available.
Everything in java is stored in word length.
If it exceeds word length then it will be wrapped.
So a 64bit long will be stored in 2 (consecutive) words on a 32bit architecture.
Even a 16bit short will be stored in an 32/64 bit word on its own.
Guys a question
I would like to make a /goodnight plugin with like, if someone says /gn it adds a percentage to make it day
Is it possible?
Yes
Yes (but in blue)
Wdym in blue?
And… how should I start my script?
Maybe look at the code for one of those better sleeping plugins
then you can read the docs
goodnight egitto
goodnight egitto
It’s not night??
it is
But if u guys have time could u please look at the script I wrote?
Here
line 10 wrong
Oh
jk
Ah ok lol
what is this for
For /goodnight
I see now, thanks a lot!
Im also thinking about making a /rep and /badrep for reputation
And if u get good repped u get a cookie
Guys please don’t steal my idea
I refuse to believe that ChatGPT did not write that code @quaint mantle
He didn’t?
he says after speaking it out loud in a public chat
My pluginer did
Idk you tell me
No it’s to be read with a sarcastic voice
He didn’t…..?
Your who?
You mean programmer/developer/coder?
I just call him pluginer
Nice name right?
Anyway, if you have someone else writing code for you then why are you asking how to write the exact code here too
Just... see your pluginners code
Bc I don’t trust my pluginer
is that because it's chatgpt
He’s doing it for free
No
I am shocked by this man's competence
I have never seen such an intelligent homo sapien in my entire lifetime
Homo sapiens sapiens*
U forgot 2 sapiens
Btw I’m off today I’ll return to code tonight
If anyone’s free, he could check this script
jree
valuable opinion: wtf is that?
What?
Is there any way to remove the result from FurnaceExtractEvent?
Can u please explain me the problem?
nested ifs
it doesn't have result method and it's not cancelable
relatively old practics
Mine?
is this a good tutorial series to follow? https://youtube.com/playlist?list=PLfu_Bpi_zcDNEKmR82hnbv9UxQ16nUBF7
Yea
ok
Egitto did you still not get it to work? It's been like 20 hours
It works now
I added the possibility to get the coords, the player name, which block
Oh cool. Looks like you made a lot of progress and have a baseline now that you can build upon
if you follow that, youll have to relearn everything the proper way after that
mans code is a piece of shit
like all yt tutorials actually
i recommend you look at the forum stuff
you got any good tuto playlist?
i dont know any good playlists
I've never followed a yt tutorial but isn't it "Just type this, don't worry it works and I'll explain it later" and then they never talk about it again?
is there a good place where i cn get snippets and learn from them?
It misses only the thing that, if it’s a player’s placed block, it should send me the message, if it’s a natural block then he will not send it
I just google specific questions
or an online code viewer with explenation of the code
yt tutorials can be something to start with provided you actually try and understand/find out what each step actually does. following it blindly won't help you at all. also would strongly recommend a baseline knowledge of java before doing plugin development
Does that have to work over server restarts?
i just start thinking about what i want to make and start looking up specific parts of that
What do u mean?
Do blocks placed by players have to be known as player placed blocks even if the server restarted?
Yea
freejavalessons is better
yes
Then you need some kind of persistent storage (database, file)
Yea I chose for a .txt file
Did you already create that?
Yeah that's a little work to put everything in there and parse it to get it out again. Get some sleep and then continue. You made good progress.
Thanks
Yes but you want to cache it and save it in intervals instead of every time. It's certainly not an easy beginner task
Yea, but that’s the important thing, bc I don’t want that every time breaks a block, it sends me an alert
Imagine when a player goes to mine
Well you chose a pretty hard task to begin with
?jd-s
guess not
when player is holding items in between (after he picked up from furnace) inventories which inventory owns the item? player's or the furnace?
Lets say I have the string:
This is a 123 string
I'm using regex to be able to split the string into multiple substrings,
I want to be able to change 123 to be a ChatComponent. So I can add events to it.
Do I need to change the entire string to be able to change it?
you definitely have it
what are you trying to code
Construct a component with string.split(" ")[0]?
Oh I can do that?
if it provides a ChatComponent(String)
idk never worked with components
i thought they are from paper
But then to display the new message do I need to add each substring to the component?
So a NamespacedKey require to put JavaPlugin on the constructor, If I decided to change the package name of the project will it conflict? Meaning it will be different NamespacedKey.
I assume I can't just change the 1 word
Eh? Whyohhh
You would need to create component for every string
Ok yeah thought so
It just uses plugin name iirc. So pluginname:key
You can append components to one another.
This means you can create a prefix component, a middle component and a suffix component
while giving each component its own properties (like clickability for example)
So use a for loop to loop through every String in String[]
Add them to a BaseComponent and do the changes before I add it, then replace the original message
yup
Oh plugin name, alright. Thank you!
Thanks smile, thought so
and same applies to plugin messages
And nice pfp
I wouldnt do that
Well, I have an efficient way to know if 123 ( in this case ) is even in the string so I would be unnecessarily checking and converting everything
String#contains(String substring)?
oh
If you really only want only the 123 component to be clickable then i would just create two components for
"This is a " and " string", as well as a clickable component for "123". Then append them to one component.
Ohhhhh
But then how can I correctly split my String
Into 3 parts
That splits everything
Which is what he said not to do
What are you trying to do?
your string is dynamic right?
Chat message yes
it's not always same pattern
I'm trying to convert a chat message that contains 123 ( as regex )
Im trying to create a grief alert plugin
And replace 123 into a clickable 123
and what exactly is the alert
Very original. Nobody has done that for sure.
If someone breaks a block placed by a player, it alerts me
No fr no one
Only claim shit
should this only be 123 or any number
umm
PDC on chunk when place
^\d{3}-\d{3}-\d{3}$
This is a really difficult task.
Regex
Alert when player breaks the block in a chunk with PDC directing to this exact block
For xxx-xxx-xxx
Yes
right i forgot that its technically irrelevant if i have an overflow as long as the native part reads the pointer correctly
So far I just made that it tells me when a player breaks natural blocks and placed blocks, and also which type of block and also coordinates
And also the name of the player
But I want only for placed blocks not natural blocks
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
And what’s that?
.
Any idea then Nuker?
or using defaut spigot api -> store pdc to chunks
How?
?pdc
good luck with that
Is that difficult?
no
I’ll try
like 5 mins ig
Ah
This will be incredibly hard on the server if you just want to check which block was placed by a player.
This describes a very lightweight way of tracking player placed blocks in the chunks PDC
Lemme see
@EventHandler
public void playerChatEvent(AsyncPlayerChatEvent event) {
String[] messageArray = event.getMessage().split(" ");
}
If someone sends a message in chat like The number is xxx-xxx-xxx
I want to replace the message sent by the user with The number is xxx-xxx-xxx except that xxx-xxx-xxx is a TextComponent.
Cancel the event and broadcast your component
But I'm worried about the efficiency of my Component
Because the start and the end of xxx-xxx-xxx are just a string. There's no need to convert into anything
This event is almost always async. So dont worry too much about performance.
So I should just create as many components for the start and end of the string?
Append them to a big one
And send that?
I would create 3 components.
Prefix, Middle, Suffix with Middle being your number
Yes I understood that, but I'm confused on how can I group array indexes into those categories
hellloooo, the StructureManager should be able to load structures generated by the structure block in minecraft right?
Hi! I know this is not a gradle forum but I am currently out of ideas and google ain't friendly (so does gradle's tutorial page)!
I have a dependency which automatically include kyori's libs + google's gson, which both aren't necessary in my plugin.
I tried excluding the group, the packages, anything when running the shadowjar task, but no changed result, any ideas?
for (String word : message) {
beforeNumber.addExtra(word + " ");
if (word.matches("^\\d{3}-\\d{3}-\\d{3}$")) {
number.setText(word);
break;
}
}
if the dependency needs those things then u don't have a choice to include them am pretty sure
The dependency has those in another plugin outside of my packages I believe.
And since I am running paper, I don't need kyori's adventure since its included in paper
So i have an on playerInteractEvent
and i want to give the player the block it right clicked, it shows no error but it just does not work..
p.getInventory().addItem(new ItemStack((ItemStack) e.getClickedBlock()));
A block is not an ItemStack
This will throw an exception
You need to get the Material of the block in order to do new ItemStack. e.getClickedBlock().getType()
Don't forget the null-check unless you checked if the block can't be null beforehand
yhea i already added that
but thanks ill try
Smile
How does using a matcher sound?
Pattern pattern = Pattern.compile("(.*?,\\s*)(\\d{3}-\\d{3}-\\d{3})(,\\s*.*$)");
// Match the pattern against the string
Matcher matcher = pattern.matcher(String);
fava
my fava r rite thing
lessons
phtava
for jree
anyone know for this? Cuz i get a File is not GZIP format error.
i wish i could visualize the spigot jar source?
i heard intellij have some features
or what plugins is good for intellij?
spigot.png
fava-reader
💀
?stash
It's open sowce
open sauce
whats the current method to get the inventory title
yeah probably
but i'm used to ecplise
getView.getTitle iirc
to check if its the same name of a inventory thats comming from another plugin
String regex = ".*\\b(\\d{3}-\\d{3}-\\d{3})\\b.*";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
String prefix = message.substring(0, matcher.start(1));
String phoneNumber = matcher.group(1);
String suffix = message.substring(matcher.end(1));
}
Now that's pretty cool
guy goes for black magic
Tf is even that regex
I got no getView
It's a perfect regex for
"Hello, my phone number is 123-456-7890. Please call me!"
To split into 3 parts, prefix, phone and suffix
Where the "prefix" and "suffix" can be absolutely anything
Inventory#getView
And now, I can add some fancy stuff to the phone number
It's on Inventory Event, not inv object
So event.getView
Is this the best way to combine 3 separate components to then replace the message in AsyncChatEvent
TextComponent newMessage = new TextComponent();
newMessage.addExtra(prefixComponent);
newMessage.addExtra(phoneNumberComponent);
newMessage.addExtra(suffixComponent);
event.setMessage(newMessage.toLegacyText());
ComponentBuilder maybe
what were you trying again
I think toLegacyText removes all the textComponent features
Replace a message in aSyncChatEvent with my custom component message
Is the last step, everything else is working
when i used to code chatmanger
i just cancelled the chatevent
and sent the message to players
i probably did too
that's the best way ig
That means I need to make a broadcast
And then it won't work in /msg
umm
That's annoying
And I would need to build the message to have the exact format as the player would
just do /msg in your own plugin and send the message to the player directly with the component
So it looks like he is sending ity
Fair
I wonder if reflection or nms can override that
hi im trying to switch from skript to plugin developement but are classes kind of functions in skript?
true
now im trying again
and i made more progress than ever
i set up a spigot test server AND made a plugin that says something on startup
dang
i think i can get into paid developing