#help-development
1 messages · Page 785 of 1
this is what it produced
why do i have the feeling that main is from the api
actually yeah it seems to have done the opposite
now my project is api with a side of root project
looking at the correct thing? api should produce artifacts in api/build/libs and the root project should produce them in build/libs
and make sure to choose the jar with the -all classifier (shaded)
uh
hold up
now it says my gradle is being used in another process
D:
yeah okay
wait what
im not trying to build api
im trying to build the root project shadign api into it
it needs to be built to consume it?
it does/
?
i thought it could just yoink the files
but yes i do have a built version in libs
which actually just becomes the root project and the root project becomes a subfolder of it whenever i build the root project
so im not sure why its not namespacing it under api
oh i see
i had them both under like
abc.def
i guess i shouldve put api under abc.def.api
i did a bit of tomfoolery and relocation and got it thanks
With World.playSound https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#playSound(org.bukkit.entity.Entity,org.bukkit.Sound,float,float) any ides what unit the volume and pitch are? (Like if I feed in 1 for both would it be a normal volume and normal pitch?)
declaration: package: org.bukkit, interface: World
do blocks not have their own pdcs
public void onTest (PlayerSwapHandItemsEvent event) {
Player player = event.getPlayer();
Block block = event.getPlayer().getTargetBlockExact(5);
if(player.getInventory().getItemInOffHand().getType().equals(Material.AIR)) {
player.getInventory().setItemInOffHand(new ItemStack(block.getType()));
}
}```
why are the items that im getting ghost items?
From what I recall TileEntities (so blocks with them) have PDCs when your at the block level in the world.
That event is probably fired before the item is changed on the server
so you set it and then the event will proceed and overwrite your item
ok so i should cancel it?
Is there a reason commands and even things typed in console are outputted twice?
is there like, some sort of instrument change event for noteblocks for when something breaks below them
nop
great
which jdk distribution contains javafx?
i probably need some special version right?
nvm got it
This might be dumb but how do I get the server to actually log out messages that I send using a logging level such as FINE or FINER. Want to add some debugging statements but I want to make sure I can actually see them Since I have heard its hard to change the logging level.
log messages to console
add a handler for those log levels
or change the accepted levels of the default handler
So no way that someone could just enable a finer logging level on their server. I would have to implement it.
as far as I know, typically what most people do is just print their own debug messages
Spigot should probably fix that... makes the logging levels sort of useless
the fine finer and info typically just don't need to be logged as they are not warnings or severe messages therefore why log them?
but I do believe these should still pop up in the console
Console only logs info and higher.
Hello, I have a problem with a plugin I made when I create a world via the WorldCreator, here is the error, I know there is a mark do not report but I do not understand how to solve it because it crashes my server https://pastebin.com/haQSBsKM
WorldCreator worldCreator = new WorldCreator("rushrace_" + getGameName());
worldCreator.type(WorldType.FLAT);
worldCreator.generatorSettings("2;0;1;");
world = worldCreator.createWorld();
it's impossible to loop, I'm sure.
Neither do I.
i check
i try with that (i send code)
WorldCreator worldCreator = new WorldCreator("rushrace_" + this.getGameName());
worldCreator.generator(new VoidChunckGenerator());
this.world = worldCreator.createWorld();
this.world.setGameRule(GameRule.DO_MOB_SPAWNING, false);
public class VoidChunckGenerator extends ChunkGenerator{
@Override
public @NotNull ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
return createChunkData(world);
}
}
If you want a void chunk generator in modern versions
All you need is an empty generator class
i try
no he crash
i try with spigot and paper and it's same
I suppose it would depend at what point you are trying to generate the world, or if you registered your plugin as a generator
I didn't register my plugin as a generator because I generate the world after executing a command.
Yeah you don’t need anything in Bukkit.yml if you are generating the world yourself
yes
Try setting a fixed spawn in your generator
how
in worldCreator ?
In ChunkGenerator
it's function ?
no crash
I'm going to sleep now I'm dead but I'll be back tomorrow if you're still hot to help me but thanks for tonight
no sry my server have crash
@Override
public @NotNull ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
getFixedSpawnLocation(world, random);
return createChunkData(world);
}
That’s not overriding it
public class VoidGenerator extends ChunkGenerator {
@Override
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, 0, 100, 0);
}
}```
That’s all you need for a void generator
opinions on how to make this more appealing
@worldly ingot should i be making potion effect type or potion effect translateable
or both
type
If you are making a minigame your best friend is SlimeWordManager, in most cases it takes up you the overloading for loading and/or unloading worlds. Also the worlds loaded by SWM are client side in a sense, meaning the blocks and those things are only seen by the client
enchantment and potion effect type both have translation stuff, what other stuff needs translations
How can I make builder a future and append everything to it?
package com.neomechanical.neoperformance.performance.smart.smartNotifier.report;
import com.neomechanical.neoconfig.neoutils.NeoUtils;
import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.Component;
import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.TextComponent;
import com.neomechanical.neoconfig.neoutils.messages.MessageUtil;
import com.neomechanical.neoperformance.performance.smart.smartNotifier.managers.LagData;
import com.neomechanical.neoperformance.utils.messages.Messages;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class LagReportBuilder {
final TextComponent.Builder builder = Component.text();
public void addData(List<CompletableFuture<LagData>> dataListFuture) {
dataListFuture.forEach(dataFuture -> dataFuture.thenAccept(data -> {
// Null means there is no data to report
if (data == null) {
return;
}
NeoUtils.getNeoUtilities().getFancyLogger().info(data.getDataName());
TextComponent.Builder dataComponent = data.getMessageData();
builder.append(Component.text(" ")).append(Component.text("[")).append(Component.text(data.getDataName()))
.append(Component.text("]"))
.append(Component.newline());
builder.append(dataComponent);
builder.append(Component.newline());
}));
}
public void sendReport(Player player) {
TextComponent message = builder.build();
if (!message.children().isEmpty()) {
MessageUtil.send(player, Messages.MAIN_LAG_REPORT_PREFIX);
MessageUtil.sendMM(player, message);
MessageUtil.send(player, Messages.MAIN_SUFFIX);
}
}
}
obviously this method is flawed as there is no guarantee the data will be appended to the builder
Best think you can probably do is look through the en_us language file and see what all is translatable and see if we have API for it
nice and fun, is it normal that coll is on the commits of my pr
lol no. You probably did somethin' weird but I wouldn't worry too much about it rn
I’m in your walls too
how have i broken stash too
(it’s bad)
man my model animator is so close and yet not quite there
How can I improve this code (or make it work):
public class LagReportBuilder {
CompletableFuture<TextComponent.Builder> builderCompletableFuture = new CompletableFuture<>();
public void addData(List<CompletableFuture<LagData>> dataListFuture) {
dataListFuture.forEach(dataFuture -> dataFuture.thenAccept(data -> {
// Null means there is no data to report
if (data == null) {
return;
}
NeoUtils.getNeoUtilities().getFancyLogger().info(data.getDataName());
TextComponent.Builder dataComponent = data.getMessageData();
builderCompletableFuture = builderCompletableFuture.thenCompose(builder -> {
builder.append(Component.text(" ")).append(Component.text("[")).append(Component.text(data.getDataName()))
.append(Component.text("]"))
.append(Component.newline());
builder.append(dataComponent);
builder.append(Component.newline());
return CompletableFuture.completedFuture(builder);
});
}));
}
public void sendReport(Player player) {
builderCompletableFuture.thenApply(builder -> {
TextComponent message = builder.build();
if (!message.children().isEmpty()) {
MessageUtil.send(player, Messages.MAIN_LAG_REPORT_PREFIX);
MessageUtil.sendMM(player, message);
MessageUtil.send(player, Messages.MAIN_SUFFIX);
}
return null;
});
}
}
its meant to go through each data retriever future and append it to a message builder, then send the message
I'm not sure how to do it properly though
I doubt TextComponent.Builder is thread safe
if you want to maintain the order in the list you allOf and thenRun, loop and build
i was joking but still "how can i improve this code" seems very general
I'm sorry, that must have been difficult
Does player always send packet when pressing hand switch button? Even if the hands are empty?
Is it really possible to create a texture on a placed block (1.16.5)?
ItemsAdder somehow did this
It isn't possible actually
I mean, you can't using custommodeldata
ItemsAdder uses a barrier block with an invisible stand
The stands has the item with the custommodeldata
but in the plugin wiki there are written types of blocks that can be created (REAL_POST, REAL)
and these 2 types are real blocks
There is not a way to create blocks textures without changing the texture of that block
But you can't using custommodeldata
Is it possible to somehow simulate a block as if the player is breaking it (with his own strength)
That's why ia sit can't make you interact cause you actually click on the stand
Like the break animation?
yes
Packets
It's not that difficult, it's just a packet
if i use PersistoDataContainer texture will be created in block?
What
well you could move the entire breaking process serverside by giving the player mining fatigue -1 and the manage everything yourselve
if this is what you ment
lol
please help, for some reason when I create a display block, it is empty, even though I installed a block there
if you look through /data, then they have this block registered and the size is not equal to 0
are creaperheads displayable 🤔 well try displaying them with a command
also i suggest using enhanced switch statements, they look way better
events
just returns null for some reason when i do player interact event
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
but when i do e.getClickedBlock.getType it just returns null
should it not be Material.AIR
thanks, replaced it to itemDisplay
Null and air er interchangeable mostly
Isn't the whole air and null thing really inconsistent
okay
A bit haha
Like sometimes it says are, sometimes it says null
obviously air is not considered a block for the interact event, otherwise this would not exist
i think i realised what im doing wrong
action.rightclickair is working its just one of my other conditions are wrong
thx guys
Can I replace the player's head texture with mine? Or does this head need to be on the mojang servers?
all textures come from Mojang
So I can't take a texture, edit it, and then load it onto the player's head?
no
so how they did it, with out shaders
I think it takes the player's texture and changes it
reflection or a 3rd party API which uploads to Mojang
isnt the value of you head saved on mojangs servers when you change your skin? so you could change your skin, get a player head from you and copy the value which is stored in the nbt. could be wrong tho
You can also do some cool stuff with vanilla shaders
Prepare for the doomed
yep, all the server does is send a texture link to the client. The client then downloads teh Texture from Mojang
Kind of. You would have to use a service which uses dozens of minecraft accounts to constantly upload skins to mojangs servers to get them signed.
They are free and have a decent API
or after the head got signed you could just use the texture string and use that for reproduction
Newer versions will do: [15:08:41 WARN]: Found inconsistent skull meta, this should normally not happen and is not a Bukkit / Spigot issue, but one from a plugin you are using. Bukkit will attempt to fix it this time for you, but may not be able to do this every time. If you see this message after typing a command from a plugin, please report this to the plugin developer, they should use the api instead of relying on reflection (and doing it the wrong way).
the "texture string" is just a base64-ed link to textures.minecraft.net
If u mess around
ye
The "texture string" is just a link to mojangs server
Ah u little... alex
I am not little D:
is simple then adding another plugin to the server which will annoy the end user

