#help-development
1 messages ยท Page 1406 of 1
PacketType.Play.Server.WORLD_PARTICLES
The goal is to remove that when a mob dies
if I do /particle poof
It does remove the particles though :/
So it works
rip :/
i don't know if those particles are spawned by the client, but they might
It seems that they are
Since when I do the command it does cancel them
but by killing the mob it doesn't
well i dont seem to get them on my packetlistener
server particles != client particles
ik
shitty mojang logic
what you can do
Yup :/
is like i said
i was going to write a plugin to redo the shitty sound system of the game
but turns out not possibru
that's for spawners i think
rip sheeps
remember the old player damage sound
wdym
the new damage sound is so boring
lol
"install or kick"
modded clients still go around it obviously
but i'm pretty sure someone said that servers can now tell the client that they can't join without the resource pack
not that easily anymore
Resource packs has SHA-1 hash verification check
if that check fails
kick the player
i mean yea
but i would like to have no prompt whatsover
do text components not support rgb values?
huh?
use the chatcolor class from bungee
the chatcolor class in bukkit doesn't support rgb
ChatColor.of is the factory method for arbitrary rgb colors iirc
is that supposed to mean anything to me
I'm sending the code just wait a second ```java
String message = teamIcon + Color.translate(player.getName() + " &7ยป " + event.getMessage());
TextComponent outMessage = new TextComponent(" " + message);
outMessage.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + player.getName()));
outMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(Color.translate(hoverText.toString()))));
Bukkit.getOnlinePlayers().forEach(loopPlayer -> loopPlayer.spigot().sendMessage(outMessage));
player.sendMessage("Message: " + message);
it's the same message, I'm using a color parser already
but if it's sent with the text component the color messes up
the parser is using the chatcolor api from budgee not the spigot one
is that resource pack prefixes?
yes just don't mind them, the only thing is the color not working if it's sent using the text component
i have literally no idea what i'm looking at, but
Color.translate(hoverText.toString())
are you sure the toString shits out something that is translated properly
it's a stringbuilder
256x256
those are text components
yea but can it render pictures?
does the TextComponent string constructor parse colors
i'm not seeing you applying a color or decoration to the component itself
do these components work in a titles subtitles?
the thing is the color is being parsed on the message before, and the message variable is being passed to both
message is a string
yes
yes it is
what about in gui titles?
then the next question is whether textcomponent constructor parses legacy color codes
because your string uses legacy color codes
the bot is trash
lol
huh
lmao
it's utf, it works on anything text is used in
so its kinda font format like
i don't think the textcomponent ctor parses legacy colorcodes into proper component colors
so how'd you manage to get that TEAM thing? ๐ kinda interested
looks nice
guy I will help you with that, if I get the thing I am working on fixed xD
I am asking if the text component doesn't parse rgb colors
again, I don't think the textcomponent ctor parses legacy color codes
already asked it
scroll
there's like a util method somewhere that parses them
as for where it is or what it's called i have no clue
just traverse
just use adventure tbh
the component code
adventure?
its component api
the better and actually consistent and good chat formatting library
but better
it's bundled in by paper and integrated into their api now
but you can still use it as a dependency as you would with any other library
link to the api?
texture packs open up a lot of stuff, you can pretty much create a custom game in minecraft
I hate it because the only way to really force a user to use it is to kick them if they decline it
1.17 has a new screen for it
hoowee what's this
well yeah anyway it shows how much you can do with custom textures
if only we had like custom models and shit as well
or could texture worn armor pieces
it looks great on the surface but when you start doing anything with it you realize how lackluster the custom x support is
i can only get so hard
Does anyone know how I can delete entity hitbox? I tried ...getBoundingBox().resize(0, 0, 0, 0, 0, 0); but it nothing changed :/
define changed
the server doesn't send bounding box information to the client
the client computes the boxes separately
so you can't for example make a player click through an entity
it will still appear as if the player punched the entity on the client side
and also, that code makes no sense lmao
That wouldn't even change the size of the bounding box
Not sure but I'm pretty sure that's like
Amount to change in each direction
They're passing 0 for all args
So it wouldn't change the size regardless
lol
then is there any way to remove hitbox entity?
so rude
depends on what you mean by remove
you can remove it on the client side
but not through the api
lmao what?
and it won't be easy
custom client
I might have found a solution to get it working with the components
the bounding boxes and are set like every tick
for client side hitboxes, you can do nothing
the client computes those on its own
you can't tell it to make them go away, or tell it to change their size
I have slime as player's passanger, but it blocks my field of view with its hitbox, so I can't block, capture, etc.
so i can get a slime effect similar to armorstand marker?
a what
okay it works, even if it seems like a hacky solution in code
that if I click with the right or left button, I will not click on the hitbox
Is the slime to be viewed by only you or others?
ultimately, it will not be visible to anyone, because there will be an armorstand with a nametag on it
what about this armorstand
is it visible to the player themselves?
or only to others
Then why are you putting a slime on it?
others
because if so, like I suggested when you asked last time, you can hide the entity through protocol fucknuggetry
to set armorstand at the certain height
for that, you'll want to hook up into protocollib and block all of the packets for that entity from going to that player
Why can't you just calculate the height?
supposedly when he tried to move the armorstand manually, it ended up lagging behind the player
and can i do this if armorstand is my passenger? It does not have a constant height then?
although now that I think about it, that shouldn't happen
ah
since if both the player movement and the armorstand movement packets are sent at the same time, they should move in sync
more or less, anyway
and only for other players
Is there a reason you are using a slime as the passenger, then the stand on the slime? Can you not use two stands?
as Armorstand is a LivingEntity and they can both be and have passengers
Not sure its going to fix your hitbox issue anyway
you could make the first armorstand a small stand then the one on top normal size
small stand = smaller hitbox
or how about a parrot?
tiny hitbox
although the parrot has a small hitbox, you can hit it
last time you said that with the approach where you manually made the armorstand follow the player, the armorstand appeared to lag behind the player, right
can you show your implementation of that
a tried with snowballs, because i cant hit snowballs, but i cant make snowballs invisible
i teleport armorstand to player location
and how did you measure this supposed lag
did you look at the armorstand over your own head?
wait a sec
or did you have another player look at it
i can't see replies
no
did you have another player look at it
i'm asking this because that method will appear laggy, but only to the player viewing their own armorstand
to all other players, it should appear perfectly synchronous
if you don't require the player to see their own armorstand, the approach should be sufficient
It looks like a baby chicken has the smallest hitbox
elgar, you can see replies right
yes
did tuso reply to anything
wait a sec, yes and no
i can't figure out whether they answered yes or no
Baby rabbit has smallest hit box
You could also put them on the same team with pvp off for the team. May not affect the hitbox though
pretty sure that just makes no damage happen, it'll still absorb the punch
hola
I am here for help
I am receiving this error
here is the registerCommands() method
getCommand("addhunter").setExecutor(new AddHunterCommand(this));
getCommand("gethunters").setExecutor(new GetHuntersCommand(this));
getCommand("removehunter").setExecutor(new RemoveHunterCommand(this));
getCommand("togglenethertracking").setExecutor(new ToggleNetherTrackingCommand(this));
getCommand("addspeedrunner").setExecutor(new AddSpeedrunnerCommand(this)); //issue occurs here
getCommand("getspeedrunners").setExecutor(new GetSpeedrunnersCommand(this));
getCommand("removespeedrunner").setExecutor(new RemoveSpeedrunnerCommand(this));
}```
I'm confused on why I am receiving it
Line 33 of main is throwing an NPE on reload
what is line 33
registerCommands();
its the method
and I provided the method code ^
it's happening with the addspeedrunner
ok now i tested it and the lag still occurs from another player's perspective but it is much less
is 33 this exact line ?getCommand("addspeedrunner").setExecutor(new AddSpeedrunnerCommand(this));
I can;t help you if you don't tell me what line 33 is
did you teleport the armorstand in the player move event
line 33 is registerCommands()
or did you do it every tick
the error is at line 49
which is getCommand("addspeedrunner").setExecutor(new AddSpeedrunnerCommand(this));
then addspeedrunner command is not defined in your plugin.yml
in player move event
it is tho
maybe he typo'd again while fixing it
is there a way to get the raw text of a component?
hey, how would I import the spigot 1.8.8 api in intellij?
maven or gradle
maven
If you use eclipse you can just use build path but I dont really know if there's a feature like that in intellij
ye thanks
another question though
how come e.setCancelled(true)doesn't work on PlayerMoveEvent
shoot
the server can't cancel the movement
so how would I cancel it then?
it can only undo it
which causes jittering and rubberbanding on the player's end when the player is forcibly teleported back
I figure i can get the players location and then if they move it tps them back
if you want to make the player unable to move, set their walking speed to zero
double x = location.getX();
double y = location.getY();
double z = location.getZ();
if (player.getLocation().getX() != location.getX() || player.getLocation().getY() != location.getY()
|| player.getLocation().getZ() != location.getZ()) {
float yaw = player.getLocation().getYaw();
float pitch = player.getLocation().getPitch();
location = new Location(Bukkit.getPlayer(player.getName()).getWorld(), x, y, z, yaw, pitch);
player.teleport(location);
I did this
still causes rubberband effect if you do tp
would that work?
either way, it will still cause that rubber band effect
yea its not a big deal
but just in theoru
how would I do it without the rubberband effect?
I haven't seen that before
every server I see has a rubber band effect
.
setting it to 0 doesn't work, what should I set it to instead?
actually idk if it works
cause it just completely crashes my server
sounds like you're doing something wrong
How do i add events to a custom item
??
wdym
"add events to a custom item"
you can only listen to events
not add or remove them to anything
i was reading the docs trying to plan out how i want to try doing something.
i read in EntityChangeBlockEvent: "Called when any Entity changes a block and a more specific event is not available."
is there a list anywhere that specifies which entities cause this event?
you can mark the item somehow, with either a special name, or persistent data, etc. and then in whatever event that could involve that item, just check for the mark and do stuff if it's present.
guys wahts th event when a player places a cake on th world :I
blockplaceevent but i need to know what the cake item was...
nvm im dumb lol blockplaceevent has getItemInHand()
Is there a library for building cages?
why does this happen? https://gyazo.com/a0bb7e4f9ab860894af0e329b3902a0b
current code https://paste.md-5.net/recurolaru.coffeescript
How do I put more than one of my plugins on a server? It gives an error "This plugin has already been initialized".
More than one plugin
No
show the structure of the files in your code editor
mostly plugin.ymls and the main classes
Ok
In short, two plugins with the same plugin.yml will not work?
as in like this
please learn naming conventions
yeah you probably have same package names
your primary plugin class shoulden't be named 'Main'
especially since both main classes are named main thats even worse
the whole point of the package is so that the plugin loader doesnt confuse your class with another plugin's
which, in this case, it is doing since they are both the same
Make sure to look into code conventions aswell, as your class names/capitalization/package capitalization is a standard, not just random
package me.mrpiedot.PantsThatPoopTnt.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleSneakEvent;import me.mrpiedot.PantsThatPoopTnt.Main;
public class TntCommand implements Listener {
private Main plugin; public TntCommand(Main plugin) { this.plugin = plugin; Bukkit.getPluginManager().registerEvents(this, plugin); } @EventHandler public void TnTCrouchEvent(PlayerToggleSneakEvent e) { Player player = e.getPlayer(); player.getWorld().spawnEntity(player.getLocation(), EntityType.PRIMED_TNT); if (event.getItem() !=null) { }}
why am i getting a error saying that event cant be resolved
because your event argument is named "e"
if (event.getItem() !=null)
event is not the name of your event:
public void TnTCrouchEvent(PlayerToggleSneakEvent e)
check inbox
what
Hello, I would like to send a string message from config, but replace %player% with e.getPlayer(). The only methods for replacing words in a string were either with chars, or using regex, although I believe there was a much easier method
String.replace
I've tried:
configmessage.replace("%player%", e.getKingdom());
But that method only uses chars for some reason?
Takes a regular string for both args
Are you sure? For me, it says I have to cast it to a char
What's e.getKingdom() returns?
String implements CharSequence, so itโs usable there
I'm not sure, but I just tried String.valueOf(e.getKingdom()) and the error is gone
You can also call toString
Although getKingdom sounds like something that would have a getName method
Well... what does getKingdom() return... if it's a Kingdom object then its toString() probably isn't what you want
sounds like something that would have a getName method
Exactly my thoughts
Your IDE should tell you what's e.getKingdom() returns.
For example, getClickedBlock() will return Block
Yeah I just realized, I can do e.getKingdom().getName()
ah, there you go.
Hmm, it's still not replacing it correctly for some reason
Keep in mind strings are immutable
What does that mean?
the string that u use to invoke the replace method doesn't change
It means any methods that modify them return a new string
And the one you passed isnโt changed
By the way, for context, I'm making a plugin that sends a webhook message when a kingdom (another plugin) gets created using that API. Here's the part with the config message:
String configmessage = KingdomsWebhook.plugin.getConfig().getString("new-kingdom-description");
assert configmessage != null;
configmessage.replace("%player%", e.getKingdom().getName());
embedBuilder.setDescription(configmessage);
Here's the default config:
new-kingdom-description: "**New Kingdom created!**\n*Name:* %player%"
And it's still not replacing the %player% sadly
That makes sense, thanks
do the replace on the embedBuilder.setDescription.
embedBuilder.setDescription(configMessage.replace(...));
sorry im not english so i might have a typo
Hey, does anybody have a way of creating a "Fake Lead"?
Like, a lead that goes from the player to a target block?
How do I check if a player survives or not survives an mlg inside a playermoveevent? because this doesnt seem to work: ```java
if(player.getFallDistance() == 0) {
player.sendMessage(Main.getPrefix("ยง2MLG") + "ยง7You have ยง2completedยง7 the MLG. This was your ยงa" + mlgs.get(player.getUniqueId()) + ". MLG");
}
else {
player.sendMessage(Main.getPrefix("ยง2MLG") + "ยง7You have ยงcfailedยง7 this MLG. This was your ยงc" + mlgs.get(player.getUniqueId()) + ". MLG");
player.setHealth(0);
}```
how do i prevent people from naming mobs
well actually
let them name it
but then rename the mobs back to what their original names (but a bit different)
Try a scheduler or check if player health <= 0
I need to check inside the playermoveevent
What is MLG?
In non-english speaking countries they still live on
if(Objects.requireNonNull(f.listFiles()).length > 0) {
for(File file : Objects.requireNonNull(f.listFiles())) {
return file.getName().equals(fileName);
}
}
return false;
}``` Correct?
Try it. If not debug.
how would i make creepers not leave behind their effects when they explode
ok
i am trying to make a mob levelling system
like lvl 1 creeper
etc
and give them strength depending on their level
but
creepers leave behind strength 10 if they are level 100
and its permanent
so kinda need to fix that
any ideas
i saw these memes like 5 years ago
last time
I imagine that these memes are the latest shit on the Spanish internet if I know them right
do you have calling overhead in java?
yes, but it is very minimal in modern JVMs
Plus JIT can inline methods if it feels like it; Javac can also do that but it is a bit more restrictive on when it does it
Hey, can someone tell me why this code is not applying the new enchantment levels? It sysouts the debug messages correctly with old enchantment level and right multiplier
public static void multiplierCheck(Player player) {
multiplierCheck = new BukkitRunnable() {
@Override
public void run() {
for (ItemStack i : player.getInventory().getContents()) {
if (i != null) {
ItemMeta iMeta = i.getItemMeta();
NamespacedKey key = new NamespacedKey(main, "UUID");
if (!iMeta.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
if (iMeta.hasEnchants()) {
Map<Enchantment, Integer> enchantments = i.getEnchantments();
for (Enchantment ench : enchantments.keySet()) {
Enchantment oldEnchants = ench;
int oldEnchantLevels = enchantments.get(ench);
i.removeEnchantment(ench);
i.addUnsafeEnchantment(ench, oldEnchantLevels * main.multiplier);
System.out.println(oldEnchantLevels + " " + main.multiplier);
System.out.println("added");
}
iMeta.getPersistentDataContainer().set(key, PersistentDataType.STRING,
UUID.randomUUID().toString());
i.setItemMeta(iMeta);
}
}
}
}
}
}.runTaskTimer(main, 0, 5);
}
adding enchant to the item then overwriting its meta (and therefore the new enchant) with the old meta
no, you should add the enchantment to the meta, not to the item
since you're setting the meta back at the end
addEnchantment
This will still add the unsafe ones aswell?
boolean
?
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
it works but the file with this name is not created. Any idea?
Might be the way files are handled with that lib. I'm not sure though
oh... The file is not created because it gets the file with the other spelling and changes in this file the values. So I type /add test and the file with the name "Test" which already exists is changed
Any idea? with this
If its changing the name of the file then yeah its probs the lib Files
no it doesn't changes the name of the file but the text which is in the file
I'm lost lol... whats the issue exactly?
When I type "/add Test" a file is created with the name "Test". In this file stands: "name: Test". And now when I type "/add test" no new file is created but the text in the file named "Test" is changed. The text in this file is now: "name: test".
But I want that a new file is created
Then yeah thats the lib doing that. It might be the OS that doesn't allow caps to have duped files.
is there anything I can do?
If its caused by the OS which I assume it is no lol. If its caused by the Files lib you can try creating your own ways.
Windows allows for files with independent cases
Either way I'd suggest to enforce lowercase
Hey, I got a question about publishing resources on the spigot site. If someone wanted to publish their resource for free, but charge for support, could that be done through a third party, our would you still want that sold as a premium resource? This is entirely hypothetical, but in thinking about this, I figured selling support as premium could be restrictive as it is a one-time purchase.
If anyone happens to know, please mention me.
You can do that. Spigot doesn't enforce support.
Awesome, do you know where I could find the rules about this
IDK the free one command
Yeah, turns out i've seen the premium one before, but yeah, the free one is more elusive
Stay in #help-server
what plugin is for selling ranks (in-game money)
using a custom world generator, can I control which blocks are generated? imagine I want to limit the world size to 10k blocks, can I prevent placing blocks that exceed X/ -X / Y / -Y coordinates beyond 10k?
Well, you can generate these are void chunks, but why not set the World border a bit before it?
I am drafting an idea for a world generator
kinda like you open up you atlas and view the world: rectangular. "top" and "bottom" spawning ice biomes, gradually working up to the "equator".
scaling that whole generator up to the limit of the world-size property would be.... very huge, I guess. if you have to walk for ages to the north, knowing, you would never reach it.
what plugin is for selling ranks (in-game money)
this is development. try #help-server .
one of my ideas involve getting the generator to create more continents. I somewhat dislike the clumsy allocation of landmass in the vanilla generator
yes, but you can't simply stop somewhere, if you want to you can hide that by setting a world border
why can't I just stop?
It would look ... off
at X=30M, that is exactly what is happening anyway
That's for another reason
I think for the same reason: the world size is reached
But why don't you just don't generate these chunks?
@EventHandler
public void onAnvilUse(PrepareAnvilEvent e) {
if (main.commandCalled) {
Player p = (Player) e.getViewers().get(0);
if (e.getInventory().getRepairCost() >= 5) {
main.getServer().getScheduler().runTask(main, () -> e.getInventory().setRepairCost(2));
}
}
}
can someone tell me why this is not working? Its not setting the repair cost to 2 when the repair cost is >= 5
well, you answered that before when I asked if I can control to not place blocks.
Ah well, misunderstood you
Generally world border should prevent player-lead placement. However you can also cancel all Block-related events
sounds good enough. I shall later look into the world generator tutorial I found and see if I can make it to align each biome in Y=5 wide strips
afterwards, writing some perlin noise and implementing the rules I want should do it.
I think vanilla makes biomes align in 2x2x2 blocks, though I don't really know
So you can only go with either 4 or 6 wide strips
I will see :D you answer gave me an idea of what should be possible
why your are running it in a task
oh
I read in spigot forums
I havent, i will rn
by checking if the if statements are working
@mortal hare I love you
Where can I get the spigot mappings?
You can use MiniDiggers mapping viewer
I want to decompile a spigot jar
But why
BuildTools does that for you but indeed why
I want a custom one
i myself see no use of mappings viewer because intellij works pretty well at decompiling the jar
^^
If you want a custom fork there are wiki pages on how to do it
Manually decompiling the spigot jar isn't one of the steps
who what now
Can I get a link?
Oh lord the hub's backlog is overflowing
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
So the manual steps are given but it also specifies a BuildTools method for automatically doing it. How to do that?
download and run BuildTools
<build folder>/Spigot
Ok
How to import Spigot API?
does optifine custom texture pack work on a spigot server?๐
because i need to set texture for items
i'm trying to make custom items
You dont need optifine for custom items
https://www.spigotmc.org/wiki/spigot-plugin-development/
You will find what to import here
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
mappings viewer is nice
because the md mappings are dumb
and being able to see what nms classes and fields and methods are actually called is nice
I think you might have to just re-send the spawn and metadata packets after sending one despawn packet.
i'm trying to make a plugin with custom item texture
fx for Rotton Flesh (Name Is="Cook Flesh")
Yes. That might be enough actually.
Then you dont need optifine for that.
what do you suggest? i should do?
you should eat regularly and healthily, and excercise daily
or did you have something specific in mind
don't forget to drink water and change your socks regularly, too
Just set the custom model data of the ItemMeta and change the items appearance in your resourcepack after that.
is there a way to get the raw text of a component?
Have you tried toString yet?
yes and it returns all the information on the component not just the text
Oh i see. You just want the text of it
if its json output
just use gson
to get the key value
or implement your own hardcoded toString() with indexOf() and substring()
idk if there's a method to get the text
but that are my solutions
is there a way to make a projectile not collide with another one in the spigot?
no
setCollidable(false) dont work
or use adventure
Paper only allows it
and use raw component serializer
Paper has onProjectileCollide event
yes ik
and its really graphically unpleasing
it just warps the projectiles behind
with that same velocity
projectiles don't collide with other projectiles
i mean you can design your own
in fact projectiles don't collide with anything
i mean entity
projectiles don't have collision code
i mean,
what about arrows?
idk u make me ungry
whatever
entity seeks for to get hit by an arrow
logical
i mean more performance friendly i guess
How do I add the Spigot API?
if you want to make an entity not collide with another entity, you have to set them both to not collide
you can implement your own version of projectile collision
there is a commande for the clearlagex?
if you only set entity a to collidable=false, entity b can still collide with entity a
Not sure if it would work but have you tried adding all projectiles to a Team and disable collisions and friendly fire?
even if entity a can't collide with entity b
if you see my project,
let me see if i find a old gif
the team thing could work
maybe, maybe not
oooh
i dont think so
doesn't matter, as projectiles don't collide to begin with
he's probably talking about regular entities
vinny7 how do I add the SPigot API?
but projectiles are entities too
dovidas
?
read the fucking guide that was linked to you
import the spigot api jar via maven gradle or build system of your IDE
@wraith rapids it doesn't help
are you using intellij or eclipse
here is for intellij
if you use eclipse get fucked i guess
What's an IDE?
he just literally took a screenshot of IDE
lol wtf
the icon in the taskbar looks like eclipse
its an eclipse with build settings opened up
What do I do?
import your downloaded spigot api
How
you are on file selection
you either switch to intellij or ask dovias to link you a guide for eclipse
just select that jar file
or god forbid google and find it yourself
I can't find it
I don't know how to find it
I installed BuildTools
maybe throw eclipse as a keyword in there too
Rubbish, don't do that
You can also use the server jar, it will work as it has the api in it
Follow https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse) instead
real men use ant
I have updated it to 1.16.5 a few days ago, so it will be somewhat up-to date
Lol
static {
NAME_MAP = new HashMap<>();
ID_MAP = new HashMap<>();
for (ParticleEffect effect : values()) {
NAME_MAP.put(effect.name, effect);
ID_MAP.put(Integer.valueOf(effect.id), effect);
}
}
why it's saying illegal forward reference?
Why can't I import?
Have you added Spigot as a dependency
You are probably attempting to instance your class before Bukkit has initialized the ParticleEffect
You also havn't defined values()
You probably mean ParticleEffect.values()
Hey, for my Project I need "animated inventories" basically once I open the inventory I want the items to come in from the right side. I have started working on a class for that (https://paste.sentinalcoding.eu/KQWlc98k2Q) but there is a small flaw: As I need to move the items every 5 ticks for the animation, my guess was to just set the items in a hashmap with a current "fake" and just always subtract 1 and re-set all items. but I am not sure how to calculate which int I have to assign to each of the items in order for just subtracting them works
so If there should be an item on slot 0, and I set its current slot to slot 8, just subtracting 1 would work, it would end up in the right slot, but I am not sure how to efficiently perform the math on all items, to get the proper starting slot for them
so basically for the first column of items, I need to get the furthest right slot, but what do I do with the other columns.
My goal is to achive something like: https://streamable.com/idxwm4
public enum ParticleEffect
{
EXPLOSION_NORMAL("explode", 0, -1, new ParticleProperty[] { ParticleProperty.DIRECTIONAL});
illegal forward reference is when you refer to something that doesn't exist yet
is your static block in that enum class?
what does that mean?
yes, I guess?
You guess?
hiElgar
Hi sweetie
how 2 import splรถgget
Did you add the dependency and repo in your maven pom?
ok it's in that class
illegal forward reference is when you're trying to reference something that doesn't have a value assigned yet
@quiet ice I did this
you can't invoke an enum's values() before the enum is initialized
That is the wrong way of doing it
How do I do it?
read the guide that was linked to you
You have no enums when your static block executes
I cannot really say because the only poms that I have are pretty bloated
I did
Basically it should look like this, just with 2021 stuff
Are you talking to me?
yes
I am supposed to type that stuff?
either way, the way you did it is wrong, you should not use JDT as your build tool
Not really, you did follow a guide right? That one should have the up to-date info
bump
What is the ding sound effect?
which version
1.12.2
Which one? The XP sound or the Noteblock one?
alright, i'll test it.
doesn't that have its own dedicated sound
maybe, idk
who knows
show the full exception
and not in a screenshot
let take the log
I think it's the orb pickup, thanks.
I assume that an array with a struct that has {index, variance, stack}, you'll iterate over it and add index and variance together, if the sum of it by the modulo of 9 is not equal to index modulo 9, then you don't display it; the itemstack stack is then placed on the inventory at index index + variance, after that you'll decrease variance by 1.
Honestly, variance could also be a "global" property
I would not use a Hashmap for this
I'm confused
woah, okay sooo that sentence sounds sooo smart, but I don't get it.
it was the first thing that came into my mind, have a hasmap with the resulting inventory, and one with the current animation progress.
geol do you use IntelliJ?
No, eclipse
How do you do it?
maven is still same in both
are you physically incapable of reading the guide linked to you
Via maven or gradle, JDT is absolute cancer to work cooperatively
or is there some issue you're not mentioning
I've already read it
I don't understand it
public enum ParticleEffect
{
EXPLOSION_NORMAL("explode", 0, -1, new ParticleProperty[] { ParticleProperty.DIRECTIONAL});
static {
NAME_MAP = new HashMap<>();
ID_MAP = new HashMap<>();
for (ParticleEffect effect : ParticleEffect.values()) {
NAME_MAP.put(effect.name, effect);
ID_MAP.put(Integer.valueOf(effect.id), effect);
}
}
}
or perhaps a monkey
isn't effect id already an integer?
populate the name and id maps in the enum constant constructors
Basically you'd have a
class Entry {
ItemStack is;
Integer index;
}
and a
Entry[] stacks = new Entry[36];
int animationProgress = 9;
to animate it you'd use
for (Entry e : stacks) {
int actualIndex = e.index + animationProgress;
if (actualIndex % 9 != e.index % 9) {
continue; // Out of bounds (would display on the next row)
}
// Display item
}
okay and when displaying the item, I just actualIndex as the slot right?
that's not the issue here
I think so, yes
Is it possible to register your plugin without extending JavaPlugin? I want to create my own custom class
extends Plugin
whoops yea
Ok but I want that the subclass can't override methods
Or implements, idk Plugin might be an interface
Yes Plugin is an interface
But if I look into bukkit's loader, I see plugin instanceof JavaPlugin
Let me see
Plugin is an interface iirc, JavaPlugin is the impl
Yeah, I think you'd need to boostrap the plugin
bukkit is rigged to only work with javaplugins
so how do I fix this?
I read all the link you sent.
The problem is illegal forward reference
So basically you will need to use a Plugin that loads the other plugins.
nix
like I keep saying
illegal forward reference is when you defer to something that isn't set yet
in this case, likely the values() method
since the enum constants aren't defined
You are iterating over something that will be initialized later
populate the id and name maps in the enum constant constructors
not in a static block
The enum constants are populated AFTER your static block (in the same static block)
And then in the plugin.yml's they have to point to my class?
What are you trying to achieve? Create a plugin loader or something else?
okay I guess I have to populate stacks first, does the Index in Entry have to be the current slot or the slot it should end in?
I want to let people extend my custom class, but I want to prevent them from overriding methods, and also I want my own return type for the getConfig
the slot it should end in
Can't you mark it as final?
I think you can override it
No, I don't think so
Yes and my custom return type?
Does the custom return type extend the original return type of "super"?
You can;t override a method and have a custom return type
got it, one last thing, I need to call a callback once the animation is over, how would I implement it with your code? eg once all Items are on their index
While the JVM would allow methods with different return types but the same name, javac does not allow it.
So you'd need to choose another name and/or deprecate the old one (and optional throw an OperationNotSupported exception)
the return type of an overriding method must be the type of the overridden method, or a subtype of it
I have this structure:
public interface Configuration
public class BukkitConfiguration implement Configuration
public class BungeeConfiguration implement Configuration
public class ConfigFile // Return type, and this will work with my Configuration interface
you'll have to deprecate the javaplugin getConfig
As soon as animationProgress is equal to 0 the items are where they should be
and declare a method with a new name
Ok, but Bukkit will never remove the method
Or I just override and return null?
got it, how does this look: https://paste.sentinalcoding.eu/ToROMg4ir5 is it correct?
override and throw not implemented exception
or operationnotsupported
whatever tickles your pickle
The class is named Configuration
if your plugin framework has a name, you can use that
or just getConfiguration, literally whatever, use what name you think is good
Looks good to me, of course you could make things final but meh, not a real issue
Ok and why not getConfigFile ?
Cool I will test it right away!!
Yes, why not? You choose.
Ok
Hello, I am tryna make a plugin which replace messages, When it tries to register AsyncPlayerChatEvent it shows an error
Could not pass event AsyncPlayerChatEvent to Emoji v1.0 org.bukkit.event.EventException
any help :)
go on
Show your code and the rest of the stacktrace.
Where do i paste lol
embed fail
i don't have embed perms
#help-development message how solve this
maybe I should create a sockpupper alt just to verify this account
then again why bother
Where do i paste the code than flooding here..
?paste
and the exception
I made a problem with translateAlternateColorCodes ig..
any help would be appreciated
what's on the relevant line of the Main class
me.Hazim.io.Main.PlayerAsyncChat(Main.java:152)
you didn't paste the entire class file so we don't have line numbers
message = message.replace("<3", heart + ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("afteremojichatcolor")));
my guess is that the config getString returns null
add defaults or nullcheck the return values
You can provide a default value as the second parameter when you get values from the config to avoid that.
and ideally, cache the values instead of grabbing them from the config every time individually
configs are quite slow
Yeah you are right, i am so dumb i forgot to save the config
No, i am slow :)
The default config is cached already.
yes, but each get is still a map lookup
which is several orders of magnitude slower than a regular field get
still fast, yes, but also orders of magnitude slower
doesn't matter because it's the async chat event, yes, but still good practice
That is true but still won't cause any performance impact. But for the most part you should cache yourself. I don't disagree with you : )
how solve this #help-development message -.
my client doesn't support message links
can you copy paste the message or something
You are getting a value that doesn't exist.
oh.
You should check if the value is present.
inside of method ?
i guess i'll go looking for it
Optional.of(entities.stream().filter(e -> e instanceof ArmorStand && e.getLocation().distanceSquared(loc) < radius).findFirst().get());```
I suppose that is the issue without have looked closer at it.
right
If there is no armorstand in the radius then you are calling get() on an empty optional
Which causes that exception.
And why are you wrapping it in the first place?
Just return the result from findFirst()
i'm starting to use optional
Just return
entities.stream().filter(e -> e instanceof ArmorStand && e.getLocation().distanceSquared(loc) < radius).findFirst()```
^ in this case ill not catch the exception ?
the exception is thrown if you call get on an empty optional
I imagine config gets would be faster without the string stuff
you are not calling get here at all so the exception can't be thrown
which is what you want
then later you call ifPresent on that optional to perform an operation, but only if the optional isn't empty
aaah right
im still getting null..
but i dont know why
public Optional<Entity> getClosest(final Location loc, final double radius) {
final List<Entity> entities = Arrays.asList(loc.getChunk().getEntities());
return entities.stream().filter(e -> e instanceof ArmorStand && e.getLocation().distanceSquared(loc) < radius).findFirst();
}``` i dont know if its because a filter
but and usually when I get it
hey for some reason this method causes a nullpointer Java public static ItemStack restoreItemStack(String data){ return ItemStack.deserializeBytes(Base64.getDecoder().decode(data)); } but I am not sure why, the string passed is loaded from the Config, and the string in the config is set using: Java public static String StringifyItemStack(ItemStack itemStack){ return Base64.getEncoder().encodeToString(itemStack.serializeAsBytes()); }
the error is: https://paste.sentinalcoding.eu/4CbRmO1ZiW
is use similar code in a method that returns a list of string with the contents of an inventory, and that works fine
What's at line 54
its this return ItemStack.deserializeBytes(Base64.getDecoder().decode(data));
Then data is null?
null pointer exception is thrown when you .call a method on a variable or a field that is null (a null pointer)
Have you checked that?
I know what causes a null pointer, but the value is read correctly, so I thought its passing it correctly, let me double check
PaperUtils.java:54
oh wait, nvm I think its just a spelling issue when reading from the file
and this is why I always recommend using in-source configuration management
the IDE will be able to catch typos in keys and whatnot for you
that sounds good, do you have a ressource that explain how to properly set it up and use it?
there are config frameworks that do it, uh, the first one that comes to mind is configurate
Configurate is undoubtedly a nice config framework
so this is the error I get when it runs your code: https://paste.sentinalcoding.eu/WkhXnH1I5A I guess its just a simple fix, but I am not sure how to fix it in your code: https://paste.sentinalcoding.eu/YoQoqb3Ie6
of course those are for actual configurations
what you're doing looks more like storing arbitrary data than a configuration
yea true, but I will take a look on configurate, I have heard about it before.
where exactly is line 74?
between lines 73 and 75
thats just the ClickInventory class I use, that method just sets the item in the inventory.
public void setItem(int slot, ClickableItem item) {
items.put(slot, item);
inventory.setItem(slot, item.getItemStack()); <---- 74
}```
java.lang.ArrayIndexOutOfBoundsException: Index 54 out of bounds for length 54
you're trying to place an item in the 55th slot
I know, but I am not sure how to fix it with geol code
the item is being set in the tick method
and the code was made by geol
looking at it, my only suggestion is to rewrite it from 0
why? isn't that just an easy fix?
it looks like spaghetti
well I want to get it working in this state before thinking about that
when working with inventories it's usually a good idea to abstract the concept of index out of it, and work with columns and rows
Well I can't just rework the whole Inventory System, we have too many inventory that use that system
and the AnimatedInventory I just want to get it working first
make the animated item entry thing hold a target column and row
try adding at line 54 actualIndex--;
create an util method to calculate index from column and row
then instead of iterating with the index directly, modify the column or row each tick
doesn't require you to rework your entire inventory system or whatever, just this class
I made a mistake
It should be
if (actualIndex / 9 != e.index / 9) {
continue;
}
as far as I see, maybe use Math.floorDiv() just to be safe with this
Modulo is for getting the colum, but we want to compare the row ๐
got it lemme try
now I just get java.lang.ArrayIndexOutOfBoundsException: null
that is intersting. Still the same line?
sounds like the jvm is swallowing stack traces
make sure you have that jvm flag that prevents it from omitting them set
I guess try to manually insert a try-catch in there.
Though interesting nonetheless
I doubt he has that flag since he obtained a stacktrace before
java -Xms128M -Xmx3072M -jar server.jar I have no flags except xms and xmx
okay one moment
for "performance reasons" the jvm can arbitrarily start omitting the stack traces of exceptions that are thrown often
which means that he'd get it earlier but since it repeated x times, it now gets omitted
weird so even with a try catch its still not throwing the exception. and I have freshly restarted the server so there should be no other exceptions
there we go
at java.util.Arrays$ArrayList.set(Arrays.java:4356) ~[?:?]
at net.minecraft.server.v1_16_R3.NonNullList.set(SourceFile:53) ~[patched_1.16.4.jar:git-Paper-416]
at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryCustom$MinecraftInventory.setItem(CraftInventoryCustom.java:108) ~[patched_1.16.4.jar:git-Paper-416]
at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory.setItem(CraftInventory.java:99) ~[patched_1.16.4.jar:git-Paper-416]
at de.jaholl.core.inventory.ClickInventory.setItem(ClickInventory.java:74) ~[?:?]
at de.jaholl.core.inventory.AnimatableInventory.tick(AnimatableInventory.java:55) ~[?:?]
at de.jaholl.core.inventory.AnimatableInventory$1.run(AnimatableInventory.java:39) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:99) ~[patched_1.16.4.jar:git-Paper-416]
at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.16.4.jar:git-Paper-416]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.4.jar:git-Paper-416]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]```
so actualIndex is still to high
What spigot version are you running
1.16.4
This is paper?
yes
you clearly have no idea how stack traces work
me?
the guy who's saying it's paper because the exception was thrown in their domain
the exception was thrown in their domain because it was given an illegal argument
Couldnt read it

