#help-development
1 messages · Page 535 of 1
I hope you programmed this
How do I get values from a list using YamlConfiguration?
my favorite part is the memory leaks
getList?
How would i go about creating the particles in the video? like making them go up and down and up again?
public static List<Location> getHollowCube(final Location corner1, final Location corner2) {
final List<Location> result = new ArrayList<Location>();
final World world = corner1.getWorld();
final double minX = Math.min(corner1.getX(), corner2.getX());
final double minY = Math.min(corner1.getY(), corner2.getY());
final double minZ = Math.min(corner1.getZ(), corner2.getZ());
final double maxX = Math.max(corner1.getX(), corner2.getX());
final double maxZ = Math.max(corner1.getZ(), corner2.getZ());
for (double x = minX; x <= maxX; x += 0.1) {
result.add(new Location(world, x, minY, minZ));
result.add(new Location(world, x, minY, maxZ));
}
for (double z = minZ; z <= maxZ; z += 0.1) {
result.add(new Location(world, minX, minY, z));
result.add(new Location(world, maxX, minY, z));
}
return result;
}```
```java
for (final Location location : GenUtils.getHollowCube(genBlock.getLocation().clone().add(-0.1, 0, -0.1), genBlock.getLocation().clone().add(1.1, 1.1, 1.1))) {
genBlock.getWorld().spawnParticle(Particle.REDSTONE, location, 2, (Object) new Particle.DustOptions(Color.PURPLE, 1.0f));
}
for (final Location location : GenUtils.getHollowCube(genBlock.getLocation().clone().add(-0.1, 1, -0.1), genBlock.getLocation().clone().add(1.1, 1.1 + 1, 1.1))) {
genBlock.getWorld().spawnParticle(Particle.REDSTONE, location, 2, (Object) new Particle.DustOptions(Color.PURPLE, 1.0f));
}```
https://media.discordapp.net/attachments/1103643978194231326/1103777982423781567/gen_upgrgadgess_4.mp4
I tried this, filter GUI blank for(String material : this.data.getStringList(section+".Filters.WhiteList")) { hopper.getWhiteList().add(Material.getMaterial(material)); } for(String material : this.data.getStringList(section+".Filters.BlackList")) { hopper.getBlackList().add(Material.getMaterial(material)); } for(String material : this.data.getStringList(section+".Filters.VoidList")) { hopper.getVoidList().add(Material.getMaterial(material)); }
Looking at the video, you have a decent start
public void gui(InventoryClickEvent e, InventoryView r) {
if(r.getItem(0).getItemMeta().getDisplayName().equalsIgnoreCase("test")) {
e.setCancelled(true);
}
}``` How would I get this code to work?
Over the frames, the animation just seems to play with the Y levels a bit so we can do some funky stuff
Let's say the animation is 50 ticks long and consists of going down and back up
That's 25 ticks going down, 25 ticks going up
Show your config and what section is
Those 25 ticks travel 0.5 blocks down so you can calculate the increment per tick
Something like
You can't have more than one event per event handler method
what property is that?
Just looking at the video
cuz rn the particles just rise up
how would i do it?, would it be an if statement in the main java file
basically you want to run a scheduler to display your animation
Let me recreate it here real quick
ty
Remove InventoryView from the method params
then my code wont work
Yeah
this
would this work? ```public class listnerGetGui implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
InventoryView inventoryView = event.getView();
if (inventoryView.getTitle().equalsIgnoreCase("test")) {
event.setCancelled(true);
}
}
}
It does!
Wait, you still there @chrome beacon ?
I feel really stupid asking this but is there a simple way to load all files from a folder inside my plugins resource folder?
I can't tell if your hollow cube method is weird or if my math is weird
its more like a hollow square
I know
one for the top, one for the bottom
but I've done something quick and dirty here and it's too spaced out
and my inputs seem fine
oh, so you're basically manually decreasing and increasing the y pos
over 50 ticks
can u send the FramedEffect class too
I lost the link to the spigot api documentation for 1.8.8
why does this this not open the gui ItemStack close = new ItemStack(Material.BARRIER); ItemMeta closemeta = close.getItemMeta(); closemeta.setDisplayName(ChatColor.RED + ("CLOSE")); List<String> closelore = closemeta.getLore(); closelore.add("Close the gui"); closemeta.setLore(closelore); close.setItemMeta(closemeta); but when i do this it does load the gui ItemStack close = new ItemStack(Material.BARRIER); ItemMeta closemeta = close.getItemMeta(); closemeta.setDisplayName(ChatColor.RED + ("CLOSE")); close.setItemMeta(closemeta);
Sorry didn't see if there was a response my flat just had to get evacuated because some nitwit burnt food
seems like a weird issue on my part
can you send the code, I'll try something
?paste
yeah it seems to work
lemme make the particles bigger
for some reason adding souts fixed it
maybe my particle size is too low
yeah
now we just need to reverse the animation
or what we could do to sound fancy
is just make the descent 1 and play a reversed version at the same time
which is exactly what you wanted
yeah, that's what i was looking for
so yeah just set the descent to 1
and play 2 copies of the same animation but one's reversed
and they like
compliment each other
yeah got it
Don't detect inventories by their name
You have a list of lists
took me a few hours and a lot of pain with chatgpt
That is what is happening, I was thinking I only had one for each filter
Thanks for keeping my mind sharp with these particle effects
That's definitely one side I need to expand on
Im changing it, should i detect by an item lore?
like a secret code
Also how do i get any mob head with a plugin?
can you also send the FramedEffect class?
like pig_head
Pig head is a player head with a skin
ok
No not really. Keep track of the inventory instance
I sent a screenshot so uh
just do your thing
Highly recommend https://www.youtube.com/watch?v=jvPPXbo87ds
why are splines? well my god I have good news for you, here's why splines!
if you like my work, please consider supporting me 💖
https://www.patreon.com/acegikmo
This project grew much larger in scope than I had originally intended, and burnout made it impossible for me to do more with it. It was already getting incredibly unwieldy, so I apolog...
You only need to watch first half or so
I barely understand trigonometry outside of like
Is there a way to mounting entity follow the direction of mounted entity?
3d stuff
Yeah check every (few) tick and set the direction
Is checking every tick the best way?
It's the easiest way
For better optimization, is there any better stuff?
If they're both AI controlled you can override the AI behavior to change both directions
Wow it's so hard 😅
thx 🙂
wait what's Location.toCenterLocation() ?
ah wait that's your own method
wait what API version are u using?
1.19.2
Let me guess you're on 1.8
🤔
Wait that's a Paper only method :kekw:
wut
yea i just saw
it's literally surrounded by // paper end // paper start
figured it'd be a bukkit thing
lmao weird
also, where's the Frame class from?
paper?
ah
and wb the Effect class?
ah
this isn't really worth copying honestly
has no workload distribution builtin or anything
what does the getFrames() return?
ohhh
Is it possible to use hex colours in the action bar?
Yes
yes
looking into units of tens of microseconds
and adding more functions is fairly easy, just look at the readme
What happens if you input invalid data
Hello! In the plugin called oraxen, even if I change the size of my rank "cards", nothing changes on the server, it stays the same. Anyone have any ideas/advice?
in where
you should ask in the Oraxen discord
Input
well what kind of input? functions?
Uhm
Oh, could you send me an invitation please?
Just anything weird honestly
smth like round(12.345, -2) would throw
its the responsibility of the end user to wrap the exception
Click the ask questions / get support button on their spigot page
Perfect
I have my own lil scripting parser thing so
I wanted to add math to if checks, conditions etc
feel free to inform me about the progress
It should be rather quick
90% chance we'll just fork and shade
One weird thing idk how I'd do would be converting ints and all
Like
you can specify you want an int in a function declaration
@echo basalt use crunch?
if randint(0, 1)=1-1
hmm?
ye
ye nah I have beef with him
also last time I followed one of your suggestions I ended up wasting 6 hours on pathethic
had to rewrite the nms to work on 1.18.2 and instead of trying to pathfind towards a location the npc would just fly there lmao
should I consider redstone ore interactable or not?
For what use case?
Checking if a block is interactable lmao?
then yes it is interactible
It returns true for piston heads as well for example, so you know just wanted an opinion if I should consider redstone interactable @eternal oxide
yes
Because some blocks just don't do anything on interaction though they are still interactable
follow teh API and you won;t go wrong
Omg Icant those people in the queue-line in front of me
the reversed frames doesn't seem to work
Because you don't see something happen doesn't mean it can't
only the top half works
They legit now already took 10 minutes to buy a fucking ticket???
oh yeah because waterlogging and stuff right?
yep
Cauldrons
?
I just need to then check if the block is waterloggable and the player is holding a bucket (empty bucket, waterlogged; full bucket, not waterlogged) and consider that as well?
becomes WATER_CAULRON when correctly interacted with
show code
new FramedEffect(plugin, frames, 20).render(location.getWorld());
new FramedEffect(plugin, reverseFrames, 20).render(location.getWorld());```
its the same as u gave
instance check of BlockData https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/Waterlogged.html#setWaterlogged(boolean)
if instanceof it can be waterlogged
wait i think for the reverse frames, the y pos should be -1 right?
no it's just the same for both
since it starts from the bottom of the block
the reversing already does all the funky math for you as it just plays backwards
but the original frames only render on the top half right?
so the reverse frames should render on the bottom half no?
ugh let's break this down
The full animation consists of a single wave going top -> bottom
Without changing the math, and just reversing all the frames, it become bottom -> top
Now, play both at the same time
and you have the desired effect
oh
for me, it only renders to half of the block
did u change the getHollowCube method in your example?
set the DESCENT variable to 1
@echo basalt added a jitpack repo if you need it
i am having trouble having the effect packet work on other players
the packet works fine if i am the target of the effect and the packet
but if the target of the effect is another player but the packet target is still me
i am not able to see the affect (ive been using glowing and invisibility effect so it would be visable for the packet target)
I am using my normal account and an offline account to test this on my localhost server
could the offline account be the problem or could it be something else?
Well
Glowing and invisibility are easier to handle in a different, easier way
and usually handled that way regardless
Glowing is part of entity metadata
And invisibility, well
You can just send a packet to remove the target entity
invisibility and glowing is just so i can see it happen on the account that got sent the packet so this could be any effect
Yeah true but
Invisibility and glowing are the 2 weird cases that actually affect how the player's rendered
the effect packet just dictates what potion effects an entity has
import org.bukkit.Material;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class SpawnerPlace implements Listener {
@EventHandler
public void onplace(BlockPlaceEvent e) {
if(e.getBlock().getType().equals(Material.SPAWNER)) {
Player p = e.getPlayer();
CreatureSpawner spawner = (CreatureSpawner) e.getBlock().getState();
if (spawner.getSpawnedType() == EntityType.COW) {
// here
}
}
}
}
``` how would i make it so where it says '//here' it saves the coordinates of the spawner to a file called cows.yml that is inside of a folder in the main plugin folder where the config.yml is?
Well I'm not going to teach you the basics
get the config and then use set()
buut
a little googling goes a long way
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
String message = event.getMessage().toLowerCase();
for (String sozcuk : bannedWords) {
if (message.contains(sozcuk.toLowerCase())) {
event.setCancelled(true);
event.getPlayer().sendMessage("You can't use this word");
break;
}
}
}```
yml file says asd but when I type asd in chat the message is not blocked
we don't know what korumaSozcukleri is
i highly suggest to use english words for variables
print out all the values in bannedWords and see why its not matching
i'll take care thank you
there is only one word in yml, when i write it, i don't get any error in console
hm I just thought about a really nice concept
that will take some annoying math and redesigning to do
oh sorry now i get it
words in yml are not reflected in console output
So your list is empty
but yml is not empty
so you're not loading it correctly
1 min i will check it
man sometimes I wish I wasn't a developer and could just pay someone for my crazy thoughts
because this is an annoying math issue
developers can also pay developers
true but this is rather advanced
no ones stopping you lol
yeah I'm one of them
but this is a proof of concept that's like
100 ish bucks to code
and I don't have that kind of money
$100?
100 doesn't sound like alot
yeah
it's a proof of concept that takes like 3 hours to make
that's annoying
I'm too depressed to be working 3 hours
3 hours is nothing lol. I'm working on an engine since at least 100 hours and I'm far from done
public static List<String> bannedWords;
@Override
public void onEnable(){
createConfig();
loadConfig();
}
private void createConfig() {
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
}
File configFile = new File(getDataFolder(), "chatkoruma.yml");
if (!configFile.exists()) {
saveResource("chatkoruma.yml", false);
}
}
private void loadConfig() {
FileConfiguration config = getConfig();
getConfig().getStringList("bannedWords");
korumaSozcukleri = config.getStringList("bannedWords");
}
private void printKorumaSozcukleri() {
for (String word : bannedWords) {
System.out.println(word);
}
}
private String getConfigValue(String path) {
FileConfiguration config = getConfig();
return config.getString(path);
}```
I mean it does work but I'm not happy with it yet
my brain is on fire
you aren't the only one
that looks fine to me
can i see the config itself
Currently working on 2-3 projects
biggest one's around 40k lines
Smallest one's around 5k lines
well mine is mostly reflection and parsing - take time to make everything consistent. dunno about the lines. It's about 190kb without any libs
yeah mine's around 1mb without any libs
# chatkoruma.yml
# Mesajlarda kontrol edilecek sözcüklerin listesi
bannedWords:
- a
- b
- c
- d
- e
- f
programming dick measuring competition going on
Um nothing seems off
maybe we're both missing something
I'm never flexing with anything programming related
I'm proud of my work. Sometimes more sometimes less. Flexing is too much though
oh
whats this korumaSozcukleri = config.getStringList("bannedWords")
why are you not doing
bannedWords = config.getStringList("bannedWords");
or is that the translation
I agree with the others. Please code in english
had to look at turkish code yesterday
you are all right
how can i check it
print it's contents immediately after you load it
see if its empty
private void loadConfig() {
FileConfiguration config = getConfig();
getConfig().getStringList("bannedWords");
korumaSozcukleri = config.getStringList("bannedWords");
printKorumaSozcukleri();
}
like that
ok I used my brain
this might be nice
this'll either be really choppy or really smooth
can you send me the untranslated version
im trying to make it so when I right click with a specific item, it deletes 1 of those items, but when i do it it deletes all of them in my inventory. Can someone help? This is the code: @EventHandler
public void onRightClick(PlayerInteractEvent event){
Player player = event.getPlayer();
if (event.getAction().equals(Action.RIGHT_CLICK_AIR)){
ItemStack item = player.getItemInHand();
String name = item.getItemMeta().getDisplayName();
if (name.equalsIgnoreCase(ItemManager.overlordrankvoucher.getItemMeta().getDisplayName())){
String PlayerName = player.getName();
Inventory inv = player.getInventory();
inv.removeItem(item);
server.dispatchCommand(server.getConsoleSender(), "lp user " + PlayerName + " parent add overlord");
}
}
}
public static List<String> korumaSozcukleri;
@Override
public void onEnable() {
createConfig();
loadConfig();
printKorumaSozcukleri();
}
private void createConfig() {
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
}
File configFile = new File(getDataFolder(), "chatkoruma.yml");
if (!configFile.exists()) {
saveResource("chatkoruma.yml", false);
}
}
private void loadConfig() {
FileConfiguration config = getConfig();
getConfig().getStringList("korumaSozcukleri");
korumaSozcukleri = config.getStringList("korumaSozcukleri");
printKorumaSozcukleri();
}
private void printKorumaSozcukleri() {
for (String sozcuk : korumaSozcukleri) {
System.out.println(sozcuk);
}
}
private String getConfigValue(String path) {
FileConfiguration config = getConfig();
return config.getString(path);
}```
use setAmount and only remove when the current amout is 1
but what if it is in a stack, is there a way to only remove 1 of them?
Yes
how? 😦
stack.setAmount(stack.getAmount() -1);
You get the string list from config.yml when im guessing its in chatkoruma.yml
ooh you're right
I am very confused with config.yml codes and chatkoruma.yml codes in the same class
THANK YOU it worked
yw
can you tell me what i should do
getConfig() will by default use config.yml
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
check out the bottom of that
Using Custom Configurations
oh
okay
thanks
If I add the korumaSozcukleri directly to the config, will it work?
I am also Turkish but I code in English to make the code future proof, it helps other developers to help and actually understand the code
I recommend doing the same
you never set bannedwords so your list is null
ignore me, I was scrolled up 🙂
I hate this. Happened to me a lot
im trying to hide command log messages from console for commands that start like that but this doesn't do anythingvb Bukkit.getLogger().setFilter(message -> message.getMessage().startsWith("/component-click-"));
What's wrong with this that it resulted this error?
https://sourceb.in/UQTQBop7Vj
are you messing with NPC's?
are we talking about void smth(Enum<?>... e)?
enum constants you mean, work with the ordinal
myMethod(INFO.ordinal() | PREDICATE.ordinal())
wdym
no implicit conversions from enum to int in java ;(
Nope
wdym with native
You are removing items from teh player in the interact event
that's not allowed?
i thought we were talking about java 💀
Quick google search https://www.spigotmc.org/threads/java-lang-assertionerror-trap.498861/
could be, will just adjust the code then, and see if it works..
how would you do it in c++ 👀 just interested
thats what i was thinking of, but you needed enums 🤔
can somebody please help me with this?
sysout the message so you can see what it contains
not the solution
im trying to put a textcomponent in a book so it can detect click events but its just appearing as json text lol, I can't find any methods other than this one to add the text, anyone have any ideas?
BaseComponent[] comp = TextComponent.fromLegacyText(ChatColor.RED + "HI!");
for (BaseComponent bc : comp) {
bc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/yes"));
}
meta.addPage(ComponentSerializer.toString(comp));
for clarity, this is 1.8
yeah I thought the componentserializer might've been an ezpz nms workthrough, can't find anything different lol, not sure why it would be showing as json text though unless I'm being stupid
WAIT
I think I might just be being stupid
hello, i can't quite figure out how to fill blocks between coordinates, other than using the fill command, i can't use that because the player doesn't have permissions to do that. i don't quite understand how to loop the blocks in the area
maybe not, actually, thought i'd missed the ichatbasecomponent
got an idea, i can make a placeevent and add the location to a list, then just remove every block from that list
nevermind, I am stupid, idk why posting it helps me think, basically, in 1.8 you can only add strings to books through the spigot API which is why my json wasn't working, so I just used reflection to expose the actual pages arraylist in nms, added the base component to that (because all spigot does is turns the string in the api to a base component) and it worked
but grazie
ITALIAN?
also idk if they changed it, in 1.8, TextComponent#fromLegacyText returns a BaseComponent[] array, so I can't ;-;
rip
what ya tryna do lol
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Just use Strings KEKW
Can't do fancy things with strings
yeeee, I'm using packets to open a fake book so players can click an option to report a player, strings aren't fabulous enough :((
I agree
paper tried to do it didn't they and nobody could be assed so they just kept using spigotapi for everything
I kind of wanna make a text input field with books
And disable darkening, make book smaller and customize look
But idk if its possible
yeah the paper API removed ALL strings and replaced them with the component API (not the text component API, their own stupid difficult thing for new people to use)
With resourcepacks ofc
With a resource pack you can
texture packs :donger:
Would need core shaders huh?
to newer people it tends to be a thing they need to get their head round if they've used usual strings for ages
paper should come with MiniMessage now
personally ive never used it cause im a lazy ass
anti-legacy 
^ and that
you sent that message, my discord tried to make me automatically buy nitro and then crashed, what on earth

Imagine accidently clicking on "confirm transaction"
And then subbing for a year of nitro and 1000 boosts
I've got it on my main, I think there's a £2 version of it
Spigot also has components smh
Why not
Whats the performance and stability diff of paper vs spigot?
Who cares about load time bro
Servers boot in 2 seconds anyways
Spigot should be more stable
We aint in forge lmao
Since we don’t make nearly as many invasive changes to the server
the forge discord would ban you, dox you, put a bounty on your head and bomb your house for mentioning you code on any version below the current latest
Source?
how do I decompile Bukkit to get the default ChunkGenerator code?
I just want to slightly modify it
Lol so will paper
buildtools
Well, not quite but they won’t help you
ty
It’s just a fancy way to run buildtools at runtime essentially
There was a spigotclip before
I mean, it is pretty far off buildtools
Yeah paperclip just applies a binary patch on the notchian server impl

Yeah
weee frate
(I have no idea who you are but it seems we speak the same language)
btw i've managed to do the console command message thing
its almost as if its original name sounds better than a hacky mashup
I think it does sound good
does one have a good guide on ChunkGeneration?
Im trying to make mainly ocean and sometimes some cool looking islands
yet I can't seem to get it working.
I'd honestly wait until 1.20 and the material rewrite v2.0 which also affects many other enums such as the biome enum before starting on chunk gen
well it makes sense, but I don't think it will take me just a few hours to setup after the update, so I want to get the hand of it sooner
also did someone crack those riddles and knows release dates?
June 7th?
oh
i have mistakend those riddles with their other game :D
It's always a Wednesday. So either May 31st or June 7th
You mean the package-info.java class?
AI moment
change display mode
or smthing
untick this
At least Eclipse hides empty packages, I assume that is what you are seeing
Yep. that is what you are seeing
I'm guessing you had your economy package selected when you told it to create orbs
I just wish they'd add more features in their releases. They've slowed down on that front for the last couple releases and it's annoying
There's only ever like one or two things to look forward to and they're so minor
Like this is the only thing I'm excited for in the next release!
A CONTEXT MENU ITEM
ugh white mode
I just hate having to press Alt + Shift + H sometimes
is the "quick actions" thing still like, "cant find method String#whatever, lets cast that string to a Player"
atleast that was how good it was when i used it 💀
Yeah because it's a valid solution sometimes. Other suggestions include changing the method signature or the variable type. What more do you expect from quick fixes?
that it stays quiet instead 💀
Yeah. Eclipse's dark mode is kind of awkward
It's the only app I still use in light mode
Tried. Hate them all and the preferences don't always save
ew
themes 
At the end of the day, I still write good code 🙂
thats the spirit
Well, I hope so
my man thought it was a good idea to let every getConfig call (which gets smth from a json file) parse the whole json file, measured it 💀
how do I make ArmorStand head bigger? as big as normal block
If you're on 1.19.4 use display entities
ye im
didn't hear of them
imma give them a try! thanks
how are they called in API? :D
static abuser
oh man he calls that nearly 40 times on startup, thats about 30ms gone man
no need to be angry man i just I suggested
ItemDisplay, BlockDisplay, TextDisplay
This guy is too angry
tysm
Does anyone know how can I make a timer in the scoreboard from Tab List plugin

Bit of a gobshite though arent ya
can they be walked on? somehow
You could use invisible shulker boxes and wrap the display entity around it
what event is triggered when the player picks up an arrow?
PlayerPickupArrowEvent ;p
What version?
1.8
I added it in 1.9 I believe
If I'm not mistaken, pickup item is called but there's no distinction between arrow items and arrow entities
1.8 is so awful, I had to do so much already just because half the stuff does not exist and I can't even switch to 1.9
Yeah, I mean that event was literally added 7 years ago
It was actually my first ever contribution to Bukkit 
I'm gonna die in this awful 1.8
how do I get BlockData of unlit campfire?
I wish I could switch to 1.9
Same as any other block. Block#getBlockData()
I'll let you guess which specific type of BlockData it returns 😛
THE block data
okay but how do I make unlit campfire? I tried getting its BlockData and setting lit to false, but there isn't any lit or smthing
Its okay mate. I dont judge you
Did you re-set the block data?
Block#setBlockData()
the problem's that there's no lit variable to be set
Sure there is. Campfire#setLit(false)
You do
or even when I cast it to Campfire
You're importing the wrong Campfire
org.bukkit.block.Campfire vs org.bukkit.block.data.type.Campfire
🤠
oh my
i was importing the shorter path :D
tysm
sorry if this might be considered spoonfeeding but i would have the command /fill 41 55 -11 62 58 -11 with corner 1 being 41 55 -11 and corner 2 being 62 58 -11, how would i make a loop out of that?
Think about it this way. You want to go from x -> maxX, y -> maxY, and z -> maxZ
How would you go from one value to another using a for loop?
you would have i = x; i + 1; if i = maxX; return, something like that (just some pseudocode) and then the whole thing with the other coords
would you just do that or is it more complicated
i++ better
for (int i = 0; i <= 10; i++), so there's i from 0 to 10
Now if you wanted to go from, say, 50 to 100, your loop would look like for (int i = 50; i <= 100; i++)
yes, that's what i meant, is it just that?
because i thought it was more complicated
Pretty much. Only instead of one loop, you have 3 numbers you want to loop over, right?
Notice that the 50 and the 0 will get called to
So its 11 iterates
Or would it?
Yeah. For a fill you'll want that
yes
And if you want a volumetric loop, you'll just have to nest those loops
for (x) {
for (y) {
for (z) {
Block block = world.getBlockAt(x, y, z);
}
}
}```
I'm sure you can fill out those for loops knowing what you know now 😄
okay, thank you very much!
is there a way to get which page of a book a player is currently viewing (not from a lectern)?
declaration: package: org.bukkit.inventory, class: InventoryView, enum: Property
sorry wrong doc
declaration: package: org.bukkit.inventory.meta, interface: BookMeta
i said not froma lectern
#getPage()
Yea, the book is client side
Like in this thread
Hello everyone
I have a little question
I'm looking for something to get all files in resources 😅
Do you think it's possible with spigot ? I've found Plugin#getRessource but it's made to get one file with a specific name :/
are there any other way to track if player teleported to other world rather than PlayerTeleportEvent and PlayerChangeWorldEvent?
as if player is teleported by Multiverse non of 2 events are called
and It seem there is no event api in multiverse either
In Java, can i somehow run code after the child constructor, without explicitly calling it in the child constructor?
Not in the way you wish.
I know i could just not use constructors and put it into functions, but thats kinda shit
There is an init block, but that runs before.
yea, chatGPT suggested that too, but if it runs before its of no use
? static function
No?
its nonstatic stuff tho
Just call it from the constructor
and it should be called after every child constructor call
from the child constructor?
but that sucks, if i have to do that for every child :/
:l? why
hello, how do you show hud titles (like those on top of the hotbar)? and if so, i would need to update it every 5-10 milliseconds (because i'm making a stopwatch). is that possible?
so do abstract class
yeh so what the problem with it?
well, how does that solve the problem?
you don't need to repeat it?
whaat, how
?xy ig
Asking about your attempted solution rather than your actual problem
You haven't explained actual problem
Parent:
public MapMenu(Player player, ItemStack map) {
canvas = new Canvas(mapView);
window = new Window(canvas);
this.onLoad(); <--- Should always be called, and always after child constructor, because it needs the stuff which is created in the child constuctor
}
protected abstract void onLoad();
Child:
public ChallengeMapMenu(Player player, ItemStack map) {
super(player, map);
defaultButton = ImageIO.read(Objects.requireNonNull(this.getClass().getResourceAsStream("/images/DefaultButton.png")));
}
@Override
protected void onLoad() {
// 100 lines of code that create a new map which i do not want to put in the constructor because I don't like having hugeee constructors and i want this to be able to be called manually later
}
That's the code.
I don't wanna have to call this.onLoad() at the end of every child constructor. I would like to have that call at one place, no duplicate code.
And I don't wanna put the onLoad stuff in the child's constructor, for the reasons mentioned.
So yeah, I hope my code made my question more clear? Basically i automatically wanna call onLoad of the child class after the child constructor is finished.
super()
?
what? where?
what about it?
idk
If anyone is interested, here is the solution I decided to implement:
I created an enumeration with all the config files I will have. And I loop on this enumeration.
he just said super)=
Nah you can't do that in java, you have to split methods
Parent constructor always must be called first
oof, hmm :/
I actually don't know language where that isn't the case
super() isn't useful as it must be first method in child constructor, you can't postpone it
Is there a way i can optimize this?
I don't think what you want is possible. There is also a problem with calling overridable methods in the constructor.
Consider the following:
public abstract class SuperClass {
public SuperClass() {
onLoad();
}
public abstract void onLoad();
}
public class ChildClass extends SuperClass {
private final Object myObject;
public ChildClass(Object myObject) {
this.myObject = Objects.requireNonNull(myObject);
}
@Override
public void onLoad() {
System.out.println(myObject); // prints null even though this shouldn't be possible
}
}
use single instance/dependency injection instead of static
I'm making a smithing recipe and I've noticed I cannot use a custom item as the RecipeChoice base, but it's fine to use a custom item as the RecipeChoice addition.
Is it a bug or there are some reasons for not being able to do that?
Parent:
public MapMenu(Player player, ItemStack map) {
canvas = new Canvas(mapView);
window = new Window(canvas);
this.init();
this.onLoad();
}
protected abstract void init();
protected abstract void onLoad();
Child:
public ChallengeMapMenu(Player player, ItemStack map) {
super(player, map);
}
@Override
protected void init() {
defaultButton = ImageIO.read(Objects.requireNonNull(this.getClass().getResourceAsStream("/images/DefaultButton.png")));
}
@Override
protected void onLoad() {
// 100 lines of code that create a new map which i do not want to put in the constructor because I don't like having hugeee constructors and i want this to be able to be called manually later
}
So the only way is doing it like this, i guess?
Why you don't just run onLoad in child constructor, why it must be in parent?
This is my full class, i can make my Connect function return an instance with all the functions so its no longer static abusing
duplicate code
too much work to zoom in
so extend the child class?
and you will have grand child class 
Well, it's only one line, I like it more then init method
also look at the problem I posted above
you can do public final class if you mark that class as utilities
it is still the same :l
Didn't you forgot a super call in the child class?
having supper() or not doesn't change the fact that constructor always called first
the super() is implicit
since the super consturctor is called first, the state in ChildClass is not initialized by the time onLoad() is called
leading to myObject being null when it shouldn't
this is complete overuse of static
ah true, forgot java does that
but yea, thats exactly the problem i had
I think your best bet is probably going for a private init method if you really don't want a big constructor
I have revised my static abuse,
Class "MongoUtility.java"
Class MongoConnector.java
Out of Context?
?
You'll realize it
Ah meanwhile I thought there was some new design philosophy I would disagree wholeheartedly with
how do i get the server default "no perm" message?
Can you please give code instead of screenshots ? 😢
MongoUtility sounds so insulting in my language lol
is there a way i can pre create "Async Tasks" would i go about it like this:
public Profile t(UUID uuid){
Bukkit.getScheduler().runTaskAsynchronously(OcsolirCore.getInstance(), new Runnable() {
@Override
public void run() {
retrieveProfile(uuid);
}
});
}
Or would i create a bukkit runnable
then execute it as an async
yeah you can create a bukkitrunnable without immediately running it if thats what you mean
Would it be better to do that
i dunno why do you need it
or to create a method like i showed?
it just creates an object, nothing more
whats the goal here
BukkitScheduler.runTaskAsync creates a BukkitTask internally
To optimize the getting/setting of ranks in a mongo database
if its a single task you're running async then no you dont need to worry about performance much
i'd just fetch data when player joins, persist when player leaves
and also recommend saving data periodically to account for crashes
Ye thats what im doing, im trying to get it down to the tiniest spec that it doesnt yeet server performace if a lot of people joined suddenly
if you worry more about that you might want to consider just loading in most profiles on server startup, but thats obviously big on memory
I mean how would i go about that
if you're doing that you'll also want to purge profiles that made little to no progress
wdym you just do what you do with one person with everyone in the database
can i remove a players permission as they leave? I have a permission i want to give to players that are in the que and if they disconect i want to remove them from the que
sure
okay
yea player.removePermission()
Hello, I am wondering why is the first code works perfectly, while the second doesn't?
Bukkit.addRecipe(recipe1);
SmithingRecipe recipe2 = new SmithingRecipe(new NamespacedKey(plugin, "recipe2"), customitem2, new RecipeChoice.ExactChoice(customitem), new RecipeChoice.ExactChoice(new ItemStack(Material.IRON_INGOT)));
Bukkit.addRecipe(recipe2);```
why not working with pdc flags?
playerquitevents happen before the player has actually left so you can access the player object just fine
i know how to remove perms
yh that was what i was concerned about thx
does anyone know how i can make a block spreading plugin with the WorldEdit api?
what
That
help
Oh
yea
ok
no
idk why
cant explain
doesnt make sense
I save the player data in a local hashmap with there UUID, so i can serach them up when i need them
i also have a bit of question, is it possible to detect item lore changes with nms? i want to make a lore api to allow for dynamic item lore changes, without interfering with other plugins possible changing lore
like if another plugin wants to add lore it will still be able to but otherwise my plugin would handle the lore format on the item
I jsut dont want the server to have to call out for data
thats not the issue, sending fake lore packets is fine
but i want to detect when the lore of an item is being changed
You can scan exiting packets and check if new lore gets sent
That probably be inefficeitn
i dont care about the packets being sent to the player, i need to compare the before & after of an item's lore when its changed. essentially, i want to detect when setItemMeta() is being used
from any plugin
nutty 😆
mmmmm
and another kinda not really related question, is it possible to space bits of text equally among several lines
basically making a table
maybe using negative space characers with a resource pack
all solutions ive found online involve things like guessing character widths and figure out how many spaces need to be between words to kinda get the spacing correct
yeah
but obviously such a character width guessing method would break if a player uses any font changing resource pack
pretty much yeah
but you can force item boxes to be a certain minimum size to make it fit so thats less of an issue
467_72_-59:
world: world
amount: 1
percentage: 0.0
462_73_-63:
world: world
amount: 1
percentage: 0.0
462_73_-62:
world: world
amount: 1
percentage: 0.0``` How would i make it so that every 5 seconds the percentage on each one of these would go up by 0.1
the location is Espawners/spawners/pigs.yml
can i bypass ItemStack size limit somehow?
iirc you have to change it in nms
hell no
Anyone have any idea?
its my plugin
Then you should not be treating that data as live
how should i
you cache it in memory
then you periodically save it as needed
files are used to store data to be reused in the next session
Things you want to remember between server starts
hello! i'm currently trying to display an actionbar using nms and an interval, because the string that gets shown constantly has to update (im working on a timer), but the server just stops responding after like 10 seconds and eventually crashes. is there a way of showing it and updating it every like 100ms? i've tried intervals ranging from 50ms to 500ms
this is my code right now: java while(Main.isRunning) { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Main.formatTime(Main.getTime()))); TimeUnit.MILLISECONDS.sleep(500); }
run async, you can not sleep the main thread
how can i make this spawncount int go up for every player so every player gets a unique spawn
sorry, i'm still quite new, but how would i do that? (yes, i'm trying not to get spoonfed, just haven't really found anything useful)
?scheduling
use Bukkit.getScheduler().runTaskTimer
and check if its enabled in the task
if so do the logic
alternatively cancel the task when you disable your plugin
so i would have to turn my method into a bukkitrunnable?
just put the code inside the while loop, excluding the sleep, inside a lambda
then put 10 ticks for the period (10t*50ms/t = 500 ms)
so essentially like this from the wiki?
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(plugin, () -> {
Bukkit.broadcastMessage("Mooooo!");
}, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);```
yeah
yeah
okay, but now i get an error which says that the plugin is already initialized, i just used new Main() as plugin parameter, am i doing it wrong?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
or just do a static getter
Kotlin > Java in terms of syntax 🤥💯
really dont see issue with that
Pin this or gay
i can't do a static return this; in the Main class
non-static variable this cannot be referenced from a static context
Sadge
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
can I create ItemStack that looks like the black and purple cube?
Thats a texture
Error
ikr
i want to use the texture as a signal for me when I f something up in code
Idk
I mean the texture is there to represent something else that's fucked up
Anyone got a yt video that can explain me how to do working and bugless matchmaking
public class A extends B {
private final byte BLACK = MapPalette.matchColor(0,0,0);
public A(Player player) {
super(player);
}
@Override
protected void init() {
System.out.println("Black: " + BLACK + " | " + MapPalette.matchColor(0,0,0));
}
}
public abstract class B {
public B(Player player) {
this.init();
}
protected abstract void init();
}
Why does this print "Black: 0 | -49" instead of "Black: -49 | -49" ?
Shouldnt the BLACK = MapPalette.matchColor(0,0,0); be executed before the init method?
If I do
public A(Player player) {
super(player);
System.out.println("Black: " + BLACK + " | " + MapPalette.matchColor(0,0,0));
}
@Override
protected void init() {
System.out.println("Black: " + BLACK + " | " + MapPalette.matchColor(0,0,0));
}
it prints
"Black: 0 | -49"
"Black: -49 | -49"
does the BLACK = MapPalette.matchColor(0,0,0); only get called after the super constructor is finished? I don't get it...
Im not to sure how to do it so i just changed my idea, i saved the current time after 60mins there instead so i wouldnt have to update it every 20s
ye
can u be a bit more specific?
r u using some type of match making rank to match players up against each other?
nope just basic machmaking
if theres 8-10 players in que i want a game session to be initialised
i have code that should work but only for 1 sessrion at a time
which sucks
any better way to store config values :l?
in a confug file?
:)
I don't want a file with 80 getters
no1 said u have to have 80 getters
so how could that be improve :l
ever heard of sth like the producer consumer pattern?
improve by using naming conventions
well they're not breaking any name conventions technically (I assume the non final is intentional altho its prob not)
I guess. I thought those were constants
yea
nope
not really :l
okay, to make it simple use a queue collection
then u have two ways of dealing with the consumption and population of the queue drvoss
There is actually no way
either eagerly check the size of the queue when ever u push things to it
or u go async (id do this)
yh thats what im already doing
how exactly does that work tbh i never really understood it
bro not even my dad ghosted me that hard
:l I meant to load it into ram
How would these be “config” values if they’re not even in a configuration
Doesn’t that go against like the whole point
my bad
just load them when ever you need them instead of loading all at once
so like you load it everytime the object is called?
not a great idea :l
well it depends on how often that value is needed
if its something that you need on every move event i agree with you
but
if its something being triggert every once in a while why waste ram on it
I mean :l that couldn't even more than 1mb I believe
do you believe
depends
if its jusr booleans yh
it does has lots of text but still not that big
oh yh well then its fine ig
So, I've been trying to make a custom health system on my plugin. I am trying to get the number out of the first lore on the head item and I'm getting an error. I've showed the helmet, error, and code. Can anyone tell me how I can fix this to get the health in the first lore and add it to the variable setMaxHealth in the code?
is there a way to make attributes completely do nothing for armor or swords but still... be there
actually nvm ill just use pdc
thats the way to go
Is there a way to use a runnable to check if 50 minecraft days have past? I want all spiders to attack every player every 50 minecraft days.
you can calculate a day count
hi, so I'm new making APIs with Spigot and I'm having this error:
[ERROR] Error occurred while enabling MiniGamesFun v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!
at com.donbaguette.arenaapi.ArenaAPI.<init>(ArenaAPI.java:10) ~[?:?]
at com.donbaguette.minigamesfun.MiniGamesFun.onEnable(MiniGamesFun.java:11) ~[?:?]
Caused by: java.lang.IllegalStateException: Initial initialization
(I only kept the useful lines)
My API main code:
public ArenaManager arenaManager;
public Arena arena;
public ConfigManager configManager;
@Override
public void onEnable() {
// Plugin startup logic
arena = new Arena();
configManager = new ConfigManager(this);
arenaManager = new ArenaManager(this, configManager);
}
My plugin main code:
public void onEnable() {
// Plugin startup logic
ArenaAPI arenaAPI = new ArenaAPI();
arenaAPI.configManager.createConfig();
this.getCommand("mgf").setExecutor(new Commands());
}
The line where I get the error (11):
ArenaAPI arenaAPI = new ArenaAPI();
Of course I already red the error and know that is caused because I initialized my API main class, but what I don't know is WHY I get that error.
you can NOT create your own instance of your plugin
is this day count already a feature within the spigot api? or is this something i am going to have to create?
I mean, I initialized the main class of my API into the main class of my main plugin
dont use a runnable, 50 * 20 minutes is a lot of time
uh
What should I use instead?
should I make my API static then?
what do you mean?
since other dude left just like my dad for the milk anyone else wanna carry the burden of explaining GOOD matchmaking to me?
I dont understand by what you mean of timestamps.
show the code you have in your main class
everything's here
the last code is from the main class of the main plugin
i see
Whats the easiest way to see which packets my server sends to my client?
well you cant really have 2 plugin classes in 1 plugin can you?
i mean thats what I assume
round them
show code
well, as I said I'm new at creating APIs, so I just followed a basic tutorial and tried to apply that to my logic, but didn't worked lmao
computers are bad at floating point :l
just for int i loop with 0.1 and += 0.1
Math.round(x * 10)/10
so the issue should be fixed from the API or from the main plugin?
just asking so I can try to fix it
plssss
in what sense?
usually apis that I use dont have a plugin class
well matchmaking xd having a que of players and then start an instance of a game once there is enough players.
im struggling with having multible run AT THE SAME TIME
they only have their normal classes instead of a main one and don't need to instantiate them?
running*
your api can still have a main class or smth, then just pass your plugin into the constructor or whatever
yes but like for what game? matchmaking can be different amongst so many different types of game. an action game, with a k/d or just mini games with a w/l it all depends on what game to have a decent matchmamking system.
so you could do something like api = new MyAPI(this) if that makes sense
where MyAPI is not a plugin
i dont want any statistics influencing the matchmaking. Just really basic and simple.
but has a reference to your plugin
its some kind of battle royal you could say
8-10 players in each session
last one standing wins
okay so what's the current problem? you want a matchmaking, how do you have this planned rn?
can anyone answer my question in #help-server
so I should delete the main class of my API right? and then in my other classes (of my API) ask for the instance of my main plugin and use it?
well rn all i do is give permissions to players in que and then when theres enough start a countdown, warp them etc. Works all fine. Just cant figure out how to host multible sessions at once
yes or just convert your main api class to not extend javaplugin
Okay, are you isolating the sessions? how are you creating the game or session.
much easier lmao
not yet bc i dont know how i dont have any sessions
let me test that
bc i cant for the love of god figure out how to do it propperly without it being all sketchi and overcomplicated
So you want to host multiple sessions. lets say 4 games at once. when the games start where would they go? just in a place around the world? i dont understand what the issue could be. you can hold most information in a HashMap, teleport the players to their own world, start the game, once they die or the game finishes, they get teleported back to the main location.
just a little issue @pseudo hazel, I need an instance of my main plugin, but idk what type should I add, I mean that all my classes that nead a plugin instance I do it like MyPlugin myPlugin and then use for example myPlugin.getDataFolder()
i dont know what all your thing is, im jusut trying to piece thigns together.
cant you just use JavaPlugin?
well they would spawn in a different world preferbly and fight until only one player is left. Then the game ends.
okay. so do that. for every session. they go into their own world.
like JavaPlugin myPlugin? wtf
yeah
yes in your API class for sure
yh but i dont understand how to use sessions. How do i differntciate between different sessions
tag them with an ID
int or uuid
you can ID pretty much everything
okay lets say i have a player death event bc a player got killed i just run through all the ids and see if they match?
u could prob use pdc or something to tag what game their in or loop
i would use a pdc
what he said
so basically just loop through ALL players every time something happens?
you can loop through that current session.
to test if theres only one player left for example
those 10 players or whatever would be in their own session their own world
when they die, you alter that session.
you tag them with a key with the session id, then you can use that to do whatever
you would tag them of what session they are in
okay let me try that thank you
itll probably be a lot of work lol. youll probably want to setup barriers and all of that. or even a custom world if you wish.
okay @pseudo hazel I think almost everything works, I just have a little and last issue. I've made a ConfigManager but can't make it work with resource files that are in my main plugin (the ConfigManager is in my API)
yh im already doing custom worlds


