#help-development
1 messages · Page 2090 of 1
okay yes but error-handling is a more generic term than exception-handling, Rust doesn't fucking have exception-handling because it doesn't have exceptions, therefore I use the term error-handling to describe the action of HANDLING ERROR STATES.
ic
and TECHNICALLY
but even as a generic term
Java allows you to handle errors
if you're referring to Error at least
not recoverable
bc they're still able to be caught
ah yes
(you're just not supposed to)
catch outofmemoryerror
Lmao
Going back to the original thing:
Error handling refers to the response and recovery procedures from error conditions present in a software application. In other words, it is the process comprised of anticipation, detection and resolution of application errors, programming errors or communication errors.
I'm not a fucking moron, okay?
It's a real term, that's used the way I use it.
Hell
Even MDN uses the term "error handling"
THE FUCKING SWIFT LANGUAGE GUIDE USES THE TERM
and python
alr I cannot figure this out someone pls just give me raw source code for accessing another variable from another class
So the next time someone gets on my case for saying "you don't handle errors"
I read the stuff but it dont make sense
LMFAO
Sorry not responding to you
?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.
getters and setters
Anyway it seems like error-handling and exception-handling are actually one and the same
In fact, exception-handling is the more common term, but neither is more proper
no
based
an error is when you do something wrong, an exception is when your code does something wrong
did you pull this straight out of your ass
no, that is how it works
no..
an error can generate an exception but an exception can not generate an error
The term "error handling" is also used by the C++ reference, Node.js documentation, Python documentation (as Imajin said), Rust documentation, and Win32 Microsoft documentation.
Not to mention error does not explicitly mean a programmer fault
i didnt say programmers fault
As judged by the fact Error in Java refers to unrecoverable exceptions
an error is when you do something wrong
an error is when theres something wrong with the code, (could be user input related), and an exception is when the code does not run correctly, whether it be incorrect arguments
then what the fuck did you say??
Is there a way to get how much time the player played on the server?
google spigot get players play time
search engines are a wonder
Oh ye also PHP and AWS documentation uses the term "error handling"
the io could do something wrong, the user could do something wrong, the programmer could do something wromg, the powewr could fluctuate and cause it
"you" is just the environment outside the code itself, there is no good term for it
I would not describe acts of God as errors
then gamma radiation and photons do not generate errors
why does AsyncPlayerChatEvent.setFormat(...) break when a player types the % character
13.04 22:18:01 [Server] INFO Caused by: java.util.UnknownFormatConversionException: Conversion = '%'
String.format stuff
% is the prefix of a formatting code
setFormat sets the format string for a message I assume?
ah k ty
void
setFormat(String format)
Sets the format to use to display this chat message.
not too elaborating on it
xD
Bukkit power
dont use String.format
it performs very badly
compared to StringBuilder or MessageFormat
i do a simple plugin that show the name of a player and in a message when break a diamond ore but i it appears every time i broke a block, how can i do to show the message only one time in 2 min?
or a simply +
so how to prevent a simple % char to break the callback then
replace it
the %?
suppress it with a timer
when someone types it?
yup
i try it, can you give me a hand with it?
?scheduling
do you know how to schedule a timer?
yeah then reading the above would be advised
okay
something like this is non-critical so you could use an asyc timer
the hard part will be adapting your code to work with the timer
just start by creating a timer to fire you a message after two minutes (you do not need a repeating timer for something like this)
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
does it work?
this dosent work, idk why
Lmao itsnot funny to be tagging and deleting tags 😡
to start with, how do you think your timer is going to decrement?
For doint countdon i would use timestamps
countdown*
i want a timer for not appear the message since 2 min
what is??
A timestamp its number or date that its checked every time
I ill send the classfor creating timestamps
give 1 sec
thx😊
epoch is, futureEpoch=epoch + (2400 /20) , is epoch match futureEpoch roughly
public class Cooldown {
private String name;
private long end;
public Cooldown(String name, Long time) {
this.name = name;
this.end = System.CurrentMillis() + time;
}
public void stop() { this.end = 0; }
public boolean hasExpired() { return (System.currentTimeMillis() - this.end >= 1L); }
public String getName() { return name; }
public long getRemaining() { return this.end - System.currentTimeMillis(); }
}
i had forgotten that java has time
thx i will try it
Its inded to be used in millis seconds
I do a getName(), so then you can have multiple cooldowns
You can create a manager for the cooldowns (Set<Cooldown>)
i want to do a timer for each player
I think he wants 1 countdown for each player (find diamond and the message will appear once, after 2 minutes if you find diamond again the message may appear again). That's what I think
Oh ok i was using the class to each player have many cooldons
But you can use it as you wish
@sterile token Are you spanish?
lol like me
Hi how I can check player who had a nickname selected?
for example "Proscreeam1337". Now there is no player with this nickname but in the past there were 3 people
store the username with a set of uuids
or however much data u want to assocaite
somenickname:
- uuid
- uuid2
the uuids would represent players who have assocaited with that nickname
Yea I know but how get this information use API
From the player class?
i made the cooldown but the message only appears when pass 2 min y want that the cooldown starts when the player breaks the block.
public class BlockBreakDiamond implements Listener {
@EventHandler
public static void blockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
Block block = event.getBlock();
Material material = block.getType();
if(material.equals(Material.DIAMOND_ORE)) {
if(Main.getInstance().getCooldowns().getCooldown(p.getUniqueId())==null) Main.getInstance().getCooldowns().add(p.getUniqueId(), 120000L);
Cooldown cooldown = Main.getInstance().getCooldowns().getCooldown(p.getUniqueId());
if(cooldown.hasExpired() ) {
String mensaje1 = ChatColor.GREEN+p.getName(); //coje el nombre del jugador
String mensaje2 = ChatColor.GRAY+"Ha conseguido"+ChatColor.AQUA+"diamantes."; //mensaje que sale en el chat
Bukkit.getServer().broadcastMessage(mensaje1+" "+mensaje2); //Hace que envie el mensaje el server para que lo vean todos
Main.getInstance().getCooldowns().add(p.getUniqueId(), 120000L);
}
}
}
}
What I do for cooldowns is just make a hashmap with time in it. Then I do a if(currentTime > timeInMap) dosomething();
What he is doing
haha
Internet API xD
Looks way more complicated
He has a Manager which contains a Map<UUID, Cooldown>
Mike=?
Are u still alive?
He is prob ignoring us
private static HashMap<UUID,Long> coolDowns = new HashMap<>();
public void event() {
if(System.currentTimeMillis() < coolDowns.get(playerUUID)) {
return;
} else {
coolDowns.put(playerUUID,System.currentTimeMillis() + (60 * 1000)); // cd for 60 seconds
}
}
Isnt what i did?
🤔
But doesnt fix his issue
Yeah but so much more work
He is issue is the next, when you break a diamond fo first time, you have to receive the message and them create the cooldown, and send the message every time he want
That what he means
Do we have expalined?
but look at the mess here and watch what you can turn it into for starters.
https://paste.md-5.net/velixusupa.cs
Meh the < should be > oops
But so much cleaner
Is the same i made him
They have some Cooldown cooldown = Main.getInstance().getCooldowns().getCooldown(p.getUniqueId()); class which is unnecessary
Just need a hashmap
Anyways what is the issue here? When they break it the message send then what?
You want a message if it fails to break? Add an else to the if(cooldowns#)
I already explained the issue
the problem is that when a player broke the block i want to put a cooldown to this player that not send the message again
since 2 min
Now the cooldown doesnt works 🤡
I mean if you want working code then something like this https://paste.md-5.net/ihafigufun.cs
where should i put a playerteleport event for a /back event?
ew static event
not mine 

quick question, can a dictionary contain multiple of the same key like python or if i .put() a key that already exists will it override it?
It will override
ok thanks
public void onInventoryClick(InventoryClickEvent event) {
if(event.getView().getTitle().equals(ChatColor.translateAlternateColorCodes('&', "&8Weaponsmith"))) {
event.setCancelled(true);
}
}
how do i make it so the player can move stuff in their own inventory but not the GUI?
don't check inventory name
what do i check then
you would want to create a custom InventoryHolder and make you GUI use that
and when you check the click, you would want to see if getHolder() on the inventory is instanceof your custom holder
check if player is clicking on the top inventory or on their own inventory
if player click on top inventory, cancel it

Don't do that
Just keep reference to the InventoryView from Player#openInventory()
Referentially compare it when clicked in an event
Then yes, follow agler's suggestion. You can compare the clicked inventory
in the command class? that errors
What do you mean by "that errors" what error
I mean it should be in the command
in the on command?
hang on
wtf
my mouse is always in a clicking icon on intellij
ok heres my command
public class BackCommand implements CommandExecutor, Listener {
public static Hashtable<UUID, Location> backDict = new Hashtable<>();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player player) {
if (Config.getConfig().getString("back-enabled").equals("true")) {
if (backDict.containsKey(player.getUniqueId())) {
Location location = backDict.get(player.getUniqueId());
player.teleport(location);
} else {
player.sendMessage(ChatColor.RED + "You haven't teleported yet!");
}
}
} else {
Bukkit.getLogger().info(ChatColor.RED + "This command can only be executed by players!");
}
return true;
}
@EventHandler
public void PlayerTeleportEvent(PlayerTeleportEvent event) {
Player player = event.getPlayer();
Location from = event.getFrom();
BackCommand.backDict.put(player.getUniqueId(), from);
}
}```
how would i add it in main file
why are you using a hashtable
Anyone know if there's a better way of doing
private static final List<String> CLIMBABLE_MATERIALS = new Arraylist<>();
static {
CLIMBABLE_MATERIALS.add("LADDER");
CLIMBABLE_MATERIALS.add("VINE");
CLIMBABLE_MATERIALS.add("SCAFFOLDING");
CLIMBABLE_MATERIALS.ADD("TRAPDOOR");
}
Besides making an EnumSet of every material?
idk its what google said a java dictionary was
ah, looks like there's a tag lol nvm
Edit: Tag.CLIMBABLE btw
hashmap
can i use it the same way
yup
good luck
this
how do i add the playerteleport event in main file
dont
ok
"Did you maybe forget to register the listener?"
on spigot forums
about issue with playerteleportevent
did you?
i dont know how to register it
this.getServer().getPluginManager().registerEvents(new PlayerTeleportListener(), this);
oh nvm he figured it out
thanks
what
all of a sudden my test server is 1.18.2
what is this wizardry
i did not update it
idk even if its a fork server versions just dont magically change
is the class implementing Listener
and does the method have @EventHandler annotation
yes and yes
then its something in how your handling your event ie the logic of it
i put the command class name for the event right?
oh this
yes
new BankCommand() but you should create this BankCommand as a variable so you dont have to instances of it running when you reister your command
for what?
well the class is a typeof BankCommand so your BankCommand would be the variable
BankCommand bankCommand = new BankCommand();
// reister events using bankCommand
// registerExecutor using bankCommand
Any reason this wouldn't work?
@EventHandler
public void onLand(ProjectileHitEvent event) {
if(event.getEntity() instanceof Arrow) {
Arrow arrow = (Arrow) event.getEntity();
if(arrow.isOnGround()) {
arrow.setGlowing(true);
}
}
}
}
I know that the event runs since I've tried debugging but can't figure out why it wont detect if its on the ground
I'm not confident that #isOnGround() will be true by the time that event is called
You can check if ProjectileHitEvent#getHitBlock() isn't null though, that will accomplish the same goal
if (event.getEntity() instanceof Arrow arrow && event.getHitBlock() != null) {
arrow.setGlowing(true);
}```
I'm also not entirely certain that Arrow#setGlowing() works exactly how you want...
holy shit do you have copilot on your discord or something
you typed that mad fast
lol
Yeah I just don't think setGlowing() will work on an arrow. iirc it's an Entity method but accomplishes the same thing as giving the glowing potion effect without actually giving the effect
Could be wrong about that though. I'd print a message there to verify if it's actually running that code
Nah you're code worked flawlessly
Oh it does glow? Neat
o/
o/
glowing is part of the generic entity metadata so it should work with all entities
only entity I highly doubt is area of effect cloud
I've just never seen an arrow glow
Wasn't sure
Aside from a spectral arrow I think
Location targetLocation = target.getLocation();
Location entityLocation = entity.getLocation();
World world = entity.getWorld();
Vector velocity = entityLocation.clone().subtract(targetLocation).toVector().normalize().multiply(1.5);
SmallFireball fireball = world.spawn(entityLocation.add(velocity), SmallFireball.class);
fireball.setVelocity(velocity);
I'm probably an idiot but this shouldn't shoot from the entity's line of sight
thank god this place exists
eyah
(1) Entity#getEyeLocation()
(2) Is the fireball just not moving? Wrong direction? Not spawning at all?
1 - the entity is not looking at the target
2 - it's shooting off its eye direction, rather than shooting at the target
No I get it's not looking at the target but getLocation() is at the feet
getEyeLocation() is at eye height
shouldn't matter much
No but it's probably closer to what you want ;p
this is close enough
also I'm not using livingentity so getEye location doesn't exist
Ah that's fine then. But yeah, wrong subtraction direction
sometimes I wonder how I miss such things but then I look at the time
for some reason protocolmanager is null and idk why
[02:41:55 ERROR]: Error occurred while enabling FirstAC v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.ProtocolManager.addPacketListener(com.comphenix.protocol.events.PacketListener)" because "protocolManager" is null
at me.blebdapleb.firstac.FirstAC.onEnable(FirstAC.java:23) ~[FirstAC-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Paper-408]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1220) ~[patched_1.17.1.jar:git-Paper-408]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-408]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
@Override
public void onEnable() {
instance = this;
// Managers
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
// Packet listeners
protocolManager.addPacketListener(KillAuraA.killAuraACheck);
Don't show code show pom
Theres your problem change the scope of protocol lib to provided and it'll work
thanks
how can i show what input type is allowed for a command if it allows any string or int input?
By adding a usage to the command. Also using a tabcompleter to assist
ah thanks
Could I apply bullshit states to items to retexture?
IE adding waterlogged: true to a grassblock
Nope
Because the blocks you want to add bullshit states to won’t be able to hold said state at all
Still scavenging for more ways to make custom blocks?
mainly just a simple color retexture
I did something a little silly to make the illusion of custom liquids
im fine with illusions
this water has no special propperties its just water
discord lag
hmm
and biomes can be seperate by x y and z in 1.18 correct?
Correct
Now there is some blending weirdness
So the color won’t sit neatly in its spot
only issue would be it would be strictly 1.18 which is sadge
I could implement it in other versions but then the water underneath the islands would change too
Well actually
that would be fine
3D biomes have been in the game since 1.16
oh?
Came with the nether update
oh shit your right
so 1.16 - 1.18 then hmm
not too bad i normally dont go below 1.14 anyways cause of pdc
alright ill take a look at that ty for the idea 🙂
I'm using this to get the time the player played on the server : player.getStatistic(Statistic.PLAY_ONE_MINUTE)
But for some reason the text is italic and purple, how do I fix this?
The text isn't italicized and purple
You're probably putting it in lore
getStatistic doesn't return a string
It returns a number
A number can't even have properties like that
Yeah I am
If you're setting it in an item's lore, being purple and italicized is the default format, you can prepend ChatColor.RESET or any color to correct it
Ah ok, thanks!
how can I add invisible light sourcse
You can do it with this
Though also I think there is a light block in the latest versions
Yep
Material.LIGHT
You can even set its level precisely
wow thanks
How do I get the plugin's folder path?
plugin.getDataFolder()
Doesn't work, plugin isn't a thing for some reason
should i take a screenshot of the project files?
No take a a screenshot of what you did
what do i use to send screenshots? i don't have the permission to send an image
imgur?
?di to get the plugin
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
You don't have a plugin variable that's the problem
aha, thanks for the help
Is there any way to add items to a LootTables object?
player pickup event for 1.18.2 ?
like am i able to add items to specific loot types during some event?
EntityPickupItemEvent
Is it possible to change the name that appears at the top left when I open a player's inventory?
https://paste.md-5.net/kujiqeneyi.java
Am i doing this wrong?
I just copied and pasted from the website you sent btw, I didn't read anything (sorry)
This is feeling like a ?learnjava
or you can help me instead of making fun of me
I'm just stating the obvious :p
lol
People who copy-paste code instead of actually making an effort to understand it are more likely not to know the source language
If you actually took the time to read over the guide, you'd realize that it gives you examples, not working code snippets.
This is truly the only part you need to understand
It doesn't matter what BlockBreakListener is
Just the fact that you're giving it an instance of your plugin
(Also SpigotPlugin doesn't exist I don't know why the guide uses it, maybe to stop people from copy-pasting?)
(Another thing: FancyLogger does not exist)
I just realized "SpigotPlugin" is the class name
(Your code would 100% fail to compile)
Oh right
I wrote a blog post on DI about a month ago
It's a decent introduction, read it https://blog.maow.xyz/2022/03/19/dependency-injection.html
Dependency injection is a common pattern in object-oriented programming (Java, C#, etc.), but it is one that beginners commonly have problems grasping. If you’re struggling to make sense of the concept (I don’t blame you, the term itself is scary), I hope this article will provide some help!
Maow help him lol
That's what I'm trying to do :p
I do have a stupid question tho.
Is that really the only way to get the plugin variable?
Well no, but it's the most preferable
You could use something like a singleton, JavaPlugin.getPlugin(...) (which is equivalent to a singleton imo), or a setter.
But most of these options are not conventional
I like that blog tbh, i like it :D
Why thank you :)
lmao
Yeah, but in different ways
For one, getPlugin will most certainly fail if called before the plugin is loaded.
Setters also introduce state and nullability
Dunno, it could happen though
So ye imo constructor DI is the cleanest solution
It's also just favoured by most Java devs
Hey, I try to modify the damage of a Trident but it seems not work, someone has already encountered this problem ?
Trident extends AbstractArrow, so I tried to use the setDamage() of AbstractArrow, it works fine for Arrow but not for Trident.
are you sure you havent just forgotten to reload the plugin? That method should work
I need to load each value inside the config.yml and create a command
commands:
command1: "Custom response"
command2: "Another response"
so everything in 'commands' is read, with the first value, e.g. 'command1' being the name of the command and 'Custom response' being the value that is sent to the player when the command is run.
However, I would have no idea where to start since loading commands from config files, without the use of plugin.yml is decently new to me.
Anyone got any idea how I could start it? You don't have to provide the code necessarily, more just the steps for doing it
you should make it a list instead of separate paths
so instead of
commands:
commands1:
...
you could use
commands:
- <response1>
- <response2>
that way you can get all the values of commands by using config.getStringList()
if you wanna have the command response pair together instead of in 2 lines or so you could just put both in the same line and split it into command and response after
Yes I haven't, weird, have you already used it in the past ?
not with tridents, but arrows. They, too, extend AbstractArrow
Yes for arrows it works well, but not for trident
and yes it worked at that time
that makes more sense and might actually work more efficiently.
Thank You!!
no problem!
also question of my own how do i do a lambda consumer again?
you have to put () -> or something I believe
possibly () -> { do something here}, 100, 100)
Hi how I can check player who had a nickname selected?
for example "Proscreeam1337". Now there is no player with this nickname but in the past there were 3 people
please explain what you mean by nickname. you mean the playername they have or some nickname on your server specifically
either way the answer should be something to do with the players UUID
It's called a captured local. Lambdas allow you to retrieve variables from outside of the lambda scope, but also allow defining new variables as part of their scope if passed to the lambda (lambda arguments).
(Technically the trait of having captured locals mean lambdas are actually closures, but who cares?)
lay it on us 🙂
but calling cancel() throws an error
cancelling the task from inside the task you mean?
yep
damnit, thats something I wasnt able to figure out either
urgh extending runnable it is
maybe with a simple return; to grasp at straws here?
well the method .runTaskTimer specifically asks for Plugin, Runable, double, double
well afaik a runnable calls, periodically, the run method, and the lambda gets translated into a runnable
the () -> is an anonymous class and executes the run method which is specified inside the {} as far as i know. then again, i barely paid attention in that class
welp
public class OnItemDropEvent extends BukkitRunnable implements Listener {
Echo echo;
PlayerDropItemEvent event;
public OnItemDropEvent(Echo echo){
this.echo = echo;
}
@EventHandler
public void onItemDrop(PlayerDropItemEvent event){
this.event = event;
runTaskTimer(echo,10,1);
}
@Override
public void run() {
event.getPlayer().sendMessage("10 ticks");
cancel();
}
}
on a different topic how do i prevent Item entities from stacking?
I know its to reduce lag but its necessary for me right now
possibly by changing some of its data? changing some of the persistentDataContainer may do the trick
well the issue is i need them to stack again when they're picked up
i imagine changing metadata or PDC would make that problematic
then undo the changes when you need it
wait, do changes to the PDC and metadata of the Item entity transfer to the ItemStack instance?
I dont know. Im guessing here
does the entityDeathEvent or the EntityDamageEvent get called when you pick up an item? that would be very useful
the jd mentions neither so i dont think so
fancey
For BlockMetaData on ItemStacks I can confirm they stay when dropping and picking up again, but not when placing then mining again (Placed ItemStack will carry over BlockMetaData though) i would assume same for MetaData
For PDC, the same thing but placed ItemStacks PDC won't apply when placed
I'm aware of that but I asked if metadata on the item entity, not the ItemStack it contains, carry over to the ItemStack when picked up
it does I believe
item entity as in dropped itemstack correct
Ive made special items which carry their data in PDC and when I drop it and pick it back up it still works. that should be enough, right?
yes
they will be there
PDC is similar to NBT in a sense, the data is persistant and applied to the item directly
yea. I ask bc the item entity gets removes afaik
but not persistent when inside an itemstack which is then placed on the ground
^ unless its a typeof BlockMetaData
then its perstant all throughout except for when breaking the block
moral of the story
yes dropped items will keep your PDC data and MetaData
?paste
lol
mc on linux be like
uuuuuurgh other way around
I modify the metadata/pdc of a item when it's created when it's dropped.
If a specific condition applies, i want to prevent it from merging with other Item entities.
ElgarL provided one possible solution, but i still want to know if the metadata and PDC of an Item ENTITY carries over to the picked up ItemStack
no it works fine for me i use Arch(BTW)
not the question. I KNOW THAT! I want to know if that PDC and metadata of an ITEM entity affects the picked up ITEMSTACK
its the same as when you dropped it like ive said many times now... nothing changes
dropped item with pdc -> dropped itemstack entity with pdc -> pickup -> same pdc
nothing changes here
i am aware that the item entity holds a itemstack with the pdc and metadata of the dropped item.
However.
The item entity itself has fields for metadata and PDC.
If i change those, the Item entities cant combine.
What i am asking is: Does the metadata and PDC of the item entities affect the itemStack it holds in any way, at any point in time
IIRC yes they do change if you change that dropped items PDT/MetaData you can always test it too ofc
the PDT of the ItemStack remains persistant throughout its life time
change the PDT as an entity, its edited when you pick it back up as an item stack
does anyone know how to fix this reset glitch? the server is running on geyser and is cross playing java and bedrock but whenever u log out and log in your stuff gets wiped ( and ender chest) if your new to the server and u join and get some stuff and log out it will be gone plus achievements and there are other plugins like /tpa /team but i hope this issue gets fixed (its a cracked server it only occured 4 days ago and it was fine 2 weeks ago)
if not thank you for your time
Hello, do you know guys what's the best way to recognize a custom item
indian voices
pdc
?pdc
if you are not ingame
that isn't what I meant
What if I slather my custom item in honey hmmm
if you made a plugin to generate custom items, then should know it is a custom item
Ty guys
oh i kinda just take a 50/50 guess at if a items custom or not
lol
theres this weird bug where 50% of the time the items isnt detected as a custom item tho
currently working hard to fix this bug!

