#help-development
1 messages · Page 964 of 1
but I don't think I can get the blocks from taht
You def can
^
how though i wasn't able to find a list
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockFromToEvent.html hidden in the handlers?
What do the handlers even do
the problem being taht I cannot just call that and see what block was there previously
what
as far as I understand it I'd just get the block position maybnne
What
Do u need an overview of how the event system works
I mean I guess you can cancel it
The event is called before the change actually occurs
So from will be the water, to will be the redstone
Interesting question
Not !isSolid one can hope https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html#isSolid(), but tbh you probably need to just have a list of things u dont want it to flush into and flush away
declaration: package: org.bukkit, enum: Material
that's isn't particularly accuate though. You can place a block into grass, but not into redstone or a red tulip
and that is what isSolid differentiates between afaik
yeah, well material 😭
@EventHandler
public void onClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (!event.isShiftClick()) return;
ItemStack itemStack = event.getCurrentItem();
if (itemStack == null || itemStack.getType().isAir() || itemStack.getType() != Material.SHULKER_BOX) return;
if (!(itemStack.getItemMeta() instanceof BlockStateMeta)) return;
BlockStateMeta blockStateMeta = (BlockStateMeta) itemStack.getItemMeta();
BlockState blockState = blockStateMeta.getBlockState();
if (!(blockState instanceof ShulkerBox)) return;
ShulkerBox shulkerBox = (ShulkerBox) blockState;
player.openInventory(shulkerBox.getInventory());
}
i open a shulker inventory for player, but when players modify the inventory contents, it doesn't get saved. how can i fix that?
i have created my own raytracing method so i can also get air blocks, altough it seems like i can also get blocks inside the floor. is there some kind of rule i can set up so i get the exact air block at a max distance of for example 10, but it stops before going underground? this isnt possible right?
Once your ray trace hits a non air block, do whatever?
Hello, if two plugins send a resource pack respectively, are both downloaded?
?tryandsee
thanks i didnt thin of that
What version
on 1.20.4
Yes
okay thanks
I need to know that before making my plugin, so I can't try and see actually 🙂
You can apply as many server packs as you want now
okay perfect thanks
https://imgur.com/lYYO0Dp not terribly enlightening
Actually
If the event is being called for a block with water as the source
That means the block can be destroyed by water
in a string like this: 1,2,3,15 ...
how can i check if x value is in the string? i'm splitting it but if I use contains(1) for example, if the number is 15 will it return true as well?
Yes
grats
You’d have to split it at the comma and then parse each value into an integer
b.getType() != Material.AIR
yea, i'm doing that
but whan can i use instead of contains?
even if the number is 15 and i'm using contains(1)?
not in my scenario, but yes
for some reason, my config.yml + message.yml files aren't being included in the jar file
as a result, i am experiencing an error when the plugin is loaded.
onEnable
if (!getDataFolder().exists()) {
getLogger().info("Detected first time launch! Creating configuration files...");
getDataFolder().mkdir();
}
saveDefaultConfig();
saveResource("messages.yml", false);
FileConfiguration config = this.getConfig();
show project structure
tag mfnalex for maven help
Hello, how can I get an accurate blockLight and skyLight for a block? I want an ItemDisplay not to be too bright in night
@tender shard send help
(sorry for ping lol)
Block should have methods for that
yeah but it's always bright, even in night
You probably have to update it constantly as time changes
humm
I'll try then thanks
but as long as I remember, I think that it was always bright, even when updating
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
lol
I like this humor
germans be like that
lol
i just want to fix my plugin 😭 😭
snails
slug
NAH
wine 🍷
(Alcohol consumption is dangerous for your health. Drink in moderation.)
tell that to oliver
he likes his vodka
he's russian?
that's a weird thing to like as the first thing
tell me a "good first thing" then
(only wrong answer accepted)
Bruh, they usually go for some sugary drink
icl this is the craziest dev talk ever
the chats aren't so closely moderated that they go full nazi on us.
You should probably repeat ur question though
Idk, they usually start with breezers as a soft drink, or "små sure" as a liquor here
San pelegrino?
any idea how to check if a water block is a source block? Casting the water blockdata to Levelled and then reading its level doesn't seem to work.
hey, you should use vodka instead
I wish
how woudl you run something while the server is running
https://www.spigotmc.org/threads/how-to-detect-if-water-lava-is-a-source-block-or-flowing-in-1-17.519739/
everyone suggests this, but when I do (e.getBlockReplacedState().getType() == Material.WATER && ((Levelled) e.getBlock().getBlockData()).getLevel() == 0) I get
.CraftBlockData cannot be cast to class org.bukkit.block.data.Levelled (org.bukkit.craftbukkit.v1_20_R1.block.data.CraftBlockData and org.bukkit.block.data.Levelled are in unnamed module of loader java.net.URLClassLoader @7aec35a)
You're casting a different block to the one you check
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("Mooooo!");
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);
id put this in on enable right
Replaced v getBlock
Sure
oh shit
ticks
20 ticks to a second by default
thank you so much. I think I'm getting too tired
that was indeed the problem
hi is there someone who can help me
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Oi knock it off
ask the question normally
It just means to ask ur question and someone will see it and think "Oh hey i can answer that shiz" and then answer it.
?h
packets aren't received sync.
how to fix creeper immediately explodes ? i’ve been dealing with the creeper bug it explodes immediately
Switch thread if u want to process something sync @inner mulch
Version?
so nothing i can do against the 1 tick delay from bukkitrunnable?
Again. U remember what i said earlier @inner mulch
its from aternos crossplay server
java - 1.20.4
bedrock - 1.20.73
@waxen widget Are you developing?
wait, you can't use contains with integers xd
nope
No but you can with a set of integers
oh
not what he meant
I would direct you to the less active #help-server for server issues then. Dev does know some server stuff, but #help-server is the correct place to ask.
okie thank youu
anyone have any tips with integrating webserver with mc plugin
Dont do it on the main thread
right now i just have a webserver running on localhost:8080 and im telling it how many players are online
explain>
Start a new thread for your webserver. And dont call methods from the game from this thread. Use the BukkitScheduler for that.
Run it on someone else’s main thread
Exactly
What should my order of trying to find an extern solution be when (I think) something is impossible using only the methods provided by spigot?
Between NMS, Paper and importing a library/api from https://www.spigotmc.org/ (or maybe even something else).
On top of that, should try my best to avoid any of these and why?
Well
If you use NMS you will likely need to update the plugin every version
If you use paper api it won’t run on spigot
And if you use a third party library you rely on it being updated when needed
what does this mean? right now I can use spigot and paper methods together in my intellij I think cause I added the paper library
Start with what you are trying to do
I'm trying to get control over a livingentity's pathfinding
I am so confused, what is a spigot server. I'm using localhost rn
yeah I my plugins turn into jar files, but they don't communicate with spigot servers somewhere on the internet right?
No
The server itself
That you are playing on
Is running spigot
(Or paper or some other fork)
does that mean if I use paper and spigot api it will run somewhere between, not on spigot and not on paper? or will it run on paper cause paper instanceof spigot
ah
Though if u use only spigot function with paper-api u can use it on spigot.
U have no way to know though
I just followed a tutorial on day 1, I think my server is paper cause I named it something with paper in it xd but I use like 90% spigot methods
but I guess it doesn't matter
is tehre an easy way to check if .addItem will fail because the inventory is full?
check the return
it's just a hashmap though
And it contains all items that didnt fit
Though it's kinda weird being ItemStack and amount when the amount is already in the itemstack so be careful
It’s not
It’s itemstack and index in the initial array
The returned HashMap contains what it couldn't store, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all items are stored, it will return an empty HashMap.
oh thank god
I was getting annoyed by me assumptions everytime i used it and didn't read the javadoc lel
Cast state to powerable iirc
It’s part of data not state
yeh
Close enough
Coll new pr, deprecate block data and state and merge it into block info
how can i stop flowers from being destroyed by water?
or torches
anything thats destroyed by water
BlockPhysicsEvent maybe?
BlockFromToEvent
i will try it out
cant be cancelled
or that
okay wait
Help this guy out
no, you help this guy out
Too lazy
same
flower got destroyed :(
U did it wrong then
.
no
Yes lol
did he cancel the event fully?
in this case the flower doesnt break cuz the water doesnt flow
not cuz the flower is immune
He did not
Hi
He cancelled it when it was flowing towards the flower
It is
Unless u mean playerbucketemptyevent too
It’s not flowing to that exact block
But all the other blocks
ok
damn you're still active 🤣
Codevision c;
💪🏻
Would it be possible to make an ender chests be shared with everyone on the server?
Like instead of everyone having their own ender chest details, it only uses one?
The purpose would be to utilize the connection function of ender chests without using unique contents
sure. listen to InventoryOpenEvent (& check if the opened inv is an enderchest), cancel it, then use player.openInventory(yourCustomInventory)
Oh, that's an interesting way to do it
you might have to delay opening the new inv by one tick (not sure)
I was thinking of arbitrarily assigning someone's ender chest data as the "universal" ender chest
And then everyone just references that
Not sure if that's possible though
I'm not super experiences with developing plugins
sure, that'd also work. probably you could use a "fake player" for that, e.g. create a GameProfile for a random UUID and then re-use that profile every time again
This would be better
although I think that it's not possible to get an offline player's enderchest
so yeah it'd be easier to recreate the inventory yourself, then save it in a YAML file / database / whatever
Why would that be? Isn't it just in the player data?
Lemme find it one sec
yeah but if you create a "fake player" as owner for the enderchest, you'll only be able to obtain an OfflinePlayer instance of them. And I'm like 99% sure that getEnderChest() is only available for Player (online player) objects
so imho you're better off by doing sth like this:
- Save/load the ender inventory to a yaml file on startup
- Whenever someone opens their enderchest (InventoryOpenEvent), cancel that event and show a custom inventory that's filled with the custom items
- InventoryCloseEvent -> save it again
You don't wanna do that, it'd require NMS and then your plugin would probably break on most major updates
as in the fake player idea in general?
?xy
TL;DR: you can't
you'll have to check all tohse things manually
what's your actual goal?
Also, remind me. NMS is essentially minecraft's actual code whereas spigot is just interferring with events?
like, once per server?
and when the item disappears (e.g. used up, or burnt up in lava, etc) it's craftable again?
okay I see. it's not THAT complicated. I would do it like this:
When the item is craftef, set a boolean to true (save that in a config or whatever)
Then you gotta listen ONLY to two events:
- ItemDamageEvent (or EntityDamageEvent?) not sure how it's called. check if the damaged entity is instanceof Item, if so you can get the ItemStack, and check if it's your custom item. If yes -> set the boolean to false again
- The event that's called when a "usable item" (e.g. pickaxe) gets damaged. Then check if new durability is 0, if yes -> same as above, set the boolean to false again
And then ofc only make the item craftable if your custom boolean is true
that's the best solution I could think of. Not sure if there's any better way, but I doubt it
hmmm good question, I haven't thought about that. But I think there's an event for that too
yeah my way is usually to just "get the job done" and then later, listen to players complaining, then you can always improve it haha. unfortunately, I don't know any better way
np!
alternatively... you could ofc loop over all online player's inventories, loop over all items laying on the ground (World#getEntities) and also loop over all chests etc (loop over all loaded chunks, then nested loop for all Chunk's getTileEntities() -> instanceof Container -> getInventory) but that'd 1. be a fucking burden and 2. wouldn't allow you to detect if a offline player has that item in their inv
TL;DR: this is a bad approach. What I said earlier is much easier and more reliable
Anyone have a good resource for how to manage static variables in subclasses?
I have a bunch of subclasses all with different 'names', like "dirt", "fart", "sandpaper", all inheriting from the same class which has a single 'name' variable, and when I initialize the subclass, I would like all of those things to be static.
there's a 99% chance that whatever it is you're doing you shouldn't be doing it that way
Is it possible to save chunks as a Base64 string like you can items? or something like that I want to be able to load the same chunk in other servers
yeah well
want me to explain in detail
and you can tell me what to do?
😛
yes, ofc. but why would you?
why would I save chunks?
exactly, why would you? the server already does that for you
and a fucking pain, if one assumes that it doesn't only have to store each block type, but also tile entities and all their data
I want to create things in chunks on my development server and load them back from my main one
use schematics
WorldEdit API
Yes but at least they aren’t a huge string
remember: a chunk isn't only a bunch of blocks, but also information about entities and tile entities (chest contents, etc)
they are actually
maybe, but who cares if WorldEdit handles that for you?
there isn't going to be chests or entites
Well no
just blocks
They are binary data
and signs ig
it doesn't do the part that I need it to do
bruh
so I have to deal with it as a massive string regardless
signs are TileEntities
ik
i suppose ill just do so anyway
also doesn't minecraft/spigot have a builtin way for "structures" now?
Why not use that
yeah
I have an effect class, 'Effect' which looks like:
public abstract class Effect implements GeneralEffect {
//GeneralEffect is just an interface with an all-purpose 'use' command
public static String name; //name of the effect in the code
public static Component title; //title of the effect for a menu system
public static List<Component> description; //description of the effect for a menu system
public static Material typeBut; //material used for the menu
public static List<Parameter> parameterList; //a list of parameter types and limits for various parameters which can be given to the effect to modify it (e.g. make it bigger, change its color, etc.)
}
I then have a number of effects which all inherit this class, and when initialized, go through and do like
name = "fart"
title = component.text("Fart Blast");
etc.
In each effect I also have a number of nonstatic variables which are used to hold that specific effect instance's parameters, whatever the player has them set to when they run the command/use the item/etc that triggers the effect.
just wondering if that is good data structures or not
No
yah so what should i change it to you think
Why do you need any of the static stuff
because a player can also open a menu for all the effects and i'd prefer this junk be in one place
its also used for range checking
like e.g. you tried to create a fart blast of range 21 when it needs to be 20 or less
do you mean why specifically it should be static?
that's just
me wondering
if that helps with speed
this is a sentence i never thought i would read
you mean have a static class for each effect
and then a separate class
for the variables?
No
Just a class
That holds all the data about the effect
Each instance is a different effect
If certain effects need a bit more to them, make child classes
so basically you mean don't bother with the static stuff?
and just have like a hashmap of strings => effects
But none of the effects need to be static
in the main plugin class
hm
@young knoll what about if two players use the same effect and have input different variables, and the effect uses a bukkitrunnable which is using the variables for the effect class in the registry
wouldn't the first player's bukkitrunnable start generating as if it was using the second player's variables
Make an effect instance class
That’s how minecraft works, there’s EffectType and then the actual effect
EffectType has all the fixed data about an effect, like the particle color or max level
And then the instance has the duration and whatnot
if I have agradle dependency do i have to specify it elsewhere?
I am working on a custom Auction Plugin and trying to create a live countdown on the item... I tried creating a timer which every second updates the items lore but it is not updating within the inventory..
ItemMeta meta = displayItem.getItemMeta();
List<String> lore = meta.getLore();
String expireLore = ChatColor.translateAlternateColorCodes('&',
"&7Expires:&b " + DateUtils.getSimpleStringDifference(expires));
lore.set(expiresLineIndex,
expireLore);
meta.setLore(lore);
displayItem.setItemMeta(meta);
}```
The item in the inventory will likely be a clone
You need to get a direct reference to it from said inventory
anyone here familliar with jetty?
I don't think I did... It gets saved to a list
public static void setup() {
auctions = getValidAuctionItemsWithin24Hours();
beginTimer();
}
private static void beginTimer(){
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
auctions.forEach((id, auctionItem) -> auctionItem.update());
}
};
runnable.runTaskTimer(Factions.getPlugin(), 20, 20);
}
public static HashMap<Integer, AuctionItem> getAuctions(){
return auctions;
}```
and when putting into the inventory
```ItemStack displayItem = AuctionManager.getAuctions().get(itemID).getDisplayItem();
inv.setItem(slot, displayItem);```
That is not cloning it right
It is
Ah how so
Pretty sure setItem is going to clone your item into a minecraft one
im implementing a dependency and when I run the plugin its throwing a classnotfound exception
What is a way to resolve the issue then
Shade it
shade?
Yes
?shading
Darn
You need to add the dependency to your jar
Either via maven shade plugin or shadowJar for gradle
dependencies {
implementation 'org.eclipse.jetty:jetty-server:11.0.7'
implementation 'javax.servlet:javax.servlet-api:4.0.1'
compileOnly "org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT"
} so ur saying this isnt enough
nope
Include that
do I have to do implementation"com.github..."
?
oh i see
You already have it set to implementation
wrong channel?
how would I put an items name into chat
like not the display name but the actualy name
add a toString method
that shows the internal name
I tried .getLocalizedName but it didn't show anything
I tried getTranslationKey but its just the key
idk how to translate it
custom item?
just a regular item
o
whatever the name is translated to for the player
you can use components
elaborate please
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
you can use a translatable component with a key of #getTranslationKey
ty!
np!
how would you do custom durability?
PDC and the item damage event
so youd have to track it and then set the damage to the correct percent?
Yeah
ty!
Figuring out how to correctly have every player have a recovery compass on joining the server in their ninth hot bar slot without having any inventory bugs, any ideas?
I’ve tried using inventory event listeners but they just delete and re create items
I’m looking for more of restriction
event listeners are the only way to do it
if its buggy you arent doing it correctly
Yea thought so, prob just doing on click incorrectly
Anywhere here experienced with sending chunk update packets to client ?
Any know of any resources for it. I can get code to work perfectly no errors but dosent actually do anything client end
?chunkupdate
@drowsy helm event.setCancelled(true)?
can you like
add ui using itemdisplays and text displays
can you parent them to the players head
yes, but good luck with the math
slay
also uhm
how would you make an entity only visible to a certain player
is that annoying d o u have to delve into packets
Are you able to convert offline players to online players?
Trying to open an ender chest of an offline player
use it
there is no replacement at this time
why would u deprecate something without a replacement :|
do you understand what an API is?
I assume its the thing im using
yes, Spigot/Bukkit
Im just confused why they depricate it before replacing it
so the deprecation message says this element may change in the future
mmm
so use with caution
its just an advisory
I guess its just weird when intellj expects depricate to mean "dont use this"
in Spigot if a deprecation doesn't tell you to use a replacement, you continue to use that method.
alr ty
how do display animations work ive never understood
like
if I wanted a text display to shrink to 0 over its lifespan
I set the transformation but it just is automatically that
even if I set the interpolation to 20
which interpolation?
theres two settings for interpolation
delay and duration
delay = how long (in ticks) before the interpolation begins.
duration = how many ticks it will take to perform the interpolation
20 ticks = 1 second
I set the duration to 20
the delay to -1
it just shows up as the transformation I set it to when I spawn it which makes sense
but how would I have it start at scale 1,1,1 and then move to 0,0,0
how long do you want it to take to go from one state to the final one?
1 second
rather fast
however, ok.
if you set teh delay to 0 and duration to 20
so long as your Transformation is correct, it will take 1 second to go from its original state to teh transformed state
doesn't work
Then your transformation is wrong
it just starts at the transformation
TextDisplay display = event.getPlayer().getWorld().spawn(event.getBlock().getLocation().add(0.5,0.5,0.5), TextDisplay.class);
display.setText(ChatColor.GRAY + "Tool xp: " + ChatColor.GREEN + "+" + xp);
display.setBackgroundColor(Color.fromARGB(0,0,0,0));
display.setVisibleByDefault(false);
display.setBillboard(Display.Billboard.CENTER);
display.setInterpolationDuration(20);
display.setInterpolationDelay(0);
var transformation = new Transformation(new Vector3f(0,0,0),new AxisAngle4f(0,0,1,0),new Vector3f(0.5f,0.5f,0.5f),new AxisAngle4f(0,0,1,0));
display.setTransformation(transformation);
display.setSeeThrough(true);
event.getPlayer().showEntity(Main.instance,display);``` im doing 0.5,0.5,0.5 for testing so I can see that it is in fact there
?paste your code for spawning thsi display
it makes sense to me why this wouldn't work
bc its setting the initial transformation
i just dk how i would set the NEXT transformation
first, use teh spawn method that takes a Consumer, so you can set all the vaules before it spawns.
then what
because im already setting the values before it spawns
will it just work if its already set to something
you are not
I mostly just dont get how this whole thing works
you are spawning it, then setting values
to every player but the one I want
and you then show it to one player
im confused
yes, you are currently flashing it up for everyone, then hiding it and showing it to one player
use the Consumer method
how do I get it to animate
then extend your duration to longer than one second and see if it makes any difference
if it doesn;t your transformation is wrong
wrong how
I've not played with transformations so I can;t help you there
Looking for information on client based chunks
Yeah
anybody know if theres a way to make this more stable?
and basically just be an icon on the screen
Data pack maybe?
im assuming its probably not very possible but if there are fixes for any of the issues (view bobbing, rotation weirdness, shading) then lmk
how would that help
don;t use the eye location
its a passenger to the player basically
bc Im assuming anything else would cause desync from the server
I assumed you were displaying it based on eye location
no idk how id do that
if its a passenger it will move as the player moves
and I assume it would be even less smooth
sigh I thought this would be cool
and actually allow you to have custom ui
That… is… cursed.
right
Scary scary
Eh I mean you just have to be as efficient as possible
(Obviously)
But it’s been made and quite smooth at that
really
Ya know the rideable pearls?
so its possible?
Like a fun toy in hubs of servers
https://www.curseforge.com/minecraft/mc-mods/spice-of-life-valheim-edition im trying to recreate this basically
Yes it’s been done before for sure, rideable entities aren’t exactly new but a bit more difficult tbf
so i want some sort of menu to tell you what food is in your slots
worst case its just in the chat
but it would be cool to do it like thr mod
how does it work
Wait are you trying to make like those icons at the bottom right?
Ohhh I thought you were talking about a concept such as you throw a pearl but when thrown the player is riding it
Hmmm I wonder if you could manipulate display entities in a way to get those kinds icons
I’m sure Elgar knows more than I do
I think someone told me something about having an armourstand riding the players and the armorstand has a translation downwards and a bit infront of the player. Then just put something on the head of the armorstand. That will all be clientsided then and perfect
ah @eternal oxide already said something about a passanger, whoops, didn't read that far. Sorry
im already doing a passenger
hm
how can i create an config file`?
public static FileConfiguration config; config = getConfig(); i have this and its not creating one
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
Anyone here familiar with nms? And sending chunk packets to players
If I need an event to manage a lot of things and it is bugging a bit if I do it all in one method.
Should I still do it there or créate another method or class?
wdym bugging, just create some methods so it looks clean
What is the problem with the command?
https://paste.md-5.net/cepesiwudi.java Command file
https://paste.md-5.net/tovexofequ.bash error message
Wdym?
there may not be any args, ensure args.length > 0
Where?
line 26, learn to read stacktraces
Yea better
how do i make an effect similar to the vanilla "can break" without the ugly lore showing on the pickaxe
havent played mc in a while but whats that effect?
basically lets you mine certain blocks only
the rest makes it look like you're in adventure mode
uhh dunno never heard of
set ItemFlag.HIDE_DESTROYS on the item flags
np
was looking for it in the docs but couldnt find it..
I just have intelli open lol
so uh im gonna make a custom mining system but before i get surprised is that possible with spigot without nms? custom mining is basically modifying how fast you break blocks
hm, has no one ever created a gui to manipulate resource packs?
You don't need nms for that I believe
for older versions you do, what can you do to do it without nms in spigot now?
There's an event, don't remember the name that lets you manage that
BlockDamageEvent
Yea that
what about showing block damage
You need a packet iirc
so nms
i don't think using a whole lib for 1 packet is very efficient
I mean I can't really talk here, I still went ahead and did it myself
it's a stand-alone plugin, a lot of plugins use it so ¯_(ツ)_/¯
but in fairness protocol lib wasn't updating to the latest mc version so
Oh that's new
that's my excuse
Yep, then you can use that @dawn flower
np
quick question, if i cancel BlockDamageEvent does it cancel the breaking animation or do i have to use mining fatigue for that
mining fatigue
mining fatigue
ok
what's a good way to make an addon system for a paid plugin without giving people a free copy of the plugin
Write an api, which doesnt include your plugin ofc
Hello, is there a quick way to get every blocks with a certain PDC in all worlds without too many resource consuming? Or should I use a List stored in a file on server disable?
Not all chunks are loaded all the time, so it would be impossible to check all PDCs
okay, so I should use a List
LinkedList or List?
why do you need to list them all?
I want to make a custom block with an ItemDisplay
doesn't explain why you feel you need to keep track of them
to avoid checking if there a block with this PDC on every PlayerMoveEvent
to make the ItemDisplay appear with ProtocolLib
why use PL to make them display?
because next I'll use this code for other plugins, and there will be many custom blocks
so to avoid lag
thats not going to reduce lag
for server?
you are already spawning them so they exist
yeah, actually, but I want to replace this spawning by a packet
but this is not the subject
then all you need to keep track of is where the displays are
no 😭
not for after
because when It'll be with packet I can't track a thing that doesn't exist
of course you can;t
(I think)
If you are replacing these to be packet based, they only exist in your code and on the client
yeah
so Your code needs to keep track of every details
so No PDC
they literally do not exist on the server if you are going packet based
there is no PDC, it will not exist as the entity does not exist
to identify the base block and make the ItemDisplay appear to cover him
check my code https://paste.md-5.net/ukuzumower.java
I saw teh code
I don't want the block to be passed through
no...
you want a solid ItemDisplay?
yeah !
not the ItemDisplay being solid
but the ItemDisplay cover a block which is solid
and I make the ItemDisplay disappear when the block is broke
thats the same thing
technically, the ItemDisplay is not solid
what is the block?
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Thats from alex ^^
ah alex
😭
.
the link...
yes, pointless
no need to store all that
just read teh PDC on teh block when you need it
but how can I identify the block?
its PDC
but I will not loop for all blocks?
The blockpdc system is suitable for a few random blocks within a chunk.
Storing bigger masses of data should be done in a different way to prevent the chunk file from exploding in size.
yeah
What are you trying to do?
when the block covered is placed and when the block covered is broke
a custom block, basically a block covered by an ItemDisplay
then only when a specific block is placed/broken and at chunk load/unload
okay thanks
That can be used for general building?
then blockpdc
Ah then blockpdc is perfect
as I already saiud
okay thanks a new time x)
monitor block place/break and chunk load/unload
I'm a bit lazy with english today x)
okay perfect thanks 😄
Btw i would load your data from the PDC into memory when the chunk is loaded. And den dont use it until its unloaded again.
Checks on a Map are faster than creating a new BlockPDC to see if it exists on a location.
humm
simple Map? Or LinkedHashMap?
https://paste.md-5.net/zurazirubo.pl
public void call(Event event, Player player, int level) {
if (!callConditions(event, player)) {
return;
}
if (!playerVariables.containsKey(player.getUniqueId())) {
playerVariables.put(player.getUniqueId(), new HashMap<>());
}
if (actions.containsKey(level)) {
Map<String, String> variables = new HashMap<>();
for (String action : actions.get(level)) {
try {
if (!evaluateAction(event, player, action, variables)) {
break;
}
} catch (Exception ex) {
player.sendMessage(ChatColor.RED + "An unexpected error has occurred: " + ex.getMessage());
break;
}
}
}
}```
this is the line that's throwing the exception for (String action : actions.get(level)) {
cough
You didn;t post any error
Sounds like gson to me
i aint using gson
LinkedHashMap o_o
What is the problem with the command?
https://paste.md-5.net/cepesiwudi.java Command file
https://paste.md-5.net/tovexofequ.bash error message
Anyways your actions map has a linkedhashmap instead of a string on its value
how can i get all visitor access?
You're checking the argument before checking the size
What do I change?

it's supposed to be that, no?
Learn to read a stacktrace and figure it out yourself
Cant you help me pls
You're looping over strings yet your object is a hashmap
I don't think that's intentional
HashMap has a key and value, your for loop for a string can;t be performed on a map
I'm here to give help, not code for you
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
ok now im confused, im never casting actions to string, i'm casting it to string list
When you loop over .values it casts
But what I am suposed to fix?
.
The stacktrace contains the exact line your problem's at
Cant you tell me pls
brother
.
Brother I'm not gonna spoon feed you your answers
You won't end up developing any critical thinking or problem solving skills with this approach
Size of what
If you want me to code it for you, it's a service not help
There Is usually a Caused by: at the bottom of an Error Message, this allows you to identify the problem, in your case, theres an Index out of Bounds exception
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at com.tekocraft.tekocore.commands.MainCommand.onCommand(MainCommand.java:26) ~[TekoCore.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
... 9 more
And index out of bounds occurs, when you're trying to access something in a array thats not there
(when you're trying to access an element at an index beyond the array's size)
Is it possible that the error is in line 26?
Yes
bruh still same error
Maybe
Thats whats creating the error
!verify yongjun5835
This account is already verified!
i told you it was at line 26
you have to check if the size of the list before trying to get element x of the list
Yes
of array or whatever
i also told you how to fix it
No
a size starts at 1 and the index starts at 0 btw
i did
if (args[0].equalsIgnoreCase("reload")) {
subcommandReload(sender);
return true;
}
Instead of doing that
before that
check that args.length > 0
add if (args.length >= 1)
The reload command works, the item one doesn't
?
on top of your command do
if (args.length < 1) {
return false;
}```
actually return true if you dont want that stupid permission message to be printed
Just love AIkar for his framework xD
regarding my error, do i do
for (Object action : actions.get(level)) instead of String action?
Got the trace?
I put args.lenght > 0 && args[0].equalsIgnoreCase("reload"); And it works now
Is it repaired or it will bug?
minestom people were hating on acf this morning
repaired
Why
oh my god
i just found out why, i'm using yaml for custom "coding" and forgot to put ""
tysm
dunno they said cloud was better, and that you couldnt do things like user <name> set parent <parent> in acf, instead only user set parent <name> <parent>
I mean it is true
But i like the simplicity of ACF
never used anything else than acf, either used the builtin stuff or wrote a framework myself, which sucked
I understand that shit like this can look scary at first glance but still
Yea, havent used anything else since i foudn acf
hehe
not the prettiest kotlin code i gotta agree
I just dont like kotlin it weird..
fr
i mean u can use it just like java
Cast may be removed by changing the type of 'action' to 'String' how do i suppress this
by changing it to string
but then i cant add this
if (!(action instanceof String)) {
TurboEnchants.logger().warning("Failed to parse enchant '" + this.getName() + "'. Please make sure your actions are surrounded by \".");
return;
}```
and if they accidently not add " it just throws abunch of exceptions
where even does action come from
a yaml config
myenchant:
event: "player-damage-entity"
conditions:
- "!is-sneaking"
actions:
1:
- "send-message hello"```
i dont even know what happens when calling config.getString and its not a string
It might just cast to a string
prob just calls toString if it's primitive
alr
i'll just do String.valueOf
yeep that supressed it
how do i get the damage cause from a damage event
found it
might want to read docs
how do i get the death cause from a death event
im srs
this might be not coding related but how do i make this regex '(%.*?%)|([^ ]+)' only have 1 match in a situation like this %hello %percent2%% and not 2 matches
I'd recommend you make a parser instead of regex
Get the number of %'s and start matching
alr
is there an event or a method that I can override that gets executed right after a server reload finishes?
oh well thanks!
Incorrect
I guess I'll not
If that were the case they wouldve had one event@
bro
when you reload all plugins reload
and onEnable is called when the plugin is reloaded
does seem to be the case according to the logs
ServerLoadEvent > OnLoad > OnEnable
onEnable works fine for my use case then
is there a hook for blocks that break when they have no block they're sitting on? It's for some reason not in BlockBreakEvent, and the BlockPhysicsEvent is not useful since I then run into the dilemma of finding out which blocks would be affected, again
Edit: Shiddy solution, but works:
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onBlockNoSupport(BlockPhysicsEvent e) {
if (!e.getBlock().getBlockData().isSupported(e.getBlock().getLocation())) {
onBlockBreak(new BlockBreakEvent(e.getBlock(), posFindOwner(e.getBlock().getLocation()).getPlayer()));
}
}
you register the listener in onEnable
so onEnable is called before ServerLoadEvent
org.sqlite takes too much space in jar, I'm using maven. To be exact, the package "org.sqlite.native" takes the most
file size?
what's this theme
Spigot already provides SQLite
You don't need to include it
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.45.2.0</version>
</dependency>
i use that
add <scope>provided</scope>
thats github 💀
where do i download it
intellij uses a trash theme tbf
go ask microsoft
Works for spigot, but then breaks for bungee
no, you tell me
even with their new "clean" ui it still looks trash, too much junk in the way
default github dark ig
what about bungeecord?
does .subtract or similar on BlockVector3s do the same as on locations where they get modified instead of just returning the result of the maths operation?
there doesn't seem to be a clone method
iirc yes I do think they get mutated internally
ugh
java.lang.NoSuchMethodError: 'net.minecraft.server.level.ServerPlayer org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer.getHandle()'
at me.fe4thers.mcs.TabList.onPlayerJoin(TabList.java:281) ~[MCS-1.0.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor73.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:git-Purpur-2169]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[purpur-1.20.4.jar:git-Purpur-2169]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[purpur-1.20.4.jar:git-Purpur-2169]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:617) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:345) ~[purpur-1.20.4.jar:git-Purpur-2169]
at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.handleConfigurationFinished(ServerConfigurationPacketListenerImpl.java:134) ~[purpur-1.20.4.jar:git-Purpur-2169]
at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:18) ~[purpur-1.20.4.jar:git-Purpur-2169]
Hi im trying to make a tablist but then without the players with their playernames and head and stuff, but Im getting this error.
pom:
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
code:
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
UpdateTabList();
List<UUID> uuidList = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()){
uuidList.add(player.getUniqueId());
}
ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(uuidList);
for (Player player : Bukkit.getOnlinePlayers()) {
((CraftPlayer) player).getHandle().connection.send(packet);
}
}
help would be appreciated cus I have been stuck on this for 12 hours :(
Are you reobfuscating with specialsource
that will hide the players in game aswel
you can hide 1 player for 1 player
Paper has methods to hide players from the tablist
player.hidePlayer(playerToHide)
?paste
please
Player#unlistPlayer(org.bukkit.entity.Player)
unlistplayer gives a boolean
Sure, whats the problem with that
?whereami
anyone knows why this is throwing this error? Worked in the past i dont think i changed anything..
File directory = new File(Main.getPlugin().getDataFolder(), "/plots");
if (!directory.exists()) {
directory.mkdir();
}
for (File file : directory.listFiles()) {
final PlotData data = (PlotData) new PluginJsonWriter().getDataFromFile(file, PlotData.class);
plotData.putIfAbsent(data.getId(), data);
}
java.lang.NullPointerException: Cannot read the array length because "<local2>" is null
at com.itzjustnico.plertanixplot.plots.PlotHandler.<init>(PlotHandler.java:42) ~[?:?]
at com.itzjustnico.plertanixplot.main.Main.onEnable(Main.java:30) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.enablePlugin(CraftServer.java:536) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.enablePlugins(CraftServer.java:450) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.reload(CraftServer.java:935) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at org.bukkit.Bukkit.reload(Bukkit.java:802) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchCommand(CraftServer.java:844) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchServerCommand(CraftServer.java:829) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at net.minecraft.server.dedicated.DedicatedServer.bh(DedicatedServer.java:413) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:389) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1200) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1017) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3753-Spigot-7d7b241-b346a5f]
at java.lang.Thread.run(Thread.java:833) ~[?:?] ```
cus I think I need to remove the player from the tablist and not get a boolean to look if they are off it
- Remove the
/from your File - Never use the reload command and send a stacktrace from that
/reload is not supported, and it even tells you that when you execute it - Use a paste website for big codeblocks
?paste
This method removes a player from the tablist
okay ill try it im probably stupid
Like the javadocs state.
For paper specific questions pls visit papers discord.
okay thank you, still the same error tho, also I used it exactly like that in a different plugin where it still works...
Show your code and the exception pls
it works thx im just stupid :D
Why doesn't InventoryClickEvent work in the player's inventory?
@EventHandler
public void swap(InventoryClickEvent event){
if(event.getAction() != InventoryAction.SWAP_WITH_CURSOR && event.getAction() != InventoryAction.HOTBAR_SWAP) return;
ItemStack cursor = event.getCursor();
ItemStack current = event.getCurrentItem();
if(current == null) return;
if(!current.hasItemMeta()) return;
if(!current.getItemMeta().getPersistentDataContainer().has(MoreBullets.WEAPON_TYPE)) return;
if(cursor.hasItemMeta()) return;
event.setCancelled(true);
}
``` it works in chest, but it doesn't work in playerInventory
code where the error occures: https://gist.github.com/ItzJustNico/e32fee17f4632efcd2cb7d896343ebbc
error: https://gist.github.com/ItzJustNico/548919d8dad3160159af26a4f1126d1c
thats how I call the shophandler: ShopHandler shopHandler = new ShopHandler();
- Remove the '/' from your filename
- Check if
listFiles()returns null. (because it will when there are no files to list)
Btw this File constructor wont create a directory
why
For a folder you should just use new File(Main.getPlugin().getDataFolder() + "/plots")
or use nio
Smh use the 2 param constructor
how do I check if there is already a folder named like this
File#exists
And append a '/'
Meh, also possible
You don’t need to append anything
You can just do new File(getDataFolder(), “plots”)
If you dont append anything then it is resolved as a file
Or you call mkdir on it
mkDirs works fine
It wont create a "plots" folder, will it?