my ID says I'm 185cm but it's wrong
no I'm a bit taller. they just copied over the value from when I was 15 all the time when I got a new ID
"are you still 185cm?" "idk" "ok then I'll just copy it over"
like that
My id says 180 but im actually a 2m
The height is pretty useless anyway
how do i check if someones holding nothing
No one checks 💪🏻
Get theirs equipment and check their hands
Their main hand will be air, the offhand will be null
is it just item in use with material type Material.AIR?
Player -> PlayerInventory -> getItemInMainHand() / getItemInOffHand()
thanks
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/EntityEquipment.html#getItemInMainHand() both getItemInMainHand and OffHand are NotNull so they should be AIR
declaration: package: org.bukkit.inventory, interface: EntityEquipment
Offhand is also not null? I could swear this only applied to main hand
at least on EntityEquipment - maybe it's different on PlayerInventory or sth
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/PlayerInventory.html#getItemInOffHand() also NotNull
declaration: package: org.bukkit.inventory, interface: PlayerInventory
yap
I always just check it like this
/**
* Checks if an ItemStack is null or empty (empty = amount of 0 or if the type is air)
*/
public static boolean isNullOrEmpty(@Nullable final ItemStack itemStack) {
return itemStack == null || itemStack.getType().isAir() || itemStack.getAmount() == 0;
}
int m = 0;
IBlockData[] materials = new IBlockData[]{Blocks.fJ.getBlockData(), Blocks.jR.getBlockData(), Blocks.jY.getBlockData()};
private IBlockData nextMaterial() {
m++;
if (m == materials.length) m = 0;
return materials[m];
}
private void placeBlocks(Block first, Set<FallingBlock> set, boolean b) {
set.clear();
for (int i = 0; i < 7; i++)
for (int j = 0; j < 7; j++) {
b = !b;
if (b) return;
Location l = Tools.getAsLocation(first).subtract(0, 0.1, 0).add(i, 0 , j);
Main.debug.debug(l);
EntityFallingBlock fallingBlock = new EntityFallingBlock(((CraftWorld) first.getWorld()).getHandle(), l.getX(), l.getY(), l.getZ(), nextMaterial());
((CraftWorld) first.getWorld()).getHandle().addEntity(fallingBlock);
for (Player player : Bukkit.getOnlinePlayers()) ((CraftPlayer) player).getHandle().b.sendPacket(fallingBlock.getPacket());
FallingBlock fB = (FallingBlock) fallingBlock.getBukkitEntity();
fB.setHurtEntities(false);
fB.setDropItem(false);
set.add(fB);
}
}
So i try spawning a falling block using this, the location where it spawns is correct but i never see it
Why do you need nms for this
to set a custom material
?
I've tried everything and I keep getting this error:
[21:28:02 WARN]: [NeoPerformance] Error loading configuration into class: Can't construct a java object for tag:yaml.org,2002:com.neomechanical.neoperformance.config.PerformanceConfig; exception=Class not found: com.neomechanical.neoperformance.config.PerformanceConfig in 'reader', line 4, column 1: performance_tweak_settings: ^
this is the function that loads the yaml file into the class ```java
public <T> T loadConfigIntoClass(Class<T> targetClass) {
try (InputStream inputStream = plugin.getResource(configFilePath)) {
if (inputStream == null) {
NeoUtils.getNeoUtilities().getFancyLogger().warn("YAML file not found: " + configFilePath);
return null;
}
Yaml yaml = new Yaml();
T configObject = yaml.loadAs(inputStream, targetClass);
if (configObject != null) {
return configObject;
} else {
NeoUtils.getNeoUtilities().getFancyLogger().warn("YAML file does not represent the expected class: " + configFilePath);
return null;
}
} catch (Exception e) {
NeoUtils.getNeoUtilities().getFancyLogger().warn("Error loading configuration into class: " + e.getMessage());
return null;
}
}```
I've tried including the class stated into the build, even checked it it was there with archieve, and it was
Why don’t you just extract it with the supplied methods
Any reason why you dont use spigots yml configuration lib?
It was getting messy, I wanted a nice clean class to store all my configuration data
You can do that with spigots api. Just let it implement ConfigurationSerializable and you can throw the entire class into your config file
Just make sure to follow one of the deserializing methods on the javedocs
Huh
well im assuming you mean 'throw the entire yaml file into the class'
if for some reason you want to go the route you were trying, you would want to use something like java.util.Properties
just fyi
no reason to do it the way you were trying to and will lead to a lot of issues lol
public final class Config {
private static final Properties properties = new Properties();
static {
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
properties.load(loader.getResourceAsStream("com/example/config.properties"));
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
public static String getSetting(String key) {
return properties.getProperty(key);
}
// ...
}
This is for loading it into a map, I want to throw it directly into a class
you need a map otherwise how you suppose to read the stuff?
my example above with the old fashion way even puts it in a map as well
Let me write you an example
I'm trying to replicate this artcle: https://www.baeldung.com/java-snake-yaml
4.4. Nested Objects and Collections
thats pretty much what I want
And what I'm doing
all of that is builtin to spigot if you just use ConfigurationSerializable
I can't find what you are talking about
All I'm seeing is reading it into a map
which I already have, but don't currently require
Yaml contents->Class
MyCustomObject myObject = plugin.getConfig().getSerializable("my-object", MyCustomObject.class);
public class BaseConfiguration implements ConfigurationSerializable {
private int someInt;
private String someString;
private boolean someBoolean;
@Override
public Map<String, Object> serialize() {
Map<String, Object> mapping = new HashMap<>();
mapping.put("this.is.some.int", this.someInt);
mapping.put("this.is.some.string", this.someString);
mapping.put("this.is.some.boolean", this.someBoolean);
return mapping;
}
public static BaseConfiguration deserialize(Map<String, Object> mapping) {
BaseConfiguration config = new BaseConfiguration();
config.someInt = (int) mapping.get("this.is.some.int");
config.someString = (String) mapping.get("this.is.some.string");
config.someBoolean = (boolean) mapping.get("this.is.some.boolean");
return config;
}
}
If you want to be fancy then you could use reflections for serializing everything and just using the field names as keys.
I would like to note that the version this article is showing is actually outdated. The article is demonstrating with snakeyaml 1.21 latest spigot versions are using snakeyaml 2.2
there is significant differencees between snakeyaml 1 and 2
I'm coding for 1.8
so thats not an issue
@tender shard Why do you not have a config blog
well it is, but it isn't
then there is going to be stuff missing I assume in terms of the api for configuration stuff that is being shown
just don't know which stuff will be missing lol
This impl enables:
FileConfiguration configuration = ...;
// save a BaseConfiguration to the config.yml
BaseConfiguration baseConfiguration = new BaseConfiguration();
configuration.set("base", baseConfiguration);
// load a BaseConfiguration from the config.yml
BaseConfiguration loadedConfiguration = configuration.getSerializable("base", BaseConfiguration.class);
because the javadocs already explain everything perfectly imho lol
Apparently not lol
Is this how the API actually functions or is this how they expect me to create a class with config contents?
oh just saw your other message
mb
actually its still a bit unclear
there seems to be more effort in this approach
More effort compared to what?
simply using snake to loadAs the config into a class
okay, maybe we could step back and just discuss whats wrong about my current approach
because I can't actually see anything that will help from spigots api
- You are hiding important information with your try-catch because the stack trace is thrown away
- The config file probably contains
!!com.neomechanical.neoperformance.config.PerformanceConfigat the beginning, which is a class that was not found on the classpath
I was under the impression that loadAs made the !! portion of the config file not neccessary
I have experimented with both, it doesn't really do anything
And for 2, unless I'm mistaken, it being present in the jar file means it is included in the classpath?
Depends on the classloader being used
Well i did specify to include it like this:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<includes>
<include>com/neomechanical/neoperformance/config/**</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
where the class is in config
and the error still continued

I'm guessing the knowledge I'm lacking on what a classpath actually is might be starting to cause confusion for both of us
I thought it just meant the class is in the jar file
if its not there, then error, class not found
so surely including it would have fixed that, but it didn't
Im currently doing some reasearch on snakeyaml and it might be a problem with spigots classloader
give me a few
Open your jar and see what classes are there.
But if your own compiled sources are not present then your entire plugin would explode the moment spigot starts up.
Thats obvious
I just don't understand how it has the gaul to say class not found when its clearly included
Add a
try {
Class.forName("com.neomechanical.neoperformance.config.PerformanceConfig");
// log message here
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
Right before you load the config. Im pretty sure that it will be found.
[21:59:07 INFO]: [NeoPerformance] Class found [21:59:07 WARN]: [NeoPerformance] Error loading configuration into class: Can't construct a java object for tag:yaml.org,2002:com.neomechanical.neoperformance.config.PerformanceConfig; exception=Class not found: com.neomechanical.neoperformance.config.PerformanceConfig in 'reader', line 4, column 1: performance_tweak_settings: ^
hmmmm
I'm getting mixed signals here
Alright, remove your weird logging and send the entire stack trace then pls
Sounds to me like snakeyaml attaches to a different classloader. But we will see.
Do you use the maven shade plugin in your pom?
wait no, I copied code from the library and put into my main plugin and it performed the same, so no
let me check

what?
👀
Alright delete the maven-jar plugin then.
And show your entire pom
And tell me exactly the steps you use to compile while you are at it
how would I track when the player enters the end portal from inside the end?
So i run clean package for the parent module
why did you disable the dependency-reduced-pom.xml?
A library told me it was neccessary
what
Many people who are using the maven-shade-plugin commonly set to false for reasons beyond my grasp. This is generally a bad idea, as it can lead to problems if you’re writing a library, and has absolutely no advantages. Here’s a rule of thumbs: If your project shades dependencies, it should create a dependency-reduced-pom.xml. The...
doesnt have anything to do with your issue though
Okay I'll delete that
Alright sounds good. And you dont shade snakeyaml yourself as it looks, right?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerChangedWorldEvent.html
i think this should work
declaration: package: org.bukkit.event.player, class: PlayerChangedWorldEvent
I did at one point, but currently I do not
check the dimension they're coming from with event.getFrom()
also working on the stacktrace still
What is the reasoning behind this?
compiling my library
it looks nicer
I also heard there can be conflicts
from an anvil gui library
haven't had any issues with it
Isnt that a path in your own project?
That could very well be a problem
stacktrace: https://paste.md-5.net/acogumayer.md
But regardless its a very weird approach to relocate your own path inside a sub-module instead of simply renaming the path
the stacktrace doesn't really help much
something about a constructor
do i need to add a constructor maybe?
Remove the relocation of your own path and try again.
Im kind of confused on your paths names btw.
You now have
com.neomechanical.neoperformance.config
and
com.neomechanical.neoperformance.neoconfig
Is this wanted?
Every class implicitly has a no-args constructor.
And snakeyaml has its own class named Constructor which is something different
I'll remove the relocation and test it
thought you said you were making this for 1.8?
Omg paper banned
1.8 up
if that is the case, why are you testing it on 1.20
Literally everyone is using paper, we can't keep this up lol
you need to first start with 1.8, also I already stated that the modern versions use snakeyaml 2.2 which there is a significant difference from snakeyaml 1.21

so, you need to first start with 1.8, then work your way up to where snakeyaml versions change
and then you will need some submodules to handle that difference
okay ill test 1.8, let me boot up the toilet server
Is it cooled by toilet water?
water cooled, nah I just took the side panel off and put a big fan there
Hmm, you would probably need to add some ventilation or keep the water running all the time
could always go with freon
what if we did like a hvac system
but for your pc
I think the power draw might be a bit higher than the pc's draw though
I have put a freezer compressor in a computer case before and cooled it with freon 🙂
Did u jelly the socket
the best compressors to use are the ones from those old deep freezers
yes, you have to
idk dude fixes AC units for a living he might have something beefy
otherwise the condensation will just kill the cpu XD
Too messy for me tbh
I forget what I used, but it doesn't make a mess
On some cpus
not really, my point was to code against 1.8 and the version that 1.8 to I think 1.14 use the same snake yaml versions
well it wasn't a waste of time since now we know that
but still
it feels pointless even if it isn't
well I tried telling you this a while back XD
hear me out
what if you parsed stuff manually instead of using ConfigurationSerializable and avoided obscure issues

tbh I just got out of bed and have no context other than config bad
and something something classloader .properties file
I gave them an example of using Java properties
yikes what the fuck
i might just do what i was doing before
lately I've been doing something similar to bungee's config system where it's just a Map<String, Object> wrapper with multiple loaders
something about getting the config keys with strings feels icky
here's more context: "ConfigurationSerializable also bad"
Im back. Idk, just pipe int into Gson. It serializes you everything.
Translation from json to yml should be easy afterwards
but I think this just might be a case of over complicating something that doesn't need to be overcomplicated
so you can load json, yml, toml etc and use the same logic
is it just me or is it a bit tacky to do use get by string for config values?
the class just felt better
most everyone just uses the api to get the values they want
there is like no difference performance wise lmao
what if you just made a class that represents your config file and you just read the objects and had a bunch of getters 🙄
you are the one that chose to be different from everyone else XD
the other two methods you would have been done with it by now 😛
maybe you can settle with the measly config.getString, but I want something different
If you are half decent with reflections then you can write your own little class -> yml serializer in no time.
Also lets you add some cool features yourself. Something like this would be nice
public class BaseConfiguration {
@ConfigPath("some.path")
@ConfigComment("This is a comment")
private String someString;
}
just use sponge configurate
or some fucked config enum like I've seen some plugins do
lol
ffs, the pain of doing this is more than just using getString
im going to just do that
gotta love intellij's recent projects tab having alzheimer's
sorry for wasting your time with this lol
but thank you
any reason why this is being spammed

also, when it comes to config properties file stuff, relocating tends to sometimes break them
if that is of any consolation since I noticed somewhere above you were relocating one of your own modules
I had to relocate it, after unrelocating im getting errors
its also a plugin
Ive done this automatically with Gson, Jackson, Jackson-yml-databind, spigots api and reflections, manually with reflections.
There are a ton of ways to tackle this and you chose a decade old snakeyaml version. This can def be done in a relaxed way.
which i have installed
Lol
pretty much the feeling I have when I am point out the outdated snakeyaml version they have to target, and again lets not forget that somewhere in the versions the snakeyaml version changes where everything is almost completely different
so would you recommend I just get a map of the config contents and use that?
At work we just use https://paste.md-5.net/apafebaxis.java and read stuff manually
you did mention that before
this would probably be better as you wouldn't have to worry about the dependency version issue
As you are on 1.8 i would just use Gson (which spigot provides) and then serialize the class that way.
Probably map it to yml afterwards.
use Gson for what? can't I simply dump it into a map and call it a day?
that's what gson does
well
Kinda
It converts to a jsonobject which is a glorified LinkedHashMap
type deal
hmm
Gson lets you do this right out of the box.
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
File file = new File(...);
// Write to file
BaseConfiguration config = new BaseConfiguration();
String toJson = gson.toJson(config);
Files.writeString(file.toPath(), toJson);
// Read from file
String json = Files.readString(file.toPath());
BaseConfiguration loadedConfig = gson.fromJson(json, BaseConfiguration.class);
Without you needing to implement anything.
so gson.fromJson is gsons answer to loadAs?
problems may arise when you want to immediately get, for example, colored text or change the structure when loading text
I think for this reason it’s better to just get everything through the constructor
If you mutate your data, loaded from a config file without keeping the original, then you have a serious design problem.
And you can do all of that with Gson by creating a custom TypeAdapterFactory that can map you all the data in the world.
Doesnt matter if you want to replace colors in Strings or whatever.
one of us idiots should implement a yml gson thing
I'd name it ymlson but it doesn't make sense
ymlG
...
why G
if it's not made by google
and the code is not gangsta
how about BYML
Because it's bukkit and bad
whyml
sure
I'm thinking of having completely overengineered parts
and completely missing the basics
Gson is made by google, and G for gson 🙂
Which is a question everyone should ask when they see this format
file.bukkit
stuff like number rounding strategy
so I can tell if reading an int from 1.6 rounds it, floors it, ceils it or just throws an error
lol
who needs comments anyways
self-commenting code bro 
Convert it to a String with legacy chat coloring §5 1.5999999
and throw an UnsupportedLookAndFeelException
lol
let me note this down
How do I check whether a certain player sent a command? I want to check if the player with the name "testingplayer" ran it.
public void Clear(CommandSender sender){
if(chests.size() == 0){
sender.sendMessage("There are no blocks selected.");
return;
}
if(sender.getName().equals("testingplayer")){
sender.sendMessage("Only testingplayer may use this command.");
return;
}``` Would something like this work? I can't test it right now but it seems to make the most sense
onCommand has a sender, you would check that sender is an instance of player, if it is, that is the player that executed the command
Should work
unless you wanted to check for any command in which case there is an event
Yeah but I want to check for a specific player
not any player
Alright thanks 🙂 Been a while since I did any programming
if(sender instanceof Player) {
Player player = (Player)sender;
if (player.getName().equalsIgnoreCase("Player name"){
//do something
}
}
Go with uuid instead
their name isn't going to change while they are on the server
💪🏻
but ideally you would pull the name from UUID ahead of time though yes
what if I bought the test.com domain
and had like a huge email server just logging all the data
I already check if it's a player somewhere else though
Gdpr coming for you
you asked in how to check for specific player, this is how you do it
I mean yeah but if ppl send me email
email I shall receive
log if for like a year or two
Yeah but the "sender instanceof Player" isn't necessary for the part I'm doing it, because I already checked if it's a player somewhere else, right?
Before running this I already checked if it was a player or commandblock
or smth else
only players are allowed to run it
Depends on how you checked
idk, I put it there so you know you should check to make sure sender is indeed a player
and not assume because console could have executed the command
and console isn't a player
there was something about a non-console non-player command sender
something something remote
entities can execute commands and so can command blocks
don't command blocks just act as the console
/execute moment
declaration: package: org.bukkit.command, interface: BlockCommandSender
With the command block, it actually has coordinates and stuff
oh fun
can't wait for that 1 plugin that casts to ConsoleCommandSender to break
Might need to actually add this functionality to my skyblock core
declaration: package: org.bukkit.command, interface: CommandSender
the amount of platform-agnostic stuff I'm doing basically means I'm rewriting bukkit lmao
LeashHitch
ironically BlockDisplay is in there, didn't think it would be something sending commands
oddly specific
CommandBlockDisplay
whha entity can do command??
yeah lol
Can /execute execute stuff as entities
Whats the difference between compiling and packaging the plugin?
Doesn't compile only make class files and package a jar? Or something like that
correct
clean is rm -rf target
compiling doesn't mean a jar is created, just that the classes are made in the structure you see in IDE
package, puts that stuff into a nice jar
also, it isn't necessary if using maven, to call compile and package
you can just call package, as it will include compiling as that is a lifecycle lower then it
Should I mvn clean before packaging 🤔
depends on what you are doing
most times no
as that prevents maven from being able to use cache
Can cache be bad
however, some unique project setups require clean building though
yep, can cause issues in some cases
my HoloAPI project can only be built using clean builds
can't use cache for it
Why is that so
because it does post processing stuff that if there was a cache it gets in the way and grabs the wrong stuff
Makes sense
I'm so stuck on what to do now lol, he was talking processing with gson, but i thought snake had a map option too
public Map<String, Object> getConfigAsMap() {
try (InputStream inputStream = plugin.getResource(configFilePath)) {
if (inputStream != null) {
Yaml yaml = new Yaml();
Object object = yaml.load(inputStream);
// Check if the result is a map, and cast it accordingly
if (object instanceof Map) {
//noinspection unchecked
return (Map<String, Object>) object;
} else {
NeoUtils.getNeoUtilities().getFancyLogger().warn("YAML file does not represent a map: " + configFilePath);
return new HashMap<>();
}
} else {
NeoUtils.getNeoUtilities().getFancyLogger().warn("YAML file not found: " + configFilePath);
return new HashMap<>();
}
} catch (Exception e) {
NeoUtils.getNeoUtilities().getFancyLogger().warn("Error loading YAML file: " + e.getMessage());
return new HashMap<>();
}
}```
Changing a plugin to use CustomModelData?
Just to clarify, there is nothing wrong with using FileConfiguration.getWhater throughout my project?
is it perfectly acceptable, no loading it into a class or setting a bunch of variables in another class needed?
Well
Ideally
You maintain single responsibility and do your config stuff on your config class
An easy example is to just
public class MyConfiguration extends MyAbstractConfiguration {
private final int interval; // something random
private final String name;
public MyConfiguration(JavaPlugin plugin) {
super(plugin);
FileConfiguration config = super.getConfiguration();
this.interval = config.getInt("interval", 123);
this.name = config.getString("name", "joe");
}
public int getInterval() {
return this.interval;
}
public String getName() {
return this.name;
}
}
type deal
this gives me an idea, give me a second
So you can later
int interval = myConfiguration.getInterval();
For data objects, I'd say it's reasonable to have a constructor with a ConfigurationSection
public class MyPersonClass {
private final String name;
private final int age;
private final int phone;
public MyPersonClass(ConfigurationSection section) {
this.name = section.getString("name");
this.age = section.getInt("age");
this.phone = section.getInt("phone");
}
get...
}
So you can then load objects and such
More advanced config work may involve a bunch of interfaces
I’m getting this error in my console can someone help
11.11 11:52:51 [Server] WARN You specified a resource pack without providing a sha1 hash. Pack will be updated on the client only if you change the name of the pack. could someone explain this
When you set a resourcepack you should hash it with the sha-1 algorithm
So that when you send the resourcepack (and its name and hash) the client can compare the hash for changes
Rather than just checking the name
And i could separate it into multiple different config classes according to the different nests in the config file for simplicity?
Sha-1 is one of many hashing algorithms
Yep
okay now we are talking
You indicated a resource pack but did not include a sha1 hash. The pack will only be updated on the client if the pack's name is changed.
can you help me like set it up
oh so how do i add a hash
and is it just this #
wait i’m lost

my resource pack isn’t a file it’s a link
a sha-1 hash
Are you aware of the concept of a hash
Alright so basically a hash is just a (usually one-way) short numerical representation of data
It can be lossy and have collisions (two inputs produce the same output)
The idea is that if any of the contents change, the hash is not the same
So you can send the hash for both files and see if you have the "same" files by just seeing if the hashes are the same
You should hash your resourcepack and toss the hash in your config or whatever
With code you just
public byte[] createSha1(File file) throws Exception {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
try(InputStream fis = new FileInputStream(file)) {
int n = 0;
byte[] buffer = new byte[8192];
while (n != -1) {
n = fis.read(buffer);
if (n > 0) {
digest.update(buffer, 0, n);
}
}
}
return digest.digest();
}
wait who's the idiot that's not closing fis
i’m so lost right
digest.digest()
there we go
i go into my servers config files
and i’m looking at resource pack and it’s got a link in it
A link to a file
Pretty sure mcpacks provides hash
if you have no hash, clients will update resourcepack only if name changes
If you DO have a hash, clients will update the pack always when the pack changes, regardless of its name changing or not.
You are in a development channel 🙂
For server setup help, visit #help-server pls
Yeah I was getting that vibe
Modpack
so in my resourcepack config i just have this in it https://www.dropbox.com/s/6oflxpd8rxi6wfq/novaprisons.zip?dl=1
so whats wrong with it
Nothing
upload ur pack here you get a hash: https://mc-packs.net/
okay so what do i do with it
That's not even an error
but its not working anymore so it must be breaking it
toss it on your config or something
when i log in i say yes to the resource pack but now nothing actualy shows
toss it where
@quaint mantle as smile said, this channel is not the right one, go to #help-server
oh can i not just finish this convo here
no
In the wrong channel tho
it doesn't matter, you went to the wrong channel in the first place...
lol no
Could anyone please have a look at my thread?
https://discord.com/channels/690411863766466590/1172869870157828146
Nobody here is paid to give support
i never stated that did i
he was helping me
then conclube said wrong channel now man is gone
just drop it
this acceptable?
I'd rather load it on the constructor tbh
why
If you need help ask for it on the appropriate channel
Rather than coming on the wrong channel, asking for stuff, fighting the unpaid staff and dm'ing the one guy that gave you a pointer
ohh fairs
does anyone know how I could remove the player death animation?
if there's a way without packets that would be preferable
What version?
1.19.4
Why the heck is this giving an error?
Material material = Material.matchMaterial(matcher.group(1));
int model = (groupCount == 1 ? 0 : Integer.parseInt(matcher.group(2)));
if (material != null) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta().setCustomModelData(model);```
All I want to do is set the custommodeldata of 'item' to 'model'
You could just use the doImmediateRespawn gamerule if you want instant respawning
heh?
wdym
oh
But then how do I fix it
You can't assign ItemMeta to void
So I just remove the ItemMeta meta = part?
if (material != null) {
ItemStack item = new ItemStack(material);
item.getItemMeta().setCustomModelData(model);```
...
I'm intentionally not spoonfeeding the answer here
I'll let you think about the problem
Makes semse
I get why you're not spoonfeeding me, but now you're saying I can't set something to void, so I should set it to void, and then I shouldnt just do anything at all
Get copy of item meta -> set model -> set meta back to itemstack
There we go
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(model);
item.setItemMeta(meta);
Yeah like that
Why does some of my *perfect * code get highlighted?
hmm
yeah
You have to check parseItem for null, not item
If you do Something something = new..., it will never be null
Just fyi
Can I do this?
ItemStack item = new ItemStack(Objects.requireNonNull(parseItem(args[3])));
Wouldn't that still give an exception
I feel like that will just cause more problems
yeah
Material m = parseItem(...)
if (m==null) return false;
Itemstack item = new Itemstack(m);
Yeah I just got that too, but I'm not sure if I can just return false
Well depends of context, but I just refactored your code a little
Depends of what u want to do
Well, the function this code is in is in onCommand
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {.... the code Im showing you ....}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
.... code
switch (args[0]) {
case "add" -> {
if (args.length == 4) {
// convert args[1] to particle
Particle particle = validParticles.contains(args[1].toUpperCase()) ? Particle.valueOf(args[1].toUpperCase()) : Particle.ASH;
// convert args[2] to int
int cooldown = Integer.parseInt(args[2]);
// convert args[3] to List<ItemStack>
List<ItemStack> items = new ArrayList<>();
String[] itemStrings = args[3].split(",");
for (String itemString : itemStrings) {
var m = parseItem(args[3]);
if(m==null) return false; // Can I return false here? -------------
ItemStack item = new ItemStack(m);
items.add(item);
}
ChestObject chest = new ChestObject(false, blockLoc, particle, cooldown, items);
pHandler.AddLoc(chest, sender);
return true;
}
sender.sendMessage(ChatColor.RED + "Incorrect usage! Correct usage: /sc add [PARTICLE] [cooldown] [items].");
return true;
}
.... more code
}
I feel like I should just break instead of return false
A break in a for loop just goes to the next argument right?
or does the break react to the switch?
return true stops the execution, return false does the same thing and sends the usage
break executes the code after the switch statement
if that makjes sense
do what you need
ig yeah break reacts to the switch statement
I need to go to the next argument in this for loop, if m == null
for (String itemString : itemStrings) {
var m = parseItem(args[3]);
if(m==null) return false; //????
ItemStack item = new ItemStack(m);
items.add(item);
}
Ill give it a try, thanks!
Now, one tiny last thing, why is setCustomModelData highlighted?
I mean, 'model' can't be null
and meta also can't be null right? Because the meta is from the material itemstack, which isn't null
can
I think meta can only be null on Air or something like that
So I should just ignore it?
Sure but I'd advise a null check in case you parse an item that happens to be air
You think it can never happen
If this is pulling from a config or just some arbitrary string, you can't ever guarantee that it won't happen
There's no harm in throwing this in for the sake of being safe:
if (meta == null) {
return item;
}```
Unless an admin tries fucking with my plugin, aka says one of the player rewards is air, it can never happen
Which event is detecing a Player riding on a horse?
I am sure there is other instances where meta can be null
according to the javadocs it is nullable
therefore not guaranteed to not be null at some point lol
It can be null when air, cave air or void air
Iirc any item will get a meta created if it isn't there, besides air. Or some stuff like that
yes
since its nullable, what happens if something removes the meta? o.O
It will be created
but that technically means there is a period in where its possible for it to be null right?
"get the 'vehicle' the player is riding and check if the entity is an instance of Horse."
- some guy on bukkit.org
Probably not, I'd guess it does something like if(this.meta == null) return new CraftItemMeta() or whatever
one day I will have some kind of setup where I can just randomly test these kinds of things
I dont think theres an event for it
declaration: package: org.spigotmc.event.entity, class: EntityMountEvent
Well, if you get that, invite me to look at it then lol. I wanna see if you can do stupid stuff
this is how holoAPI became a reality and some other stuff
HoloAPI relied on a bug in where a horses age was set to negative
it made the horse flip upside down and turn invisible but the name tag was left visible
Lol what
Is there a way to simplify this? I feel like I'm overdoing it
lol arrow
&& me like
then out of nowhere mojang decided they wanted to patch this in 1.8 and many people got upset. So that is how we got armorstands that could turn invisible so that holograms could continue existing. And now we got Display Entities and Text
defo make a method to get one of those random messages
that doesnt work
Why
You should do stuff to craftbukkit
Alright, but it doesnt solve my initial question
now you know where Holograms came from or how it was invented. And it was some person who found the bug randomly messing with minecraft data. Me and 2 other devs just took this and turned it into a plugin
You don't need 3 times else with the same thing
if (meta != null && meta.hasDisplayName() && !meta.hasCustomModelData()) {
p.sendMessage(...);
} else {
p.sendMessage(...);
}```
Yes
Can I fuck with cb
I have a question is /mute <add/remove> <player> if add <duration> <reason> or /mute <player> <duration> <reason> and /unmute <player>
if((item.getItemMeta() != null) && (item.getItemMeta().hasDisplayName()) && (!item.getItemMeta().hasCustomModelData()) {
p.sendMessage("You found " + item.getItemMeta().getDisplayName());
} else {
p.sendMessage(LootMessage[r.nextInt(LootMessages.length)]);
}
What
I pressed enter by accident
noo call getItemMeta() 4 times
😭
Save it to a variable
oh thats a good one actually
could further be reduced if we just make a convienient variable for the itemmeta calls
thus removing the whole item.getItemMeta()
ItemMeta meta = item.getItemMeta();
if((meta != null) && (meta.hasDisplayName()) && (!meta.hasCustomModelData())) {
p.sendMessage("You found " + meta.getDisplayName());
} else {
p.sendMessage(LootMessage[r.nextInt(LootMessages.length)]);
}
Why are all the things in the if block surrounded by brackets
to use multiple && or || it is necessary so that java isn't trying to compare them to each other
idk, I have always done it that way, never had issues. Always had issues when I never did it that way lmao
I guess they might have fixed that in java or changed it so maybe now its just preference?
not entirely sure
lol
anyways I think its pretty compact now though
my one free spoon until whenever I decide to be kind enough to give another free spoon
What you could do is turn it all into 2 lines, in theory
true && (false && true) || (true && false) xd
yeah I am not doing lambda's
p.sendMessage(statement1 && statement2 ? "You found blabla" : LootMessage[...]) this kinda stuff
Doesn't look very good, but very compact
I love those things, they made my life was better when I figured out they were a thing
lol
it will look ugly for his case, too long
You can always indent
I thought the goal was for compact, not prettiness
yes but for me, i won't do it
I would do that 100%
guys if i want to save stats on database it's better to save it on hashmap first then transfer to database?
Yes, having a cache is good
What kind of stats
like kills, rank name
Although if the stats don't change super often you can also just send them to the database
What is rankname? Is it based on kills?
the stats will change on every kill
yup
i think i have problem here
right?
Then why do you save it? Just saving kills should be fine
ohh
wait
but i don't want to transfer directly to database
first save on hashmap then if player leave from the server transfer to database
is that right?
Sure
yes that's correct
For something like this, should I use a List in a dictionary, or an array in a dictionary, or something completely else?
CUSTOMITEMSDATA{
item : {custommodeldata, displayname, description},
item2 : {custommodeldata, displayname, description},
...
}```
I saved all that data somewhere else, and want to know the displayname and description in a different part, where I already know the item and custommodeldata
Technically item and item2 can both be white_dye, but have a different custommodeldata.
Make a holder class that contains all the data for a given entry
And use that as the value in your map
Whats a holder class and a map
Also, Ill be using a seperate file that contains this data, seeing as it's much better for what I'm doing
A map is the java version of a dictionary
A holder class is just a class the holds data in various fields
hmm
declaration: module: java.base, package: java.util, class: Dictionary
do note I don't advocate the usage of Dictionary as it is obsolete, it was more or less to confirm what Coll is saying is true as it says it right in the Java API Docs 🙂
declaration: module: java.base, package: java.util, class: TooManyListenersException
there is all kinds of stuff in the API that many people just don't know about
I found pushbackinputstream a few days ago, always something to discover
declaration: module: java.base, package: java.util.spi, interface: ToolProvider
for those who might want a better way to invoke command line tools
Compare different mappings with this website: https://mappings.cephx.dev
Im here if you want help me
and i try that and my server crash agaiin
can anyone take a look at this and tell me why im not recieving any message when holding a sword?
?paste
what is the problem with using the discord's built in message to file converter
this is urgent
They’re a pain in the ass to view on phone
Any stacktraces?
There you go
whenever i hold the sword, theres no eerror
That’s good
and i didnt get a catch(Exception e){Bukkit.getPlayer(uuid).sendMessage("FUCCKKKK");}
but there was no error when deserializing
I'm running this every time I need to give an item a previously saved itemmeta. I feel like it's far from optimized though (I wrote it a while ago). The highlighted area shows the file being loaded every time I run this function right? Is there a way to still do the same without having to keep reopening the file, or is this still efficient?
might be easier to put that in hastebin
?paste
ever heard of a for loop
what even is the issue
debug it then
i did
sysout the value after you modify it
i did
this is not a sys out after its modified
theres no difference
System.out.println(...)
Bukkit.getConsoleSender().sendMessage(...)
it does not calculate anything
sys out the value of getNumber then and see if it returns 0 or not
allows you to add a pause point to use the debugger
pauses the server to see the values of stuff or whats happening where without debug statements
let me use it and try again
cant use breakpoints if you dont have a debug configuration setup
oh nooooooooooooooo
i tried everyting
add sysouts then
pls pastebin
my eyes hurt
change language to java
the code hurts my eyes
I cant read message.txt
here you call get number
i know
add a System.out.println(getNumber(helmet, NSKeys.ITEM_DAMAGE_KEY)
its insanely hard to debug this, will take years to figure out whats happening
just write something to console
This is totally unrelated to the issue at hand, but
HypixelSkillCore written by amirparsab90 for the minecraft server iransky
If you're writing software for a server, I would suggest maybe not branding it towards another server 😅
show what you added
wait
you should be panicing now that choco is here
Nah I'd have suggested the same as a Hypixel dev or not 
would you though
ye