#help-development
1 messages · Page 596 of 1
well, but headers are not supposed to have impl
that was joke
comparing c++ to java i actually prefer java, but that doesnt mean i like java
i think the verbose thing is important but it shouldn't be required
well, comparing java to kotlin, it uses like completely different approach
hi, my custom config files doesn't save the .addDefault(). I already made a save method
and it's simplified to the point where it's easier to write, but harder to read/understand
when workin on a big project
addDefault is part of FileConfiguration tho
let me send the code
dont get me wrong, for big projects java is very good
but if you're thinking in a bunch of small tasks, is very annoying
what's the problem
.
is that so hard to copypaste original config code from stash
and just change "config.yml" to your filename
why are you using addDefault tho
?stash
i never found myself in need to use it
to create parameters
just add your config to resources and call JavaPlugin#saveResource
// This is an example.
config = new CustomConfig("mongodb.yml");
config.getConfig().addDefault("mongo_uri", "Your connection uri");
config.saveCustomFile();
How to get the arrow sender, like if arrow damaged player, how i would get the entity that shoot the arrow
public class CustomConfigManager {
private File customConfigFile;
private FileConfiguration customConfig;
public CustomConfigManager() {
var dataFolder = JavaPlugin.getProvidingPlugin(CustomConfig.class).getDataFolder();
customConfigFile = new File (dataFolder, "customconfig.yml");
}
public void saveCustomConfig() {
try {
customConfig.save(customConfigFile);
} catch (IOException ex) {}
}
public void reloadCustomConfig() {
customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
InputStream defConfigStream = getResource("customconfig.yml");
if (defConfigStream == null) return;
customConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
}
public void saveDefaultCustomConfig() {
if (!customConfigFile.exists()) saveResource("customconfig.yml", false);
}
public FileConfiguration getConfig() {
if (customConfig == null) reloadCustomConfig();
return customConfig;
}
}```
copypaste to every plugin
this is 100% original spigot code
customconfig.ymn
with custom word added everywhere
but if yo uwant to create another config with other name?
add more similar methods with configname instead of customconfig, or add parameters to methods
second approach will increase methods complexity but still
thanks ❤️
emm, but that is for a single file
alr, adding 2 specially for you
public class CustomConfigManager {
private File customConfigFile, localeFile;
private FileConfiguration customConfig, locale;
public CustomConfigManager() {
var dataFolder = JavaPlugin.getProvidingPlugin(CustomConfig.class).getDataFolder();
customConfigFile = new File (dataFolder, "customconfig.yml");
localeFile = new File(dataFolder, "locale.yml");
saveDefaultFiles();
}
public void saveCustomConfig() {
try {
customConfig.save(customConfigFile);
} catch (IOException ex) {}
}
public void saveLocale() {
try {
locale.save(localeFile);
} catch (IOException ex) {}
}
public void reloadCustomConfig() {
customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
InputStream defConfigStream = getResource("customconfig.yml");
if (defConfigStream == null) return;
customConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
}
public void reloadLocale() {
locale = YamlConfiguration.loadConfiguration(localeFile);
InputStream defConfigStream = getResource("locale.yml");
if (defConfigStream == null) return;
customConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
}
public void saveDefaultFiles() {
if (!customConfigFile.exists()) saveResource("customconfig.yml", false);
if (!localeFile.exists()) saveResource("locale.yml", false);
}
public FileConfiguration getCustomConfig() {
if (customConfig == null) reloadCustomConfig();
return customConfig;
}
public FileConfiguration getLocale() {
if (locale == null) reloadLocale();
return locale;
}
}```
where xd
but you need to create more methods each one you need
except saveDefault
yeah, one more save, one more reload and one more get
cuz you don't want to save config if you changed locale
and only need to save locale
does anyone know how PersistentDataContainer#set() is supposed to work with PersistentDataType.TAG_CONTAINER? Since PersistentDataContainer is an interface, I'm not sure what to instatiate to create a new container
what are you trying to do
thats not what im really doing, it the same but not adding more methods each file
set() uses Key and Value
ok cool one sec
trying to use PDC to store a Location, but I want pitch and yaw, so I don't think an int array will work
and there doesn't seem to be an option for double array
write a custom type or use morePDC
to string at least
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
you can serialize location to string like
?paste
oh yeah string would work as a base type. I was trying to figure out what to do since the custom ones need to reduce down to one of the original types
"world;107.0;98.55;290.153;90.0;0.7"
and then use string.split(";");
and build location from the array
should be simple enough. Thanks for the tip!
Location PDC https://paste.md-5.net/janipagazi.java
i'm lost now xdddd
oh yeah, MorePDC has a type for double arrays. It looks pretty lightweight, so I might just use that
MorePDC can just save Locations directly
No need for double array
Locations are configuration serializable
Heyo!
Currently on some version of 1.19.4 and can not update yet
Can somebody check if isKeyboardClick checks for SWAP_OFFHAND on newer versions ?
Seems to me that it should be considered a keyboardClick
oh sweet
public class CustomConfig {
static File dataFolder = JavaPlugin.getProvidingPlugin(CustomConfig.class).getDataFolder();
private File file;
private FileConfiguration conf;
private String fileName;
public CustomConfig(String fileName) {
this.fileName = fileName;
file = new File (dataFolder, fileName + ".yml");
if (!file.exists()) file.createNewFile();
}
public void saveCustomConfig() {
try {
conf.save(file);
} catch (IOException ex) {}
}
public void reloadCustomConfig() {
conf = YamlConfiguration.loadConfiguration(file);
}
public FileConfiguration getCustomConfig() {
if (conf == null) reloadCustomConfig();
return conf;
}
}```
Hello, I need advice
in my plugin i need database system,
At first I was just thinking of doing it this way:
when something needs to be changed -> sql query
but for perfs it's not terrible, what was suggested to me,
create a hashmap which the uid (key) and in value an instance of a class which contains the equivalent of the columns,
then at the start of the server I transfer the database into my hashmap, and all my modifications I make them inside this one, then every 5 minutes I save the hashmap in the database.
Is it a good idea ?
on crash it dies
i always wonder why so many people's servers randomly crash, it has never ever happened to me
is everyone running a 100 player server on a 512mb aternos server or what lol
Lol
but at least it's better than saving changed to SQL from your hashmap on server disable
ive already asked here but it didnt work, how can i increase player swim speed?
its not
sad
ive tried a lot of stuff
Dolphin effect? Does it work for more than 1 level tho?
@quaint mantle
that's still 100% copy of default bukkit code, but for case when you create a file and it's not present in .jar(so it's a super custom config)
up
if you really need it, one way would be to manually apply velocity
would be scuff as fuck and quite laggy for ppl with higher ping
i'd just save the changes directly
It would work very weird, but sounds like the only solution
tried that
didnt work
getReaource() ?
or atleast i tried
Well, sounds like you did something wrong then
so no image of the database in a hashmap? going directly through sql queries does not risk altering performance?
removed, now there is no resource
Or water is fucked
how/what did you try that then ?
I am 100% sure that would work... in some way
this the getSwimSpeed returns 1 and im fast as fck for some reason
and on reload it has to be new YamlConfiguration
what
I assume you're triggering that every tick in which case I am not surprised
onPlayerMove
yeah, exactly
every tick since the player moves when you give them velocity
So just.. give smaller vector
It's a class name, by which you call a static
im so blind, my bad
what do you mean by that, like multiply it by smaller value or what
are your configs present in the final jar or you just create them for random game event?
yeah, that will make the player "swim" slower
is a core plugin idk
?
but i want it faster
like for a server core
A server core?
but you just complained about the player being too fast
well yes, when i multiply it by 1 im very fast which doesnt make any sense
here a core is called a plugin (util) taht manages the base of teh server
I have an error
show it
and i don't have createCustomConfig method in my code
you multiply the direction by 1, direction is a unit vector
You might want to create your own vector from previous position and current position and multiply that one by the swim speed
show code where you instantiate a new CustomConfig
this for example?
Is a new player object created when logging out of the server?
should i use UUID for this?
yes
and you didn't use what i gave you
a player instance only exists as long as the player is online
What is an OfflinePlayer then?
When the player leaves the server, will that object be deleted from the list?
don't call save here
You'll have an invalid player object, basically
you need file.createNewFile() here
yess 🙂
you'd better always use uuids tho
Finally someone that gets it
wdym by create your own vector from previous position and current position like subtract them?
isn't like every developer on YT using STATE for minigame plugin
I assume so
I am not the best with vector math lol
I mostly jsut guess
and what's wrong with an enum
now the file is created but not saved
At work I do something like that
also, you would have to cap the length of the new vector to your swimspeed
otherwise it will increase over time if the multiplier is over 1
well i did this but now im swmming super slow
Start by splitting your logic
so I'm back again... MorePDC lists a "shadowJar" section along with the repository and dependency. I'm assuming this is meant to move the API into the package at build time, but I'm not sure how it works. Is it handled automatically when I run the jar task?
(this is referring to the build.grade file)
Hmmm
guy needs free shadow gradle lessons
Exciting
help him
Anyways a phase is just uhh
a kind of state where you can register listeners and tasks when it starts
cool
and when the phase ends, things clean up and the phase is no longer active
There's also the vanilla mechanics system that lets you disable certain vanilla features dynamically
aren't you developing fucking base to every possible minigame
pretty much
😉
I made TNT tag in like an hour
How should I go about this? I removed our implementation line for sdk and just switched it to only the jvm kotlin plugin and its still included im pretty sure I need to include kotlin for it tow ork (they are all using the same kotlin plugin because we have our projects as modules and they all define kotlin in the master build.gradle.kts not induvidually)
java.lang.LinkageError: loader constraint violation: when resolving method 'void me.nopox.stuff.Serializers.useGsonBuilderThenRebuild(kotlin.jvm.functions.Function1)' the class loader 'Commands-1.0.jar' @5ea86494 of the current class, me/nopox/commands/Commands, and the class loader 'Stuff-Remapped-1.0.jar' @4def2336 for the method's defining class, me/nopox/stuff/serializers/Serializers, have different Class objects for the type kotlin/jvm/functions/Function1 used in the signature (me.nopox.commands.CommandsPlugin is in unnamed module of loader 'Commands-1.0.jar' @5ea86494, parent loader java.net.URLClassLoader @27fa135a; me.nopox.stuff..serializers.Serializers is in unnamed module of loader 'Stuff-Remapped-1.0.jar' @4def2336, parent loader java.net.URLClassLoader @27fa135a)
nvm I found the docs for Shadow
- copypaste entire codebase
- change name to MyAwesomeMinigame
- change game logic a bit
- done
not like i'm going to
why cant i just multiply the velocity, why does it have to be so hard to make bruv
Split your logic up
if not then .normalize()
multiply by some value
and set to player's velocity
boom done
also velocity should work different in water
Location from = event.getFrom();
Location to = event.getTo();
Vector direction = to.getDirection();
Vector difference = from.clone().subtract(to);
iirc
from - to = vector that pulls from -> to
cuz water resistance is much higher
to - from*
to - from = vector that pulls to -> from
it might seem a bit backwards
either that or I'm tripping
you do end - start
to get the vector directing from start to end
thats what i had before
and what was wrong
umm, lower your value
altough the multiplier is 1
with your old code or current code
this is what i understood you told me to do
the one which is suggested to you by guys here
yeah, smth like this
but multiplying by one is not changing anything
How do i check if a player has any of these for permissions?
testPermission1, testPermission2, testPermission3 and testPermission4
so are you too fast with this piece of code or with another
the thing is that the vector is normalized
for loop
and has length of 1
and velocity(according to docs) saying that it's 1 block per tick or smth similar
so you need to multiply by value, which is smaller than 1
try .2 for example(should be 4 blocks per second) which is somewhere on move speed
I dont really understand what you mean
Isnt there a symbole like & or something?
ohh its changing
&& is AND
|| is OR
BUt || dosent work
why for loop just an if statement
if (player.hasPermission(1) || ... )
If statement not scalable if you want to test for 20 permissions instead of just 4
if there are 99 perms
you need a for loop
public boolean hasAny(Player player, String... permissions) {
for(String permission : permissions) {
if(player.hasPermission(permission)) {
return true;
}
}
return false;
}
Simple enough
for (String perm : perms) {
if (player.hasPermission(perm)) {
doYourCode();
return;
}
}```
if(hasAny(player, "one", "two", "three"))
or ^^^
No i mean if i have like 8 permissions and i want to check if a player has any of these 8
make a list out of those 8
and do a for loop
if (!hasAny(player, "myplugin.fly", "myplugin.god", "vault.die")) return;```
joe.mama
was easy lol
if you are doing this in moveevent, don't forget to check if player is in water
I dont get it
So it this right
Player player = (Player) sender;
public boolean hasAny(String permissions) {
for(String permission : testPermission1, testPermission2, testPermission3, testPermission4) {
if(player.hasPermission(permission)) {
return true;
}
}
return false;
}
okay
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
yeah it's learnjava time
Read up on for enhanced loops and vararg function parameters
jearnlava
if(firstItemMeta.hasEnchants() && secondItemMeta.hasEnchants()){
Map<Enchantment, Integer> enchantmentsMap1 = new HashMap<Enchantment, Integer>();
for(Map.Entry<Enchantment, Integer> entry : firstItemMeta.getEnchants().entrySet()){
Enchantment enchantment = entry.getKey();
int enchantmentLevel = entry.getValue();
enchantmentsMap1.put(enchantment, enchantmentLevel);
Bukkit.getLogger().info("Item 1 Enchantment: " + enchantment + " - " + enchantmentLevel);
}
Map<Enchantment, Integer> enchantmentsMap2 = new HashMap<Enchantment, Integer>();
for(Map.Entry<Enchantment, Integer> entry : secondItemMeta.getEnchants().entrySet()){
Enchantment enchantment = entry.getKey();
int enchantmentLevel = entry.getValue();
enchantmentsMap2.put(enchantment, enchantmentLevel);
Bukkit.getLogger().info("Item 2 Enchantment: " + enchantment + " - " + enchantmentLevel);
}
ItemStack resultItem = new ItemStack(firstItemMaterial);
EnchantmentStorageMeta resultItemMeta = (EnchantmentStorageMeta) resultItem.getItemMeta();
int i = 0;
int j = 0;
for(Map.Entry<Enchantment, Integer> entry : enchantmentsMap1.entrySet()){
Enchantment key = entry.getKey();
int value = entry.getValue();
if(enchantmentsMap1.containsKey(key) && enchantmentsMap1.get(key) == value){
resultItemMeta.addStoredEnchant(key, value+1, true);
Bukkit.getLogger().info("Result: " + key + " - " + value);
i++;
i = i + value+1;
}
}
final int enchantmentsDone = i;
final int levels = j;
resultItem.setItemMeta(resultItemMeta);
event.setResult(resultItem);
this.getServer().getScheduler().runTask(this, () -> event.getInventory().setRepairCost(30));
}
Am I missing something? Shouldn't this work?
try explaining what it should do and what it is not doing
Combine enchanted items and get a resulting item past the default limit. Ex. Fortune III + Fortune III = Fortune IV
Can I set a spawn egg's NBT so it spawns for example a librarian villager?
I dont get it..
Does it work for java 8?
declaration: package: org.bukkit.inventory.meta, interface: SpawnEggMeta
i mean yeah technically
2 of the 3 methods are deprecated
it does look ok
but I remember the Anvil gui having some weird problems
Is the debug output as you would expect as well ?
?img
Not verified? Upload screenshots here: https://prnt.sc/
Deprecated
It does, it just happens that you don't know java
Is it possible to send debug info from the server to the client such that it will be written in client log files?
(Obviously you can just send chat messages, which are saved in log files, but ideally I don’t want to display anything on the screen, because it’s debug info)
since you can do
/give @p mule_spawn_egg{EntityTag:{id:"minecraft:villager"}} 1
I would expect spigot to have a way as well
when i changing the gamemode to survival from spectator this happening why ?
@EventHandler
public void onDamage(EntityDamageByEntityEvent e){
if (e.getEntity() instanceof Player damageGetter && e.getDamager() instanceof Player damager){
e.setCancelled(true);
damageGetter.setHealth(20);
damageGetter.teleport(ArenaManager.getTeam(damageGetter).getSpawnLocation());
damageGetter.setGameMode(GameMode.SPECTATOR);
arena.playerDeath(damageGetter);
// after 5 seconds:
for (UUID id : timeTORespawn.keySet()){
int t = timeTORespawn.get(id)-1;
timeTORespawn.put(id,t);
Player player = Bukkit.getPlayer(id);
if (t == 0)
try {
timeTORespawn.remove(id);
player.teleport(ArenaManager.getTeam(player).getSpawnLocation());
KitManager.getKit(player).equip(player,ArenaManager.getTeam(player).color);
player.setGameMode(GameMode.SURVIVAL);
}catch (Exception ignored){}
}
Well I want to store the entity's data like villager trades or sheep wool color
is there a way to know when the player is clicking the space bar?
yeah, the vanilla nbt EntityTag can spawn entity with set nbt
just trying to find a spigot equivalent is probing to be difficult
There is no API for it
jump stat increase if on ground
but I need to also know when in air
you can't jump when in the air so can't detect
this is an annoying problem I got a good approach for
half solution: give player the ability to fly, once they start "flying" the player pressed space
hmm, that sounds like it makes sense
are PDCs on players preserved on death? I remember having to hook into the death event to copy over NBT for a mod a long time ago
actually nvm my solution has nothing to do with your problem
it's just an elegant way of handling spectators
yeah but they have to press it twice
so again, half solution
No, it prints all sorts of errors in the console
Tbh I don't know what half of them mean
for what I'm doing it for it seems to be enough
what is it
wait so you have problems not with logic...
Start with that next time maybe
?paste
send the erros
I want to make like semi flying, like not normal flying, but a little bit, maybe like jetpack or something
Possible?
Here you go: https://paste.md-5.net/ifahuvuqim.pl
well for that sneaking midair might be a bit better, you can control the velocity of player more precisely
tho again, ping is an issue
don't cast to EnchantmentStorageMeta
what is spigot using to colorfully display player joining in yellow? because cmd doesn't support ChatColor colors
normal items can have enchantments so it is pointless
and the meta is probably for enchantment books
EnchantmentStorageMeta is for enchanted books only
So I should just use ItemMeta resultItemMeta = resultItem.getItemMeta();?
yes
I'm not sure if this is the right place to ask the question, but can someone help me resolve this error? Thank you.
not an error, a warning
I replaced spigot-api with spigot because I want to use NMS. So, is it okay if I have this warning?
I understand! Thanks!
can I somehow make my plugin not kick players for flying when they fly too high with my jetpack kinda fly?
or is it about disabling enabling flying on the server?
You gotta disable it on server
everything in my plugin works except the commands
no errors in console
8o7gasfd
i had no permissions
how i can save a text like this into a String:
[{"translate":"a"},{"text":"test","font":"default","color":"#2804f9"}]
from config?
snakeyml does not allow that and shows a lot of errors because of " and more ...
first try surrounding the entire thing with ` `
switch (clickedItem.getType()) {
case GOLDEN_HOE:
closeInventory(p);
new SkillGui(player, "Farming", Material.GOLDEN_HOE).openInventory(p);
break;
case STONE_SWORD:
closeInventory(p);
new SkillGui(player, "Combat", Material.STONE_SWORD).openInventory(p);
break;
case STONE_PICKAXE:
closeInventory(p);
new SkillGui(player, "Mining", Material.STONE_PICKAXE).openInventory(p);
break;
case JUNGLE_SAPLING:
closeInventory(p);
new SkillGui(player, "Woodcutting", Material.JUNGLE_SAPLING).openInventory(p);
break;
case CRAFTING_TABLE:
closeInventory(p);
new SkillGui(player, "Crafting", Material.CRAFTING_TABLE).openInventory(p);
break;
case ENCHANTING_TABLE:
closeInventory(p);
new SkillGui(player, "Enchanting", Material.ENCHANTING_TABLE).openInventory(p);
break;
case BREWING_STAND:
closeInventory(p);
new SkillGui(player, "Alchemy", Material.BREWING_STAND).openInventory(p);
break;
}
why does this code open all the guis?
it opens a gui for each skill defined on this switch case statement
It's also ignoring the fact that you shouldn't close or open inventories directly in the click event
yes i know
why?
The following should never be invoked by an EventHandler for InventoryClickEvent using the HumanEntity or InventoryView associated with this event:
HumanEntity.closeInventory()
HumanEntity.openInventory(Inventory)
HumanEntity.openWorkbench(Location, boolean)
HumanEntity.openEnchanting(Location, boolean)
InventoryView.close()
^^ From Javadocs
why?
results may vary
there should be a reason
i asked why is my switch case statement is executing all the code and got i shouldn't close or open inventories directly in the click event
what is your opinion is it better to make plugin in kotlin or in java ?
Your switch will not be opening all the inventories at once
oh no he mentioned kotlin. Time to die
but it does
but opening inventories in teh client event can have vey random outcomes
why do you think so
impossible
?img doesnt work for me
alternatives?
Not verified? Upload screenshots here: https://prnt.sc/
first follow the javadocs. Do not close/open inventories in the click event.
then where should i do that
but type inference is fine unless you are not trying to get value of that type ?
don;t bother calling close at all as opening one will close th eold.
to open a new you do a runTask#
we can say it is really simple langauge simple to look at read and work with
even if im mnot doing it in the click event?
yes
but whatever leme try again
is there some event for when an item gets destroyed in any way? Cactus, lava, fire, void, whatever
hey does enyone know kotlin?
i'm getting this error: java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics for java 8
and onJoinEvent isn't working
i can give more details as needed
wait until someone sends that command for java docs
?paste
let us see your code
I can visit javadocs myself
well might be because it is not onJoinEvent
yes i hate when they do that to me because i can also visit them myself
problem is, it seems like there is no such event which is not good
how to build directly onto the plugin folder?
ItemDespawn ?
i've tried meny ways to do join event
its PlayerJoinEvent
i tried that one
only when it despawns because of 5 minutes
do you shade the kotlin sdklib or whatever it is
variable naming doesnt matter
I wonder if I can somehow track a certain item on ground
the stdlib
on what events can an item be thrown on ground?
ok
well you can track item that is dropped
well, I need to know when it's dropped
but kotlin is disgusting use java
there is event for when player drops item
i wanted to try something new
Isn't Kotlin like a superset of Java?
what if the player dies? or the item is dropped after destruction of a chest or something?
and it did nothing :
no console error and no message
not sure what to tell you i only know there is PlayerDropItemEvent and you can get item that is dropped and i dont think there would be any problem with tracking that item even if player is dead
for items dropped by destruction or something like that really dont have any clue
you dont register the event
well, that's shit
you can do same stuff as in java you can use same libraries as in java but it is just much simpler
idk if this is how you do it in kotlin but add @fresh templetHandler on the line before you define the onplayerjoin function/method
its there
ask elgarl he might know something about it
I thougt bukkit was full of events and stuff, but in reality, it just has no events I need
and register it in the onEnable method
you should have used ` around the @
Yeah, so why don't use Kotlin? It even replaced Java as the prefered language for android app development
nms probably has it. i mean its the minecraft server code and minecraft contains all of those sooooooo
use nms
I would bet even mojang doesn't need these events
indeed android studio is just letting you use kotlin you have to get to java on other ways rn
i made recently plugin in kotlin and yeah it is quite simple th
but how do i regester it?
also, I'm not some kind of mage to be converting nms stuff to bukkit and vice versa
do you know java
not alot
learn more java first
then how does it delete the item?
i do it in my spare time but i'm not a pro at it
this is how i learn
i play and experement
this is kotlin, you wont learn java by doing this
in onEnable function you should put plugin.registerEvents(this, this)
getWorld().getEntity(itemEntity).delete() or something, idk I'm not a mojang developer
but it should be getServer().getPluginManager().registerEvents(this, this)
so i wanted to check it out
getting support is harder
a lot less people here know it
Yeah, I don't get why Kotlin hasn't replaced Java altogether. Java devs are still among the top earners and Java is still in demand (mostly for legacy/maintenance of codebases though).
but it needs an event to do that
it only needs to be able to track the item, that's it
Many java devs have zero interest in kotlin. It's too close to a scripting language than programming.
well no need for that i mean there is going to be new java update soon that will make java look similar to kotlin and much simpler for learning so yeah 🤷🏻♂️
ElgarL, I've been told to ask you about my problem
problem?
no much difference it is just way simpler rest is the same 🤷🏻♂️
hey now it works, but i'm still getting this NoClassDefFoundError :\
basically, I want to be able to know when a certain item is destructed in any way by the void, cactus, lava or anything at all, but I need to either have an event for when the item is gone or an event for when the item lands on ground and then to track it
It stills compiles to JVM though
that means I can write kotlin code, compile it, decompile it and continue writing in java
not a simple task
I know
you'd do better to think of a different way to handle your item
why do you want to track it so accurately?
first of all if you are trying to learn java by coding plugins dont do it dumb way try to do it right way so you dont have to throw your knowledge in trash once you find out it is not prefered to make listeners and commands in the same class which is also main class of the plugin and second of all is to learn basics before even trying to go and learn plugins as it will make it easier for you
I remember my homie once made a plugin that was like "item dropped by X, picked up by hopper, landed in a chest opened by Y" and it was a shitshow
I need to be able to return it with some cool effect after destruction, making it completely indestructable
you would lose track of it if the chunk unloads
right
which means it will also work as a chunk loader
pdc
That was a respond to ElgarL's comment about Kotlin. If it's still compiled into the JVM, it doesn't matter if it "looks" like a scripting language, it still has pretty much the same performance.
i'm not learning java for the sake of learning java, i'm learning java to make plugins for my own server
if i could write plugins in python my life would be 100 times easier lol
i have passed a java learning session in the past but over the years i kinda forgot it
I never mentioned performance, I said precision
because players still need to be able to give it to each other and also, how is it going to just cancel death?
Groovy would like to have a word with you
why do I always come up with the most complicated shit
Do I need to use maven to build plugins? Cuz Im using my own build artifact
Workign with Spigot Maven is recomended for building
mavern
Okay thanks
and like everything in the project is going fine really but i don't know how to get rid of this kotlin/jvm/internal/Intrinsics issue
like is java ment to have that? or is it ment to be imported into the JAR and isn't?
But it isn't required.
I thought of making it soulbound, but I don't think I can do that in this case
wc.type(WorldType.FLAT);
wc.environment(World.Environment.NORMAL);
wc.generatorSettings("2;0;1;");
world = wc.createWorld();```
https://pastebin.com/UrDJ93DG why am i getting this error?
oh lol it's fine
you still have this error?
or it is fixed already
yah i still have it
so what exactly is the problem
Your generator settings have to be like a json thing
Never use Kotlin for plugins solved.
u use maven/gradle
u shadowed stuff
your mc version matches target
and same for java
i compile from kotlin and in the compiled code i see this
which links to the NoClassDefFoundError
i used maven
Maven plus kotlin must be a nightmare
true
isn't kotlin meant to be used mostly with gradle
hasn't been a nightmare for me honistly
Yes. It's meant to be used with gradle fully
your plugin isn't even working rn
Try to use fat jar
so it is
@paper trout
give me a second
i works until i try to run code that has the intrisics
the pom
So which jar you put into the plugins folder?
wait
the compiled jar, what other jar would i use?
isn't mc 1.16 not supporting java 8
Use shaded or without any suffix
confused what that means
trueee
I've had the same issue my intellij just dies once a class gets over 200 lines which is a nightmare for my gui items which I usually store in enums
Solution buy more ram
and jar-with-dependencies.jar
I have 32 gigs def not the issue
Mine has been freezing too in larger classes
are you actually allocating more to intellij?
this is where the output of the jar goes and i only get one jar file
just having more ram wont change anything
Yeah I tried allocating 4 gigs but then it stopped starting lmfao
I run my intellij with 4gb and it works fine
you shouldnt do it like that
why not?
yea i got 8gb there
that way doesnt build with maven, so you dont shade kotlin
likes burning ram but
I run it with 2GB and it runs just fine.
i also have some custom jvm flags that helped for me
-Xmx8048m
-XX:ParallelGCThreads=4
-XX:+ParallelRefProcEnabled
+PerfDisableSharedMem
I've worked on classes with over 2K lines at a time, 2GB is more than enough.
Help -> Edit Custom VM Options
still no
noob's command executors
with 99 switches
the class that parses all my configs and makes invs out of them is 200 lines at most
Case and point, the BuildTools GUI that we are working on. The form classes are massive.
so should i delete my artifact information and do this?
Do you use wrapper install/package?
?
get better cpu lol
unfortunate :d
Jesus mine lags with 4 gigs and i5 12600k lol
Wtf? I use a 3700X and I have only ever gotten a lag spike once.
My ide's perfectly fine on a 5600x with 32gb ram total
Windows skull
all i have is base intelIj and Minecraft Dev (and Kotlin obviously)
5900x
1080p
Heart attack.
?
Showing neofetch with windows
Nice uptime
breaker hasn't tripped in 45 days
Developer on windows 🪟 😭
Had to restart my server recently 😦
Why not
Linux gaming go brrrrrr
Open target folder there may have big jar.
its kinda my life
Fake dev
Now you gonna try and say that you talk to people and go outside and shit lol
I love being kept from my favorite games because they don't run on linux!!
nah I wish lmao
I do go to the gym
If your favorite games don't work on linuz they're bad games objectively speaking /s
there isn't unless it's in a sub folder
you havent built with maven
Same no wonder I suck ass at development
i litterally just click Build Project
that builds with intellij
xD
on the right of your screen opent he maven tab
then lifecylces
then press package
well that wasn't obvious they are seperate '3'
what that
Imagine paying
oh lmao
checks price
i just built with maven using the package option from lifecycle
use the top one
it's probably my biggest waste of money
true
I have Nitro lol
why
bruh
💀
I had nitro classic but some idiot had to gift me full nitro on a month when I was broke
and nitro basic doesn't let me do the 1440p60 streams I need at work
nice
Just twitch stream proprietary code bro /s

Btw, talking about not gaming...
wait that's not 1440p60fps anyways lol
nice
oh no blud's got 60 hours on csgo
its 1080p
it's working
that totally didn't take like 2 hours of banging my head before asking lol
and 2k hours on hypixel sb :{
still salty they haven't replied to my applications
Hm
you walk to slow
Oh wait, wrong channel lol
Go to #help-server
Should we move this to #general though
nah
probs
this is fine here
not
it's character development
eh ok guess game
nah
valo?
that's not the apex banner
no valo aint on steam
Lets talk about games in #help-development channel 😁
prolly gmod or some degen game
character development
What he said
Destiny 2
yeah I was correct
I used to play minecraft a lot more when I was a kid
Wish I could know, cause I have played a lot of Minecraft
new season banner
I love it, it's the part where my console tells me why I am stupid
the torturing thoughts of what youve done and the pain you experienced while making plugins
I literally know NMS inside out
people at school just used to be like
PacketPlayOut
"yo illusion help me solve this argument"
"can you use a hoe to melt items on a furnace"
only if it's a wooden hoe
yet no one cares about how fucked the scaffolding block is
and how it recalculates its entire structure on any scaffold's block update
why does it burn for 60s
Dawg 💀
you can place a block next to a scaffold and the entire structure re-calcs its integrity
and string doesnt even burn
thats nothing
oh no p_
I had to figure out why my custom block was being destroyed by water earlier
oh, I know. I just wanted to distract lol
nowadays I just do whatever
Turns out any block with noCollision in its properties gets destroyed by water
make minigames or something
you havent experience the pain, the agony the FUCKING WILL TO SLEF DESTRUCT, WHEN YOU CAN DISABLE MONGO LOGGER ON STARTUP EVEN THO YOU SPENT 5 HOURS TRYING
how the fuck do you disable the mongo logger
Cnat*
But why do I get a Null exception WHEN I LITERALLY CHECK FOR NULL RIGHT BEFORE
it does everything but fire exceptions
Hey, oh yea today were gna send ur password, the connection uri everything in the console
But no
were not sending that one important exception
I did manage to disable it once
mongo in a nutshell
Even ChatGPT couldnt disable it
just use a middleware api with a socket connection and secure it
I literally got so bored last night that I wrote this https://www.spigotmc.org/threads/using-influxdb-and-grafana-for-internal-metrics.609971/#post-4608466
I dont use apis
this way you can read/write to mongo without importing the mongo library at all
i meant set it up yourself
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
chatgpt isnt a developer, its just a chatbot that knows a bunch of code snippets by memory
yet it still cant disable MongoLogger
yeah I'm not a fan of that guide
cause i dont think you can, one approach would be self hosting a middleware api but you said you dont want to so idk
fun
🎧
or you could decompile the mongo lib, edit it and recompile it so it doesnt log
💀
pov: hypixel
The Entire console is just fucking Monog logger xD
yeah recompile it however you like man
i hope you are familiar with that unless its heavily obfiscated or sum shit
What would be the best way to check if a player is holding an item when PlayerInteractEvent triggers? 'cause I feel like it could be better
Currently I just get the main hand and check if the value is null or Air
thx
(event.getItem() != null) i think
Bro I've started on this plugin 3 times and I keep wanting to restart 💀 It's so dumb I can't seem to get it "right"
You learn something each iteration
You wanting to restart shows that you've learned something
I think I should just get it fully functioning at this point, though. Dwelling too much over having things perfect will lead to insanity at some point
I think I borrowed too much code from the previous version, though. Some methods have proven to be... quite bad.
Is there anyway to check if a block was broken before in the on block break event?
catch nms packet
what plugin ya making
Me every time I start a project I've redone projects 10 times 😭
Me everytime i restart the same goddam project like 50 times and end up just not doing it
convenient mass single-item storage
It's all basically working it's just that I'm not satisfied with the code lol
so you can save like 50k of one item?
Why are you not satisfied?
is the code not clean?
That doesn't seem too bad, maybe serializing contents. Though you could let mc do that if it's physical
Yeah
Wouldnt it be simpler, to just save the data on the item
PDC
Yeah, simpler but the utilizing the container would be powerful too granted idk the extent to which you can use containers completely server sided
I mean not even using a container
Virtual?
if your displaying the amount of items saved in the mass storage
why not use the metadata
lore**
ur updating it anyway
so why not
It's inconvenient
Lore is bad PDC is gud
it efficient
PDC takes space doe
Lore is simply for users sake
So does lore
That's a hyper optimization
but if you already have lore, why not utilize it?
What if I ever want to change the way lore is displayed?
Much easier to have it stored in PDC in that case
wdym?
PDC more versatile
Easier to retrieve
And a better storage format in the underlying nbt
Like if I have "Stored: 500"
but then I want the number on a separate line
you have to admit tho, lore would be more efficient, even if its inconvenient
So if a player has an item with the first iteration, how do I then update it safely
I have to have a check for that in perpetuity
It's not
Instead of just changing the display style, and getting data from PDC
Parsing takes more computing power than a retrieval from memory
I'm updating the meta regardless, what's an extra operation?
I get the efficiency perspective, but we're running on GBs not KBs
i cant say much about optimization when im currently running a vector calc on every player move even
t
💀
Are you seriously arguing that parsing a stringlist that's visible to the end customer is more efficient than just using an internal data structure?
maybe...
💀
I mean, why read once and write twice, when you could just read once and write once
not to mention that lore has to be parsed from json on every getLore call
cries in inefficiency
lore is not for you to use or compare at all, its just for display and for the client
just use pdc or at least nbt
AnYwAyS, anybody wanna see my epic Entity that is def the best ever created?
same with the displayname
stop speaking in inefficiency, i dont speak that language
Itemstack PDC type when
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
^ Alex already has a neat lib for that
Merge MorePDC with Spigot when
Ask MD :p
@tender shard 
promoting arbitrary formats for itemstacks to API sounds five head
why use pdc, save it in a binary file
And then put the file into PDC!
Yes
or just, stop being lazy and do it yourself :)
?
write complete ItemStack -> YAML converter with all tags
That already exists
ItemStack is ConfigurationSerializable
Is is
Translate it to yaml, translate that to binary, use an encryption key on that, then put it in a pdc
i thought it only did some of the shit, mb
MorePDC uses the fact that ItemStack is configuration serializable stores that
Ah I thought it used a BukkitObjectOutputStream to turn it into bytes
If I change my config.yml file and then restart the server, my changes are being overriden with the config.yml file that was loaded when the server started. Any ideas why this is happening?
Yeah it does that
Take alook at my epic code
yea but bukkit output stream is kinda bleh for writing an item stack 
You can always PR smth better
Iirc paper has a different method
did i just see the word starting with p and ends with r
Dawg I stepped away for a few minutes, what happened 💀
notin
Fr
It's spigot let's do it 
I like Alex's library though if it were to be merged with spigot we'd need to cut stuff out
New spigot license
Any change you make in a fork you must propose as a PR
Or else you die
PacketPlayOutEntityStatus packet = new PacketPlayOutEntityStatus(
((CraftPlayer) player).getHandle(), (byte) 35
);
is this method deprecated in spigot and paper api for 1.20.1?
BLYAT
seems doesn't work anymore
Pr
I mean same in spigot
oh okay then what should I add for NMS?
?nms
is there gradle version for this?
so only maven does work
NO
you can use paperweight-userdev for gradle
BUILDTOOLS
but that gets you all of paper
?
Follow the guide
have i been doing it wrong my entire life
It’ll have you run buildtools to get remapped jars and set up the maven special source plugin
no not at all
but kotlin compiles to jvm compatible bytecode
so does java
Can't you write plain java code in Kotlin?
no
kotlin interoperate java code
but no
they're syntactically different
if kotlin were a superset of java, it'd mean valid java code is valid kotlin code
which is not the case
Oh, I thought that was the case
ye it isn't, keyword, they compile to the same type of bytecode
Like some Python libraries that let you write C code
i dont think C is a superset of Py tho
like, a good example is perhaps json and yaml
yaml is a superset of json since valid json is valid yaml
Yea no worries (:
Definitely the name of the function
definitely not the event handlers not cleaning up
Yea
which was breaking my "WaitForPlayersPhase" as it still had a stray listener that was breaking things
and I thought I had duplicate games
Is there a way to store server-wide data in a Persistent Data Container, or is it better to just put it in a file? The closest thing I could find is World#getPersistentDataContainer(), but I'd rather it not be tied to a world
yeah you should just use a file
Okay so I did manage to send packet using protocol
but now it's just complicated to send other custom item instead of totem when player revives
with my PersistentDataSerializer you can turn any PDC into json and vice versa
so yeah you could just save it to a file
the resulting json is also human readable and not some gibberish
yes, the values don't get saved into the file
whats the best way to make a mob walk along a certain block (wtith turns)
Is there in any way to disable bed night skipping? Like disable x/x players sleeping on right clicking bed.
how can i make a froghead with skullmeta?
i have a skin, but idk how i could set it to a skullmeta isnt it for players?
yes
idk how it works exactly, I just meant that its the same process for any other head presumably
this the give command im usin n every attempt i try to get it working in spigot api it dont work
give artcel skull 1 3 {display:{Name:"Frog"},SkullOwner:{Id:"6e0e69d8-ac58-40a1-baf8-68de9d85cff8",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDJjM2I5OGFkYTE5OTU3ZjhkODNhN2Q0MmZhZjgxYTI5MGZhZTdkMDhkYmY2YzFmODk5MmExYWRhNDRiMzEifX19"}]}}}
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
If I make mutliple calls to persistantDataContainer.set
can I set the item meta after all of them or do I need to set them after each call?
you can set after all of them
how do I convert a component to a string
Kinda going nuts over this one, i'm trying to do a daily bank interest system, but i'm stuck on how to check IF the player has reseted or not :/
I currently have the last reset time(code), the last connection of the player in time(code), the current time(code) of course
LocalDateTime lastresetplusone = lastreset.plusDays(1);
LocalDateTime current = LocalDateTime.now(ZoneId.of("America/New_York"));
LocalDateTime lastconnection = ConvertStringTime(data.get(new NamespacedKey(plugin, "lastconnect"), PersistentDataType.STRING));
i think my problem is that the reset happen at 12pm, so i can't just check if the day has passed, i need to check everything, down to the minute/hour
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R1.inventory.CraftMetaFirework cannot be cast to class org.bukkit.inventory.meta.FireworkEffectMeta (org.bukkit.craftbukkit.v1_20_R1.inventory.CraftMetaFirework and org.bukkit.inventory.meta.FireworkEffectMeta are in unnamed module of loader java.net.URLClassLoader @27fa135a)
How is this possible?
So if I am doing Player.getInventory() how do I duplicate the inventory/save it for later so the data doesn't change out from under me when the player's inventory changes?
I tried making a new PlayerInventory and then realized it was an interface
It's been such a long time since I've used Java tbh
Firework v firework effect
yeah
getContents
How do I bind that to a variable and then restore it after?
