#help-development
1 messages · Page 14 of 1
yeah well, kinda true, but also not really any problem
No, not a problem. As much as
public void myMethod()
{
}```
also isn't a problem
It's just wrong lol
still doeant work
I'd also not name my new plugin's main classes "Main" but it also would not cause any problems, ever
Unless, of course, you're importing the wrong Main
Because both CraftBukkit and NMS have a Main
(both of which contain the main method btw ;p)
your class name is not following java conventions
its causing you issues
your making a listener from presumably spoon fed java code and named your class incorrectly expecting it to work
but people shouldn't use OBS or NMS anyway 😄 And whoever does, probably knows which class to import. But yeah, you're right, Main is not a good name but it also doesn't kill anyone
ok
yet

No you're fine lol
ok
You can if you want, we generally discourage the use of Main as a class name, but it won't be the cause of your issues
I'd imagine you're just importing the wrong Main
I usually call my main ChestSort, Drop2Inventory, etc (however the plugin is called), unless I already have another class called like that. e.g. for AngelChest, there's an "AngelChest" class so that'd be called "AngelChestPlugin"
uhm I think his Constructor name is wrong based on his class name choco
your clas is interactListener when it should be InteractListener
how do i fix that xd
registereevents?
and DO NOT register the listener in the constructor
that's against the "single responsibility" idea
register it onEnable
your main class / onenable should register the listener
a listener should only register itself in very few usecases
normally it shouldnt do that
shitty video then :/
Yes, just the class and constructor names don't match
rename the class to InteractListener
this shit pisses me off on god im gonna make my own jvm at this point
yay
good luck
what about "mainClass" 👀
thx you guys
I'd argue the easier solution would be to not modify a list while you're iterating over it, but yeah
do not moddify collectiosn while looping over them
- use a second "copied collection"
- use an iterator
- use a threadsafe variant (e.g. ConcurrentHashMap)
all videos are
true
bump
use this in the constructer
also why don't you register ur events in onEnable?
show your InteractListener constructor
i do
package buildserver.main.listeners;
import buildserver.main.Buildserver;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class interactListener implements Listener {
private Buildserver plugin;
public interactListener(Buildserver main) {
this.plugin = main;
}
//ArrayList<String> hidden = new ArrayList<>();
//String prefix = getConfig().getString("Config.prefix");
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if(event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(event.getMaterial().equals(Material.COMPASS)) {
Bukkit.dispatchCommand(player, "kill");
}
}
}
}
Thats the whole code
?paste
ok
^
just confused why u made a different class for it then
You explicitely said that "interactListener" (you still didnt fix the class name) requires a parameter of "Buildserver" to be passed
you should take a look at this:
?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.
ok so?
learn. java.
so pass an instance of your main class, duh
Use Plugin instead of JavaPlugin. Use a constant for the Namespace. If you're on a modern version you can use instanceof Player player. So you can skip the cast line
and ?learnjava
Constants in java??? whaaaaaa,
Guess what im doing right know. Im learning java and learn from you help
private static final NamespacedKey MY_KEY = ...
watch the video first...
wait where?
or non-static, if you don't have a static getter for your main instance ofc
final is constant?
please i just wanna get on coding
wow i never knew
basically
patience man
i would not start making minecraft plugins if ur brand new to java
and i dont know this stuff yet
understandable but you gotta learn the basics
and you're helping me
then dont use that stuff yet
then do that
make a hello world program, work on proper class names
spigot != coding
but i wanna code in another class
and there are errors
ur making it hard for urself
what does != mean?
then come back
It means does not equal
was asking the other guy...
i answer
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.
is there any language that doesnt have this? o0
idddk
i found it out in java first
since it's what i only coded in for like 2 years
until i started learning other stuff
and i haven't worked with other languages that do booleans yet
I think every language has this, or at least a similar thing :3
just css and html
They are stylesheets and markup
ik
i am just saying thats the only other stuff ik to code in
starting to learn js now tho
then python
css + html5 is turing complete :X
jeff
Ntdi
;/
blogger
clogger
i read your blogs
toilet clogger
python has “not” but the bang is nicer
hey how do i make non-final vars in a interface class?
also every male person has at least once tried to.... oh wait I'm on spigot's discord, I better shut up
you don't
O:
conclure will 
but yes
if you want to have a non-final variable in an interface, I fear you haven't understood the purpose of interfaces yet 😛
well have this but like i needa change it 2 the item when i implement this class
i’m gonna assume my answer is yes
you could use an abstract class instead of an interface if you really wanna do this
looks good. what's the error message?
i could, but i prefer interfaces, is there an alternative
you didn’t do it wrong
.
an interface is merely a "contract"
you need to pass for constructor
you still didnt pass "this" into the constructor
idk why you refuse to ?learnjava
?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.
like that
yep
read one of those tutorials! If you refuse to, I will refuse to answer from now on. Feel free to ask if you got any questions about one of those tutorials, but it makes no sense to spoonfeed you if you refuse to at least try to read one of those tutorials

yeah true
sorry
Effect.LAVA_POP is deprecated, how am I supposed to spawn the lava particles
no problem, ?learnjava isn't meant as insult. It's just a suggestion because it's hard to learn java by just going into spigot without knowing the basics 🙂
mommy give me food
me too pls
yes true
Mommy help me
I'm hungry since 2 days
gimme your mom's phone number
imma message her and ask for food
if your grandma is still alive, gimme her phone number instead
where the cookies at
gotta craft'em yourself D:
read the deprecation note but i can’t find it at all
^
can u make for me?
no sorry. whenever I try to create a world, it's stuck at this for 30 minutes
oh bruh
can u atleast send the recipe then?
#spigotcraft just reminded me of how old i am
thaaaanks!!!!
I got you one cookie and it only cost me 100% cpu usage
I appreciate that
lol
you just saved my life ill do saves urs one day
❤️
oh great
?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.
I also kinda learnt java while doing spigot plugins and it was a pain. I learnt the very basics in school, like 12 years ago, so I didnt have to start from scratch. But learning at least the basic concepts (e.g. like "WHYYYY can I not use new MyClass() when I defined a constructor that does MyClass(SomeObject)") is ofc a huge help. So yeah, sounds frustrating but you really have to go through at least half of one of those linked tutorials. It'll be very helpful, I promise
WHAT THA FUCK. I searched everywhere and i nowhere i import buildserver.main.main >.<
plugin.yml
huh?
wait i read that wrong
how did u compile ur jar?
can i see ur pom.xml?
to long for dc
I've already told them what the issue is
the plugins section then
?paste
oh
getting this error when trying to use a custom item system: https://github.com/horizonstudiosmc/EternityItems
Main class: https://paste.md-5.net/sabafaxofo.java
Item Manager class: https://paste.md-5.net/umataberuk.cs
Custom item class: https://paste.md-5.net/alepisefas.java
getItem is null
not sure why
They're not holding an item
but they are
PlayerInteractEvent get called twice, once for offhand and once for main hand
so probably the offhand is empty
^
okay, but the effect doesnt give
what's your listener code
@Override
public void handleAttack(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Player victim = (Player) event.getEntity();
victim.addPotionEffect(new PotionEffect(PotionEffectType.DARKNESS, 10, 1));
}
Player victim = (Player) event.getDamager();
victim.addPotionEffect(new PotionEffect(PotionEffectType.DARKNESS, 10, 1));
}```
no
It will when any other entity damages another entity
CustomItem item = getItemFromDataContainer(((Player) event.getDamager()).getInventory().getItemInMainHand().getItemMeta());
this is probalby null then
They use an interface
abstract*
it gets called from another class
how?
ItemManager passes the event to the CustomItem thing
Yeah this is where the error is from
Actually wait no
?
CustomItem item = getItemFromDataContainer(event.getItem().getItemMeta());
getItem is null
Or can be
why is it?
also instead of doing !(item == null), just use item != null
it's way easier to read
but why is it null in this case?
Fix one thing at a time
oh wait
thats not even related
the effect just isnt being given
thats before i hit that entity-
i have no idea where 2 start debugging lol
Fix the error mentioned above. Then put a sysout in the attack listener/method
Make sure it fires and we'll work from there
and it doesnt fire (:
Well there you have the problem
aha
public void onAttack(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player) {
Bukkit.getLogger().info(((Player) event.getDamager()).getDisplayName());
CustomItem item = getItemFromDataContainer(((Player) event.getDamager()).getInventory().getItemInMainHand().getItemMeta());
Bukkit.getLogger().info(item.key);
if (!(item == null)) {
Bukkit.getLogger().info("gets here");
item.handleAttack(event);
}
}
}``` okay so `item` is null for some reason
not sure why
@chrome beacon
Use variables to make the code easier to read ;/
Anyways I need the getItemFromDataContainer method
public CustomItem getItemFromDataContainer(ItemMeta itemMeta) {
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
NamespacedKey nk = NamespacedKey.fromString("custom_item", mainPlugin);
if (!(container.get(nk, PersistentDataType.STRING) == null)) {
return getCustomItem(NamespacedKey.fromString(container.get(nk, PersistentDataType.STRING), mainPlugin));
}
return null;
}```
ik ima fix that later
No. It will throw an error
idk how to get around that
??
well idk, heres my entire class https://paste.md-5.net/tahenemisu.cs
you should cache NamespacedKeys when possible if you need them frequently
I usually just use a map to store keys https://github.com/JEFF-Media-GbR/JeffLib/blob/1035777b3f4ac8bd57cb91352b46643355307735/core/src/main/java/com/jeff_media/jefflib/PDCUtils.java#L72
Make sure the item actually has the pdc on it
If I'd like to modify the behaviour of horses, where can I start? Would I create a class CustomHorse extends Horse?
You would need to extend the NMS horse yeah
I already answered to you that you need to extend the NMS horse but you didnt answer anymore
what would i init it to? also why
private final NamespacedKey myKey = new NamespacedKey(...);
thens it not changable?
ah okay wasn't totally sure if Horse was that but doesn't look like it. i can't access net.minecraft.server maybe I need to add a maven dependency
What version are you using?
are you on 1.17+?
but the new instance is for every item? that would ruin it??
1.19
pdc?
PersistentDataContainer
oh
im so confused rn
about what exactly?
but i did use pdcs?
what are you trying to do, and what's the problem?
I still haven't seen where you add the pdc to the item
@Override
public void init(EternityItems plugin) {
key = "dark_sword";
this.plugin = plugin;
ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
ItemMeta meta = item.getItemMeta();
meta.addEnchant(Enchantment.DAMAGE_ALL, 2, false);
List<String> lore = new ArrayList<>();
lore.add(ChatColor.WHITE + "The souls of the damned.");
lore.add(ChatColor.BLACK + "Gather into the blade of darkness");
meta.setLore(lore);
meta.setDisplayName(ChatColor.BLACK + "The Blade Of Darkness");
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier("dark_sword_speed", 5.0, AttributeModifier.Operation.ADD_NUMBER));
plugin.itemManager.generateDataContainer(key, meta.getPersistentDataContainer());
item.setItemMeta(meta);
NamespacedKey namespacedKey = NamespacedKey.fromString(key + "_rec", plugin);
ShapedRecipe recipe = new ShapedRecipe(namespacedKey, item);
recipe.shape("OOO", "ONO", "OOO");
recipe.setIngredient('O', Material.OBSIDIAN);
recipe.setIngredient('N', Material.NETHERITE_SWORD);
Bukkit.addRecipe(recipe);
}```
here
I repeat: what are you trying to do, and what's the problem?
custom item plugins, it wont fire the handleAttack
I have a feeling you're making things more complicated then they need to be
then check all your "if statements" and see which ones of those fails
We know which one fails
just add something like System.out.println("...") before and after everx if
Is it possible to add durability to an item that doesnt normally have it? say a spawn egg?
then you can see where it stops
You can't add the durability bar or things like that. But you can add lore with durability text
shucks alr
Actually you can in modern versions with a resource pack
You will still need the lore though
alr 👍
For what? What are you using the string for?
why do you need it to be a string o0
ItemStacks are serializable
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
We just told you?
yes
myYamlConfiguration.set("item",itemStack);
almost everything in bukkit implements ConfigurationSeriazable
even Player 😄
(although serialization for players and offlineplayers is useless)
you can retrivee it again with myYaml.getItemStack("item")
By the offchance, i need to generate a Random int every tick, would ThreadLocalRandom be more efficient, or a static Random instance for the entire plugin?
Are you on a modern version like 1.18+
Then you can use the new random classes
ill google that ty, didnt know there was new random
I mean, a bit excessive tbh
You can use either. They accomplish the same goal
Yes but its something i need to call every tick or every other tick, multiple times in said tick
That's fine
ThreadLocalRandom#current() returns a constant anyways
(constant for the current thread, that is)
So say 100 times per tick, shouldn't be an issue? with a max bounds of -20 to 20?
Yeah, no issue whatsoever
Generating random numbers isn't necessarily performance intensive
add i always thought it was
i guess I must be thinking of the noob way new Random().nextInt()
i remember when first learning java there was something with randoms that was necesarily bad, maybe that was it
cant quite remember
however the new api does look nice
yep
Yeah, if you're doing new Random().nextInt() every time, you're going to break some computers
ah okay so i guess that's what it was then, ty :))
public final class Main {
public static void main(String[] args) throws Exception {
int amountToGenerate = 100000;
int[] values = new int[amountToGenerate];
long start = System.currentTimeMillis();
for (int i = 0; i < amountToGenerate; i++) {
values[i] = ThreadLocalRandom.current().nextInt(-20, 20);
}
long end = System.currentTimeMillis();
System.out.println("Done in " + (end - start) + "ms");
}
}```
This took 5ms
oh shit
okay
yeah certainly fine for 100-1000 then 
I just use randoms to offset a location while a NPC is syncing location to player
A lot nicer then them pathfinding straight into your face
You'll be okay ;p
god the namespace for custom recipes is weird
" X "
like 3 length string cx on the namespace
Yes but IMO it should be more programatically available for setting what slots accept what
ie set(0, "X");
indeed, its easy to make a wrapper around it tho
but always something that slightly annoyed me when working with the raw api
if you do it right you could have some sick chaining
so like
static random
set(0, null).set(1, "X").set(2, null).
set(3, null).set(4, "X").set(5, null).
set(6, null).set(7, "B").set(8, null);
wrong reply
fuck that hurt my arm typing
also there's a random you can use fo ra sped
see here ike
setting nulls wouldnt be necesary tho
you can just set only slots you dont want air
https://dsiutils.di.unimi.it/docs/it/unimi/dsi/util/package-summary.html#package.description
https://dsiutils.di.unimi.it/
@noble lantern
declaration: package: it.unimi.dsi.util
for sped random
If you want speed there are benchmarks in the random guide I sent
more or less just for programatic friendlyness
its awkward to manipulate raw strings, especially with dynamic stuff
this is from projects developed at the Informatics Department of the University of Studies in Milan
it's a huge library of fast as fuck utils that are extremely good at what they do
anyways gtg
bugs are on my screen (it's night)
In that one says Random has highest score vs the new one weird
neat lib but seems like major overhaul to shave off .2ms
You want low time per operation
So L64X256MixRandom
at .090
seems like an odd graph to read lmao
never really benchmarked stuff using ns/op
Il bookmark this tab and take a look into it later tonight
When i get nit picky for performance ill shove the new random generator in
Yeah go for thread local
Yeh that's currently what I'm using, only reason i really even did in the first place is because nextInt supported a min and max value that was negative easily without any math haha
you create a new inventory, or fill the one you already have
you have to loop over it, yes
are there negative side effects of setting an item in the inventory as 0 to get rid of it apposed to removing it from the slot directly. I'm working with an item I want to be consumed and its easiest to set the amount to 0 than override the inventory slot its in based on my design structure
remove -1 from amount on consume is best
ok thank you
use getItem(slot).setAmount(- 1)
cause if you override the slot a different item may be there by the time you try to set it to null/air (IE in a task)
sorry discord crashed so took a min to send
well I'm doing all the consuming in the actual item class regardless because I have a use method it would have been annoying to pass in a player method and find the item in the inventory to remove it
ahh so your already dealing with just a raw ItemStack already in the use method
In that case it still applies for - 1, just as long as you arent cloning the ItemStack getting used
What version is this
on newer versions you use GameProfile's to set skull owners iirc
that method is from 1.8, thats how it was done back in the day
yeh
thres an article somewhere on it
you can use PlayerProfile from spigot iirc
no need for Mojang api anymore
Bukkit#createPlayerProfile
yep this ^^
that method is outdated use PlayerProfile which has a similar way of working just minus the reflection
the method for the skull setting should still be the same, but just take in PlayerProfile instead of the GameProfile
so everything GameProfile in that thread is irrelevent
because you rly need the Base64Texture the skin provides
if you already have the base64
im like 99% sure thats all you need
PlayerProfile file = Bukkit.createProfile(UUID.randomUUID());
file.setTextures(file.getTextures().setSkin("url"););
way shorter and easier
just do url its super easy
most websites host links to the url
lol
new URL("https://textures.minecraft.net/texture/32bb65a10d0162ba63f84deedd3e678ba0904751aeff5ba077e094f1cf27feec");
if you need a url object do that
private static void createProfile() {
PlayerProfile file = Bukkit.createPlayerProfile(UUID.randomUUID());
file.setTextures(file.getTextures().setSkin(new URL("https://textures.minecraft.net/texture/32bb65a10d0162ba63f84deedd3e678ba0904751aeff5ba077e094f1cf27feec")));
}
You will have to add a try-catch
PlayerProfiles are the way go. I still use the NMS way because I gotta support 1.16+ (look at the SkullUtils class in core) -> https://github.com/JEFF-Media-GbR/JeffLib
PlayerProfile isnt from nms?
or is it from mojang auth package
No, its API
How does the default config get created with all your saved values?
GameProfile is from authlib
PlayerProfile is API since 1.18.1
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
I always use this for custom configs with default values https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/data/Config.java
ah that why
I keep getting this error in the console when my plugin loads a config. Does anyone know of a common solution to this if there is one? Cannot load configuration from stream org.bukkit.configuration.InvalidConfigurationException: unacceptable code point '' (0x0) special characters are not allowed in "'reader'", position 0
That means the contents of the file is null iirc
Did you specify defaults?
I don't think so
Hey, does anyone know the process for sending a lever change?
I got this fakeblock class here -> https://sourceb.in/K9V8eliCTH
Which works fine overall, but I can't send new lever blockdata with the following code -> https://sourceb.in/CBw0KBj5gE
Anything else works so I might need some other packets?
file.getTextures().setSkin
How do I hide my directory or make it work with a team of people when exporting to a specific path in pom.xml
no need to call setTextures
Just trying to make it export to plugins folder but making a repo so it won't rlly work if anyone else tries it
Get the skull meta and call setPlayerProfile
You need to set the variable type to SkullMeta
why is that static
ItemStack item = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (short) 3);
if (url.isEmpty()) return item;
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField = null;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
item.setItemMeta(itemMeta);
return item;
}```
so I don't see a reason not to
this is the code I use, use it or dont
yes
just build it in your project
its just 60 kb
Someone knows how i can get all players in a range of 5 blocks
And pick 1 of them to die?
But then i check nearby entities instance of player
But how will i pick 1 player if there are more players in the range?
Alright thanks! I will try that :D
Hahaha thanks i will!
make sure to keep your range the limit of players detected
Anyone good with AI in NMS
When setting the zza of an entity, does this gradually go down as the entity travels? What exactly is zza? Its effective velocity i assume?
it's the effective velocity for the z axis
i see
thank you
currently modifying citizens cause i need to figure out when the entity stops traveling on zza 
Agree
Anyone awake that could help me out
yes
what means "<<a"?
Possibly in dms aswell
oh hey saiyan gens admin
eh lol, who are you xd
you could do that, but something that might be better is using enums to stick them in
How are your Java skills ?
Also i know you from the name Buchard
I have a few diff names ppl know me by
more organized and can be called anywhere when needed
Exceptional, why so?
Ive offered to make plugins for saiyan gens in the past 😛
Not accepting any current work though, if you need a java dev you may need to go check services
But i can help with any java question you have
Yea its not a service, purely problem solving
Ask away then, if i cant answer others will 🙂
Alright
kinda hilarious the velocitys so low he moves .002 blocks a sec xD
your way is perfectly fine if that is how you want to do it, most people just don't know you could use enums for such things too lol
lol
?paste use this to send code
I use netbeans, there is a config file where you can change the resources and jvm flags 😉
hard to read from txt file
EntityTypegetType() uses NMS interally right? Because i need to stop player killing mobs and i need
will have to ask me in about 10 hours when I get off work. Heading to work now 🙂
Anyone who will make me a sell portal plugin.
So i detect mobs and kills them and store there loot so i can sell it like this video
https://www.youtube.com/watch?v=fux3NTrz8K0
Alright, whats the issue you currently have mostly seems decent from a quick skim through
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Alright so what im trying to do is create a .yml file for each player which shall be stored in a subfolder. example: /plugins/HoldPlugin/PlayerData/<PLAYER UUID>.yml
The problem is neither the subfoler (PlayerData) or the files are anywhere to be found
Do i have to load the something in my Main class for everything to work ?
Is this all your file code?
Any more hiding elsewhere?
When you want to create a new file, you need to make its dirs leading up to file + the file itself
Unless im overlooking i just see you opening an int/out stream to a File instance
he doesnt need that
getDataFolder() for the parent is just fine
hes just not actually creating the file
eg File#createNewFile
Hes just initializing a new File()
Which yes works, but if you want data to save you need to write its data to it then save
hes already doing that
soo from this
this.playerConfigFile = new File(this.plugin.getDataFolder(), "PlayerData" + File.separator + uuid.toString() + ".yml");```
to this?
```this.playerConfigFile = new File(this.plugin.getDataFolder(), "PlayerData" + File.separator + uuid.toString() + ".yml").createNewFile;```?
Almost
so, first i would make a single method just for checking the PlayerData directory
eg new File(dataFolder, "PlayerData");
Then you need to check if it exists calling exists() on it
If its false, call mkdirs() on it, if not continue to load the player data files
when loading the player data files, do the same thing with exists(), but instead of mkdirs() afterwards, its gonna be createNewFile()
From there, you can just use Bukkits Yaml api for saving/writing to said file
Do note
brb in 2 min i really have to take a bi piisss
some of these methods need try/catch so listen to your ide for that
iirc only createNewFile needs it
You can likely actually make the process smoother, but thats the most basic way to make sure the files exists before opening a Yaml stream to them
lowercase
NamespacedKeys cant have spaces
So yeah
BUMP #1001629133807300678
?bump EntityTypegetType() uses NMS interally right? Because i need to stop player killing mobs and i need
Something like this? or am i totally mistaken
public boolean playerDataDir() {
if (!(new File(this.plugin.getDataFolder(), "PlayerData").exists())) {
new File(this.plugin.getDataFolder(), "PlayerData").mkdirs();
}
return false;
}
I didnt challenge you I showed my method so idrc
yep, i would reccomend creating a local variable for that file, other than that alls good
mkdirs() returns a boolean btw
you can return its value instead of always false
private boolean playerDirectory = false;
public PlayerConfigManager(HoldMain plugin) {
this.plugin = plugin;
}
public boolean playerDataDir() {
if (!(new File(this.plugin.getDataFolder(), "PlayerData").exists())) {
playerDirectory = new File(this.plugin.getDataFolder(), "PlayerData").mkdirs();
}
return playerDirectory;
}```
yes
Like this @noble lantern or do you mean return playerDataDir();
yep 
well
return new File().mkdirs()
and outisde your if return true;
no need for that boolean variable you have sec
that way will work, but its better to return the values of the methods directly
public boolean playerDataDir() {
if (!(new File(this.plugin.getDataFolder(), "PlayerData").exists())) {
return new File(this.plugin.getDataFolder(), "PlayerData").mkdirs();
}
return true;
}``` 🙏
yep!
and from there, you do the exact same thing but for each player data file individually
And use createNewFile() instead of mkdirs() for actual files
so an on join event and then just check if the player already have a file?
Yep, and if they dont createNewFile and then open yaml stream to write and defaults you need
YamlConfiguration.loadConfiguration(file); iirc
and you can call save(file) on that option (I assume your using yaml)
and if not new File(this.plugin.getDataFolder(), "PlayerData" + File.seperator + uuid.toString + ".yml").createNewFile; ?
then you just get theyre file
Yessir
new File() and then open the YamlConfiguration if it exists
I recommend using Json or sqllite for flat file storage, but for now learn this and get used to just creating files and whatnots 🙂
Once you learn all this you can do really crazy cool stuff with JSON + POJO classes when you learn json
PDC
?paste
https://paste.md-5.net/jekodujice.cs Is this efficient enough to work?
Yours simplified https://paste.md-5.net/udexovutaz.cs
😭 Why can't people use DBs like a normal person
lol
i mean the plugin need unregister this recipes
If you are reffering to me, i would much rather learn all the more "basic" stuff rather than jump right ahead to databases. To me learning the basics is much more important.
You have the key so you could try https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#removeRecipe(org.bukkit.NamespacedKey)
Databases don't have to be complex. I'm just saying it's not the best practice to do that. You can ignore best practices that's fine by me.
simple databases are the best databases
What would you say is the best practice? Sqllite ?
mysql is popular
That or a regular SQL DB.
I've had exotic customers ask for amazon s3
Either or. SQLite is used in enterprise software so 
windows uses sqlite
Adobe, Google, etc.
Mongo is nice
sqlite is nice due to its offline support
It's used in Android
it's literally a file
And Chrome
I prefer it over an actual hosted DB unless I plan on having that data be accessed by multiple applications
I prefer to just support the most popular choices
instead of convincing people to stick to a solution
each class has like 100 lines
I mean it really depends what the data is used for
Yikes, that's a lot of nested ifs
I might impl some system on my redis packet system to tell other servers about fetch and save status
might help with latency and anti-desyncing
I don't like the string forms
or how people send json messages
just serialize the data to a byte[] and send it bia binarypub
speaking of I was actually just working on one of my packets that I should resume work on lol
it has a "packetprocessor" system where you can add redis, rabbitmq or just use sockets
and not have to rewrite communication to add rabbitmq
everything is modular
ugh the entire system I just wrote won't work
because isSimilar matches meta data to some extent
and your making a new item stack
check its type, or if your item stacks are statics/singletons then just use that instance for isSimilar
yep
but your gonna need to tell if its a player head from your plugin ofc, likely using pdc
?pdc
^
Based+
Its essentially NBT, but wrapped in BukkitValues NBTCompound
Sound.valueOf
He was passing a bukkit sound name
playSound's string param is the minecraft namespaced key, made for playing a sound present in a resourcepack
Can i get an npm package idea
get the player’s equipment, get item in main hand. Set amount, set item in main hand.
awnser: use .toLowerCase
Whats the max distance a player can be off a block before they fall off of it? Is there a specific decimal amount?
Well doesn't it depend if they're shifting too?
yeah, without shifting is what ide likely need
cause what im doing wont involve shifting
seems like quite a lot, but not sure of the actual float amount, couldnt find anything online
wait
im stupid f3 exists
its about .3
actually its .3 both ways
when walking off, and shifting up to it then walking
So i have a map of <ItemStack, Double> I need to calculate the amount of items to give the player based off of a int of how many minutes. Double is the chance of that item to be given every minute
I dont want to loop through the list for however many minutes there are
But i cant figure out a better way
And do calulations from there
I could also just get the amount of items per minute and then divide by the percentage. But then it would be the same if minutes are the same. I want it to feel random
Oh well
Imma go with that one
I now run into an issue
How do i calculate the amount of items per minute
Without looping through every minute and adding the itemstack to a list
Cause if its been 9999 minutes. And it has to loop 9999 times
Seems like there should be another way
I mean i guesse i could just save it to a map with an amount of items, and then use that later
thats what imma do
How often are you giving the items to the player
Well, ill make it whenever they click a button in the gui
But still
Math is the key here
Ik, but how would i apply that to the amount of objhects i need to add
You need time in milliseconds on last click and on nw click
? I have the time
In minutes
So what im gonna do rn is this: (Leme type it rq)
You don't need to loop over time all your doing is looping over a map full of items and giving a reward based off an algorithm of time passage and percentage chance of item retrieval
Check the item, multiply the amount of that item by the minutes int. Then divide by the chance.
The only issue being
That i have no idea how im gonna add the amount of items based off the number
Sounds like im looping over the amount of time that passed?
Why would you loop over time at all that'd be overly costly and slow
Yes. So im trying to figure out an alternative
But i cant think of anything
At some point im gonna have to loop over the amount of time
Are they placing it?
Yea do that
Log the name of the block placed and thays your answer
anyway. Yea what do i do to not do that
My math b3ain is dead this late gimme a second
Alr
i uh huh?? how did it just break out of a sudden
Check your maven/gradle dependencies
Restart intellij
Delete intellij cache
Etc
alr
Since I'm in bed right now I can't write an algorithm I apologize but I'll do my best to at least explain what you need if your not already aware of such alternative method
I am not
Before I write I want to confirm you want to give player a 30% chance to recieve 1 item after every X milliseconds from last execution
every minute. But yes
X% chance to receive X amount of items every X minutes
I will
one sec leme read it
Use interact event
In that situation yea
yes
I think
Hold up, idk if ive ever done that specifically before
Leme double check for you
@quaint mantle
My b
I havent used block place before
Use block place event
But check the block not the item
Or
Even better
Use event.getItemInHand
Excuse my schizophrenic ramblings
this is the correct fix
you talk just like me 
lmao
If you want a player to have x% chance to recieve y amount every z minutes first you need previous time and current time. Now you'd need to form something to run that x% chance z/current times. This can actually be modeled by
p^x(1-.3)^y
X mean succeses
Y meaning times it can process
You should beable to use a log to achieve this fairly easily
Credit where credit is do I simply reversed the formula from the answer here https://math.stackexchange.com/questions/1260572/probability-of-something-happening-exactly-x-times-given-y-tries
getHealth for Entities,
Im sorry, its not every X minutes. Its based off of X minutes. Like if i give it 3 minutes. Then it will generate three times as many items
Oh idk then I'm tired lol I gotta go to bed
But im having an issue because i cant simply modify an ItemStacks amount to be more than 64
alr lol
Get some sleep
wdym
If it's above 64 subtract 64 from total and add a new itemstacm to the inveno
BlockData
And then loop until its 0?
Then im still looping
Its more efficient
But
Is it the most efficient
Wdym metadata
Metadata isn't permanent so make sure you don't use it like persistent data containers
go to sleep lmao
How tf did origin realms do this?
In most places text is rendered, a shadow appears beneath every character. This shadow is a copy of the character's bitmap, with the brightness subtracted by 90%, and positioned 12.5% south-west of the character, relative to its spacing. Regardless of the resolution of the character's texture, the shadow is always moved by 12.5%. In the default font (assets/minecraft/textures/font/ascii.png), the shadow is equivalent to being moved 1 pixel down and right.
https://i.kawaii.sh/Bl~I4BZ.png
the background is dynamically resizable and that bar doesn't have a shadow. I'm wondering if by one pixel they just put a pixel that was 90% more opacity to negate it?
Someone said if you don't use a default font there is a way to disable it but i havent figured that out
huh
what lmao
Your trying to get the material?
What do you need
Ohhhhhh
Check the event.getHeldItem()
That gets the item before it was placed
checked my maven dependencies, restarted intellij, deleted intellij cache:
leme get the right one
can you send any more information than that?
probably
check the docs
Yea
thats it
Show your imports?
Are any of them broken/red
@rain mason Multiple modules?
lmao does it work?
nope, but I magically fixed it by importing EntityDeathEvent
It looks like it should
still the advancement thingy tho
Thats intellij 4 u
Try importing it lmfao
it is tho
Delete the imports
And then find whatever turns red
push ctrl+1
or whatever your bind is
To open the tips thing
And find what its suggested fix is
Odd that your getting that issue with only a few things
okay I figured it out: importing EntityDeathEvent fixes PlayerDeathEvent, but importing AdvancementDisplayType produces the first image I sent you
pass only the event
no wait wtf, if I put AdvancementDisplayType and the bottom of all imports, it only screams about AdvancementDisplaytype
but if I import it at the top, it screams about literally everything I imported
ahaha I wanna die
It checks everything except item amount
So you would wanna do if(getType == Material.PlayerHead)
no idea lmao
you need to use a singleton of the custom item you have if you wanna use isSimilar, if not what hyper said + pdc
anyways I removed the ADVANCEMENT THINGY!! >> thing and it magically works!! it was probably bugging out because of the advancement.getType lmao
I have no idea how to use the bot
So imma screenshot it
Hes trying to check if its a playerhead
So he would check if the item.getType == player head
its a custom item
@quaint mantle am i correct?
Hes making a custom item plugin
he was in here a few hours ago
with the same question xD
See
Make a class like this to hold your keys
public class Keys {
public final NamespacedKey ENTITY_TYPE_KEY;
public final NamespacedKey MULTIPLIER_KEY;
public final NamespacedKey MINED_KEY;
public final NamespacedKey OWNER_KEY;
public final NamespacedKey LAST_GEN_KEY;
public Keys(StartupClass pluginClass) {
MainClass plugin = pluginClass.getPlugin();
ENTITY_TYPE_KEY = new NamespacedKey(plugin, "bs.entityType");
MULTIPLIER_KEY = new NamespacedKey(plugin, "bs.multiplier");
MINED_KEY = new NamespacedKey(plugin, "bs.wasMined");
OWNER_KEY = new NamespacedKey(plugin, "bs.ownerName");
LAST_GEN_KEY = new NamespacedKey(plugin, "bs.lastGen");
}
@quaint mantle And then have a getter somewhere to get this class.
And get the key
So you dont create a bunch of namespaced keys everywhere
And then after that its pretty simple
leme give an example
With my plugin
ItemStack spawner = new ItemStack(Material.SPAWNER);
ItemMeta spawnerMeta = spawner.getItemMeta();
if (spawnerMeta == null) return null;
PersistentDataContainer spawnerData = spawnerMeta.getPersistentDataContainer();
spawnerData.set(plugin.KEYS.ENTITY_TYPE_KEY, PersistentDataType.STRING, spawnerType.name());
spawnerData.set(plugin.KEYS.MULTIPLIER_KEY, PersistentDataType.INTEGER, multiplier);
spawnerData.set(plugin.KEYS.LAST_GEN_KEY, PersistentDataType.LONG, System.currentTimeMillis());
@quaint mantle
PDC is very easy
Huh
Lmao
Its super easy 
Show me your checks
Wait
so whats happening?
Also, dont do the pyramid of doom
Or whatever its called
Callback hell
use if(event.getBlockPlaced().getType() != Material.PLAYER_HEAD || !event.getItemInHand().getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) return;
It checks if its not, and returns if it isnt
Does the same thing but more efficiently basically
Weird
Very weird
Look it up?
lmao
What was the issue
very odd
Check if its null, and return
That should stop the error but still allow you to place it on the side
Just try it
gn
probably using a copy of the item
try something like
Item(or ItemStack?) item = event.getItem();
item.setType(Material.AIR);
event.setItem(item);```
if the event ur using has a setItem at least
Air has no ItemMeta
Yes
Just maybe, BlockPlaceEvent is triggered before the block is registered as placed?
BlockPlaceEvents.java:22 you are testing an Item which has no Meta
Air
BlockPlace fires before teh block is placed so you can cancel it
Your second hand is empty
MainHand OffHand
No but some events will fire for each hand.
easy test, put a torch in yoru offhand
The fix is to always test .hasItemMeta() before attempting to .getItemMeta()
What item is in your MainHand?
ItemStack item = event.getItemInHand();
if (!item.hasItemMeta()) return;
...```
Pretty new to all of this so got a quick beginner question:
Is there a simpler/cleaner way to wait some time? I'm currently using Bukkit Scheduler and it seems really messy. Also applying to while loops, is it possible to just use while loops or am I required to use runTaskTimer
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
p.setVelocity(new Vector(0, -10, 0));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
p.playSound(p.getLocation(), Sound.ENTITY_DRAGON_FIREBALL_EXPLODE, 1, 0.2f);
p.setInvulnerable(false);
}
}, 10);
}
}, 10);
if you use a while loop it will pause the entire server's thread and make it crash
runnables are your best option
wait do you want to pause WITHIN the runnable?
Correct, I'm currently using a scheduleSyncDelayedTask inside of another scheduleSyncDelayedTask
The while loop is elsewhere
i mean you could just delegate both to a method to make it a bit cleaner
but theres no other option really
or make it into a class instead of an anonymous class
well thats mostly how you do it. also you dont necessarily have to use a runTaskTimer, a while loop can be fine but it depends on the usecase
Gotcha, as long as what I'm doing is standard, I'll deal with it being messy. Appreciate you both! 😄
Lol wtf DO NOT DOWNLOAD
How does one send a bossbar using a TextComponent
someone said protocollib on spigot but i think the packet structure changed
I get an error while intercepting it
com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.network.chat.IChatBaseComponent exists in class PacketPlayOutBoss.
Is there a getDefaultWorld somewhere hidden in the api?
Properties server = new Properties();
try {
server.load(new FileInputStream("server.properties")); //$NON-NLS-1$
serverDefaultWorldName = server.getProperty("level-name").toLowerCase(); //$NON-NLS-1$
} catch (IOException ex) {
GroupManager.logger.log(Level.SEVERE, "Failed to load server.properties", ex);
}```
Why would you do that
How to create Craft Recipe?
https://pastebin.com/cr5Qfb7V anyone mind reading through this
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
my remap isnt working for some reason
Custom font from resource pack
Need to set it to use that font
Can only be done using json messages
Aka textcomponents
Spigot/Bukkit can't do it by default but the client will accept it so
Your compiler has source and target as 1.8
oop thanks
oh btw forgot to post code with it
class ProtocolTagChanger(plugin: Plugin?, listenerPriority: ListenerPriority?, packetType: PacketType?) :
PacketAdapter(plugin, listenerPriority, packetType) {
override fun onPacketSending(event: PacketEvent) {
val packet = event.packet
if (packet.type === PacketType.Play.Server.BOSS) {
var baseWrap = packet.chatComponents.read(0)
if (baseWrap != null && !Strings.isNullOrEmpty(baseWrap.json)) {
val firstPass =
ChatColor.stripColor(TextComponent.toLegacyText(*ComponentSerializer.parse(baseWrap.json)))
baseWrap = ComponentConverter.fromBaseComponent(*ComponentSerializer.parse(firstPass))
packet.chatComponents.write(0, baseWrap)
}
}
}
}
val bar = Bukkit.createBossBar("", BarColor.YELLOW, BarStyle.SOLID)
val x = TextComponent("\uE233\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234")
x.font = "yume:bossbar"
bar.setTitle(ComponentSerializer.toString(x))
bar.addPlayer(event.player)
(sorry that its in kotlin)
I am making my own file format for saving builds. I want it to be efficient so I figured using numbers instead of strings would save me some bytes. Does blocks have texture ids or something? I want to like get the material I'd of a block. Would I have to make my own hashmap?
Check for entities health
Why
Then how should I proceed?
my custom damage system occasionally has the issue where mobs get into like an invincible state, i saw the same issue has occurred with plugins like mcmmo and advancedenchantments but it wasn't clear on what causes mobs to get into this state. does anyone know?
I want to edit the login protocol
how? and can i use ProtocolLib for that?
GetWorlds().get(0)
I also always use java 8 for 1.19 plugins, thats no problem
Whats the problem?
is that always the default?
Which is why its a good idea to read the properties to be sure
Always
any help with that?
Not always. If a plugin loads world early World will not be 0
Are you sure? Ive never seen this happen
I've never seen it happen, but it's possible
Hm well ok
When I get time later I'll test it to be sure
I just remember md5 saying its not guaranted
package buildserver.main.listeners;
import buildserver.main.Buildserver;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.ArrayList;
public class interactListener implements Listener {
private final Buildserver plugin;
public interactListener(Buildserver main) {
this.plugin = main;
}
ArrayList<String> hidden = new ArrayList<>();
String prefix = Buildserver.getPlugin(Buildserver.class).getConfig().getString("Config.prefix");
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Location playerLoc = player.getLocation();
if(event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(event.getMaterial().equals(Material.GHAST_TEAR)) {
for(Player players : Bukkit.getOnlinePlayers()) {
if(hidden.contains(player.getName())) {
hidden.remove(player.getName());
player.showPlayer(players);
player.playSound(playerLoc, Sound.CLICK, 1 ,1);
player.sendMessage(prefix + "Alle spieler sind nun §asichtbar§7 für dich!");
}else if(!hidden.contains(player.getName())) {
hidden.add(player.getName());
player.hidePlayer(players);
player.playSound(playerLoc, Sound.CLICK, 1 ,1);
player.sendMessage(prefix + "Alle spieler sind nun §cunsichtbar§7 für dich!");
}
}
}
} else if(event.getMaterial().equals(Material.ARROW)) {```
player.playSound(playerLoc, Sound.CLICK, 1 ,1);
player.teleport(player.getEyeLocation().add(0,0.1,0));
}
}
}
Why is this not working?` There are no error in the console
https://wiki.vg/Protocol#Spawn_Entity
Does clicking on Mob Types redirect to a invalid link for anyone else?
Have you tried debugging? Adding some log lines in between code thats running and not?
hm I tried to load a world in onLoad in STARTUP phase and it throws this
thats just compiling
thats not how it works