How do I make players not be able to rotate items in item frames? because this doesn't seem to work (the if statement does get called)
@EventHandler
public void onItemFrameMove(PlayerInteractAtEntityEvent event) {
Player player = event.getPlayer();
if (event.getRightClicked().getType().toString().equals("ITEM_FRAME")) {
event.setCancelled(true);
}
}
getType()==Material.ITEM_FRAME, maybe?
no thats not the problem
the problem is event.setCancelled(true);
the if statement gets called with 0 problems
Have u tried denying any block or item use result
And use this also
Even though its not the problem
that wont matter
sometimes
you need string checks for version safe plugin writing
as calling Material.<Something> will throw an error
Its not the error here if anything
no?
he should be checking if getRightClicked() is instanceof ItemFrame, but all 3 methods work for detecting if thats an itemframe
bkgert do you have any other InteractEvents?
or is it just that one
oh i see
this is the only PlayerInteractAtEntityEvent
another thing to note
i dont think this prevents taking items out of the ItemFrame
might need to check that
already fixed that :)
ah nice! sounds good then
thanks for reminding me
?jd-s
How PlayerTeleportEvent#getTo can be null?
it can't
It can afaik
during portal teleportation logic
tho effectively that won't happen
well it IS nullable, so I guess you can pass a null location in a teleport
all @NotNull
however https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerMoveEvent.html#getTo() is nullable so its possible (so say the docs). Never seen it happen ever though
I have never ever seen a null Location in getTo
Are there any naming conventions for group ID in Maven?
Is me.quzack.pluginname a fine ID?
me.quzack would be the group id and pluginname the artifactid
I read somewhere that you can use your GitHub name for a group ID, how would I format that?
The fun part about github is that you "own" the domain username.github.io
so you can use (for example for me) io.github.lynxplay as the groupid
because no one but you will ever "own" that domain
Alright, cool. Thanks
Hey guys!
I'm a returning plugin-dev, last time I've coded a small plugin for our own server was with api-version 1.16 . Now I'm coming back, wanting to create some new custom ShapedRecipes, but I see a lot of the stuff being marked as deprecated. For example:
ItemMeta magicWandMeta = magicWand.getItemMeta();
magicWandMeta.setDisplayName(ChatColor.GOLD + "Magic Wand"); // The .setDisplayName() method is marked as deprecated
It recommends me using these fancy new Kyori.Adventure Components instead. So what I'm trying now is to:
ItemMeta magicWandMeta = magicWand.getItemMeta();
magicWandMeta.displayName(Component.text("Magic Wand").color(NamedTextColor.GOLD)); // Trying to set the display name with the fancy components
.. but without any effect. What am I missing here?
spigot
Spigot seems more natural to me, lol
I'd recommend using Spigot's API but Paper's server jar.
That's what I'm doing.. kinda. Except for mixing up Spigots API with Papers API
Cool! Soooo all the deprecated stuff isn't really deprecated then?
Yeah nah it's just discouraged from use since Adventure is seen as better.
String-based methods use the legacy text format and are unable to do things as cleanly. I also don't believe they support things like chat events.
I mean, only really useful if you want to publish your plugin to spigot
if you only run your plugins on your own server and that server already runs paper
just go with paper-api too
Yep
I'm confused on something, I'm trying to get the click type in a packet and on this wiki it says it's a Varint Enum but idk how to get those lmao, I'm using protocollib btw https://wiki.vg/Protocol#Interact_Entity
It's just a varint
It's called an enum since it should only ever be one of the values listed
I see. Well, as far as I can see the Spigot API has a more "natural feel", I'm planning to use that. Thanks for bringing me up-to-date maow!
so do I just get an int?
Yes
alr
There is the Bungeecord Chat API though
Which is similar-ish to Adventure
A little worse though, imo
so like int clickType = packet.getIntegers(1);
like that?
cuz there is another varint there already
Depends on the placement of that int in the packet's class
But I reckon you recommend the Adventure-stuff as well?
Since spigot is planning to get rid of the "old way"
They're not
Paper isn't either
Legacy text afaik will stay for a long time
(Oh and btw you can use Adventure on Spigot too via their adventure-platform-bukkit dependency)
I mean, we will see how long legacy survives if paper ever hardforks
legacy text is just so incredibly useless with the current ecosystem
like, mini message can make your life (if you prefer a string based approach) so easy
I see I got a lot of stuff to catch up upon lol
Can't seem to find any nice guide on the spigot forums tho
MiniMessage allows you to write string-based formatted text pretty easily
Seems outdated
It uses Adventure and an XML-like syntax
Also supports stuff like gradients and placeholders iirc
oh sweet stuff
Ye it's made by one of the users here
MiniDigger
I believe he's also a Paper contributor
*core team member
I think that'll work. Not too sure.
got any docu for all of that?
and https://docs.adventure.kyori.net/ is the general adventure documentation
that's my man
it has a section for mini message too
See I'm unsure if ProtocolLib would convert this:
private final PacketPlayInUseEntity.EnumEntityUseAction action;
To an int.
Great help! Thanks guys
uhh there is an error
Field index out of bounds. (Index: 1, Size: 1)
yep ok that means you actually can't use getIntegers then
Well it's an int when received/sent
but it's then decoded to an implementation of EnumEntityUseAction
so technically it's an object
I have no fuckin' clue lol
lmao
I have a method that normally returns a Array of Blocks if it finds some. But sometimes it cant return the array because it didnt find any blocks ... what can I return then so I can check, when using that method, if it found Blocks or not?
ye that's why I asked cuz forums say that it's an entityuseaction which idfk how to get
empty array?
new Block[0]
okay hmm
Three choices:
Have method return Optional<Block[]> (Optional.empty()) - I wouldn't recommend this.
Have method return null - I wouldn't recommend this.
What FourteenBrush said, new Block[0] - This is preferable since iterating over it won't throw an NPE.
imagine returning an optional array
It's an option! Just not a good one!
@pliant oyster https://ci.dmulloy2.net/job/ProtocolLib/javadoc/com/comphenix/protocol/events/AbstractStructure.html#getEntityUseActions()
declaration: package: com.comphenix.protocol.events, class: AbstractStructure
Although actually...
There's getEntityUseActions() and getEnumEntityUseActions()...
You probably want the latter.
and I would need to check everytime I use the method if it returned an array with something in it before doing smth with the outcome right?
Well it wouldn't be too hard for the last one
Just arr.length == 0
I mean
Every solution requires checking the array
Just different ways of doing so
yeye I just meant if I use it alot its the same code so many times but thank you
But if it's null, you will die a long, terribly painful death :)
and is the new Block[0] the same as if I would return blocks of Block[] blocks = {};?
dont return null >_<
String[] s = new String[] {
"Hello, ",
"World!"
};
// is equivalent to
String[] s = new String[2];
s[0] = "Hello, ";
s[1] = "World!";
okay thank you
In fact
An empty array likely has the same performance as a null pointer
Since it contains literally nothing, meaning there's likely only a few bytes allocated?
And those would just be for the type of the array
So ye
No need to worry about that
And this Block[] blocks = {}; is the same as that Block[] blocks = new Block[] {}; ?
Actually no bc the former is not valid Java iirc
Maybe it is now
but I'm pretty sure it's not
Usually {} by itself is reserved for anonymous class implementations and specifying annotation array parameters
so I use the right one?
Yes
Well no
You shouldn't declare an empty array initializer
Just looks shit
use new Block[0]
okay ok
Block[0]::new 🙄
That is not valid Java either
Block[]::new is though
Array constructor references ✨
Actually wait I wonder what those compile to...
its valid for a supplier
Oh, wow.
🥶
I honestly thought there would be some kind of optimization here...?
But nope
It literally creates a proxy of Function that creates a new empty array
how does minecraft implement its crafting
Who the fuck knows
i dont
games with gabe does
Good point
he is recreating a mc clone
fr?
pretty good so far
oh nice
That guy knows basically fuckin' everything about Minecraft at this point
but is it the exact same because there are some features that id like to have
mainly (actually only) how to have shaped recipes work everywhere in the grid
instead of only in the top left corner
i thought about first moving the recipe to the top left and then eliminating empty space around it to leave you with only what you need
Well
An idea is that you could essentially
figure out the max size of a recipe
based on how many slots it would span in a 3x3 grid
but then i have to normalize (thats what i call the process) for every recipe
e.g. the sword recipe is 1x3
and rn im using a decision tree for matching
fishing rod is actually 3x3
yeah
you would basically then just like
check a list of recipes under that size
to find which one corresponds to what's in the grid
wait what if i just loop over all empty space around it
skip over
i meam
mean
I think your best bet is what I suggested
I don't know how performant it would be tho
Join the Discord: https://discord.gg/4tHeAkxNg7
Follow me on Twitch: https://www.twitch.tv/gameswthgabe
Watch my brothers video of him playing the game!
https://www.youtube.com/watch?v=BtYfR3lY6Cw&t=1s
In this devlog I go over how I added a multiplayer mode to my Minecraft clone. I go over some basics of how the Internet works, and then dive i...
there
linked to implementing crafting
ay i saw that video
(think it would also be cool to basically utilize hash codes or some other unique hash to lookup the recipe based on its contents)
and what did he do?
I'd watch the video
but I don't want to bc I'm tired
i have flexible i ingredients so hashing wont work
anyways ima eatch the vid noe
he matches every possible positioning of every recipe against the player input
is what hes saying i think
Where can I get the list of all the objects that can be stored in config?
What is this error about? https://paste.md-5.net/adesokesac.md
Is it possible because I'm listening to an event that has no getHandlerList method?
uff whats that help pls: https://gist.github.com/ItzJustNico/5cf8d5f7a61fb06deda2becc9d5409c5
if I have something like this:
if( (condition1 || condition2) && condition3)
then the statement will be true if condition1 && codition3 or condition2 && condition3 ?
Hey do you know how I can put HEX color in a scoreboard ? Thats work for my title but thats didn't work for the objectives
String title = ChatColor.of("#25bfbf") +"S" +ChatColor.of("#29bdad")+"e" +ChatColor.of("#2dbb9b")+ "a" +ChatColor.of("#32ba8a")+"O"+ChatColor.of("#36b878")+"f"
+ChatColor.of("#3bb767")+"S"+ChatColor.of("#3fb555")+"k"+ChatColor.of("#44b444")+"y";
ob.setDisplayName(title);
Score s2 = ob.getScore("§7│ §e▪ "+ChatColor.of("#24E48A")+"Grade§f: " + SCOREBOARD_UTILS.getGroup(p));
Score s3 = ob.getScore("§7│ §e▪ §aConnectés§f: §e" + co);
Score s4 = ob.getScore("§7│ §e▪ §aPlayTime§f: §e" + SCOREBOARD_UTILS.playerTime(p));
Score s5 = ob.getScore("§7│ §e▪ §bTempFly§f: §e" + SCOREBOARD_UTILS.getFly(p));
Score s6 = ob.getScore("§7│§b");
Score s7 = ob.getScore("§7│");
Score s8 = ob.getScore("§7│§e");
Score s9 = ob.getScore("§7│ §e▪ §aRôle§f: §e" + SCOREBOARD_UTILS.getRole(p));
Score s10 = ob.getScore("§7│ §e▪ §aNiveau§f: §e" + level);
Score s11 = ob.getScore("§7│ §e▪ §aArgent§f: §e" + SHORT_MONEY.getShort(MoneyAPI.getMoney(p)));
Score s12 = ob.getScore("§7│§0");
Score s13 = ob.getScore("§7│ §6VoteParty§f(§e" + 0 + "§f/§750§f) §7━");
yes, boolean logic is distributive over && and ||
?paste
I have this code that switches the player item in their hand and vanishes or unvanishes them when they right click
The thing is that for some reason when the player looks at the air it requires to clicks and when the players looks at a block it requires one click
Any idea why?
first of all, compare Materials with ==, not equals. it can get weird with equals
Ok I changed it
other than that I cant see any mistakes in the code you sent. to check further you would need to send the plugin.checkMode, unVanish and vanish implementations
wdym?
I can't see anything that would cause that bug in the code you sent, so I assume it is in the rest of the code
oh, I will look into that
the thing is, when I look at a block it fires the event twice, so maybe its that somehow?
thats also possible
let me look at the docs, one sec
ah I googled it
the event is fired once for the left hand and once for the right hand, so maybe recheck that it is the right hand, even if the Action.RIGHT_CLICK* thing should check it by itself?
Ah, then I will also need to check for the game version as I want the plugin to be 1.8 compatible
Let me do it rq
https://www.spigotmc.org/threads/playerinteractevent-called-twice.221747/ anyway, google helps a lot with finding answers to exact problems XD its almost like StackOverflow at this point, just for spigot lol
Haha ok thanks!
I created a Custom mob plugin but when I tp away and then tp back they are heavily duped
how can i use getDescription in a static method?
I was referring to that specific case since they were already comparing the Action enum by ==
Bungeecord - Kotlin - config.yml
of a plugin?
is that a method in bukkit's Plugin?
by either holding a static reference to your plugin instance
or
using
Plugin plugin = Bukkit.getPluginManager().getPlugin("pluginnamehere");
then plugin.getDescription() or whatever it is
Is there a way to make items "unique"?
So that I can read out with a plugin whether a certain chest has been clicked on?
Yes
ok thanks
Whats the easiest way?
does anyone know how do i check if 5 is the amount of light blue wool exists in the player inventory
I will check when the Player place a block then i want to check how much is the wool left
But how
that does not change the answer
How do i check
for loop through the inventory and add up all the matching blocks
ok
zacken, that ones for you
😄
keep and use it, its the best way to convey that information
can spigot please unblock tor this is frustrating
im using it to bypass thier restrictions
they block google.
i cant
they block everything
possibly because they dont want you on spigot XD
schools are openly anti spigot, we must rise up
same
i am it has restrictions
Still damn feels bad
does anybody knows a good article or video about making Bungeecord configs in Kotlin because I can't get it to work
vps wouldnt help
my computer is here
I have this too
i bring my laptop
I have it for other things too
wait i i have a rpi at home i might be able to
Do you live at school?
Why is your pc there then
i get here at 7:40 and leave at 7
tf feels bad
because its a laptop and i can bring it
Ohhh
does anybody knows a good article or video about making Bungeecord configs in Kotlin because I can't get it to work
Yes spam this in every channel
?
my VPN still works
ok I have a really dumb issue
I open a new inventory when a player clicks an icon but it's carrying the click event to the next menu
letting go of the click may be causing the click event? maybe? never worked with it
open the inventory one tick later?
I tested that specifically actually, it's not it
I really wanted to avoid doing the 1-tick trick
the snippet is uh a bit massive
thats what the paste is for
actually
I think I might have a trick up my sleeve let me test real quick
it's really dumb too
code is dumb alltogether, that translates into the solutions you make for problems you didnt need to have in the first place
Is there an event that is triggered for ANY block breaking, changing state, victim of an explosion event etc, or is there a way to tell when any of these events happen.
I currently have a plugin which listens for each of these events, and adds blocks to an array to be reset later - This mostly works however sometimes blocks are not replaced, which is why i was wondering if there was any event that catches any block changing state or being destroyed or changed.
It's a shame the BlockBreakEvent is only called when broken by a player 😢
ignorecancelled set to true, I suspected it was literally using the same click event even though it was a different menu
this sort of feels like a spigot bug
well
at least I avoided doing another 1 tick trick
I hate those, they always come back later to bite me in the ass
player.playEffect(Effect.valueOf(plugin.getConfig().getString("sound")));
Most of it is fine as is,
lol respawning players is cringe I dump them to spectator mode when they would've died
um is it correct?
The only blocks that are not being detected seem to be stacked blocks
As in, a bottom cactus breaks
The top one is not detected to be broken sometimes
also important side note my trash bin bugged out
I think it's broken, it no longer automatically opens
shit sucks it worked for all of 4 days
imagine having to debug your trash can
How i add a resource pack in my server spigot?
tbf I fed it too low a voltage
but to be even fairer they didn't include the power cable for it
look the store page said 4 AA bateries
it gets here and says 4 D batteries
all I have to say about that is D-z nuts
oh shit I'm stupid
Not sure, what I'm missing
I just realized I turned the power socket off on purpose to enter recording mode
alright debugged my trash can
on with the next one
yep works just fine
How can i insert a zip file in a txt file?
I'm not saying strictly speaking that that is impossible but I am saying that it is the most stupid thing I've seen this month and it's been quite the month
BlockBurnEvent, BlockCanBuildEvent, BlockCookEvent, BlockDamageAbortEvent, BlockDamageEvent, BlockDispenseEvent, BlockDropItemEvent, BlockExpEvent, BlockExplodeEvent, BlockFadeEvent, BlockFertilizeEvent, BlockFromToEvent, BlockGrowEvent, BlockIgniteEvent, BlockPhysicsEvent, BlockPistonEvent, BlockPlaceEvent, BlockReceiveGameEvent, BlockRedstoneEvent, BlockShearEntityEvent, BrewEvent, BrewingStandFuelEvent, CauldronLevelChangeEvent, FluidLevelChangeEvent, FurnaceBurnEvent, FurnaceStartSmeltEvent, LeavesDecayEvent, MoistureChangeEvent, NotePlayEvent, SignChangeEvent, SpongeAbsorbEvent 😭
Hahahahahaha,i thought this too when he said that to me
Hol on thats specifically apex
I don't use apex
technically you can get the zipped file as an object, turn that into a string and put the string into the txt file, then later interpret the string as whatever kind of object it originally was
I'm replying to the guy who asked how to put a zip file in a txt file
I know
he was trying to put a resource pack on their server?
I'll do it alone as always
yeah that's not right
Goodbye
hell yeah I love it when people get help and then act sassy
ong
Is there an easy ish way to teleport to the dead center of a block? I'm trying to teleport myself to a projectile location but it's of course not always centered which bothers me
add new Vector(0.5,0.5,0.5)
as easy as that
awesome
that being said you probably want y = 1 unless you're really into being inside of blocks
player.teleport(enderPearl.getLocation().add(0,2,0).add(0.5,0.5,0.5)); is what i have
But i think i might get rid of the first add and replace the second Y level with 2
This method https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/HumanEntity.html#getOpenInventory() says that if the players doesnt have an inventory window open, it return their internal crafting view, how can I check that?
if (e.getWhoClicked().getOpenInventory().getType() == InventoryType.CRAFTING)
If that's what you meant
Yeah that's it, thanks!
np
anyone know a good update-to-date public anti cheat base? I cba to make my own
like all the other files
Like check and checktype
and the data
i’ll do it later, just grit through it
he didn’t google what he wanted first 💀
noob move
I rmr when i didn’t understand what docs actually said 😢
🙌
someone teach me how to read docs they are confusing lmao
alr
I gotchu
first attach some eyes on your face
make sure you attach 2
then do this function
public void useBrainPower(Human human){
human.learnToRead();
human.useAttachedEyes().useBrainToRead();
}```
I have a custom inventory with a name that I assigned with a class, is there a way to get that inventory given the name?
Yeah but how do I get the inventory
getInventory()?
getdisplayname()
what are you trying to do
Inventory#getTitle()

