#help-development
1 messages · Page 651 of 1
Unfortunately, yes
I say unfortunately, because most people use the wildcard as it is
Just '*'
Which is, in terms of security, lamentable
Is more powerfull than having OP
You can still limit OP permissions, but you can't limit single * wildcard permission
Cancels mom?
menu))
In layman's terms I got no clue what your issue is
"doesnt work" isnt very informative
you send 3 screenshots of code
Maybe the issue is their mom
with like 5 words
I don't even bother looking at screenshots anymore
Like is it really that much work to click a link and ctrl c ctrl v
Does it even reach the openStash call?
can a plugin know the players language?
Yes
like, the language set in the client
#local in paper
Under spigot idk
hmm
when it closes, the menu continues its work, if you hide it, the menu closes
My bandwidth is limited - not going to open that
I'd still use the paper method if possible though as idk what the spigot method returns
Well it returns a string but idk the format of it
a string, probably en_us format
Yeah probably that one
But how will it represent the conlangs?
conlangs?
https://paste.md-5.net/yafopemoco.java - stash class
https://paste.md-5.net/cazosayono.cs - events class
https://paste.md-5.net/latenekilo.java - menu class

?
Reversed English, lolcat, etc
well, reversed english will be something like su_ne ig
Or the pirate thing
yikes
Woops wrong ping
Static abuse of the absolute highest order.
This leads to inevitable chaos.
:knife:
what will happen
sounds like smile is judging for some crime here 😂
Meh, static local vars would be worse
en_pr maybe?
Although HM<Player, V> is enough bad already
Always use Map instead of HM if possible heh
what even is the differnece
does it matter where they are placed? I could make a DataManager with these values stored
one of ur problems is that u are storing "Player" objects, these can become stale and lead to "memory leaks" if you dont handle them properly and i suspect you dont.
Yeah these aren't really mem leaks
the problem is that I'm not accessing the players via UUID?
thats why i put it in " " 😒
how can i check if the players inventory is full
This is a bit hard to decypher. I would suggest that you try to follow this in your next project:
- Dont use static. And i mean at all.
- Make all fields private
- Dont create any getters for Lists, Sets, Maps or other collections
This will greatly improve your understanding of java and how to write robust code.
Bukkit.getPlayer(uuid) be like (or what was it?)
You are not storing data via UUIDs to be more precise
First you need to define what full means in your context
Hence the yeah
all the main inventory slots(9 main, 27 additional) are filled with any item. no matter what theres an item of the same type im adding,
What is static for?
i believe its for making a method accesible without creating an instance of the class
This is worded misleadingly
It isn't accessible per-se, it just means you do not need an instance of the class to invoke it on
Well, it seems to me that this is more convenient than creating a Data class and passing it to others
can someone help me with this?
yea thats just the thing. its easy in the beginning
that does not mean its a good idea
function hasFullInventory(Player player):
content = player.getInventory().getContents()
for each item in content:
if item is null:
return false
material = item.getType()
if material is Air:
return false
if item.getAmount() < material.getMaxStackSize():
return false
return true
Here is the pseudo code representation of what you need to do.
The check for max stack size is optional
That is the (synthetic) parameter this disappears when using static
kotlin smh
there must be a built-in method
I don't think there is
there is but that does not support any present items of the same type
which most people want
There are multiple definitions of when an inventory is considered as full. So ther is none.
i need this
You literally just loop through the inventory and check if any slot is empty
does .isEmpty() return true when there is empty space on the inventory?
PlayerInventory#getFirstEmpty() != -1 would always check if the player has at least one empty slot
With streams that is a one-liner!
idk if thats even still present in the api
If it wasn't deprecated at any point: why would it get removed?
idk, i never programmed much on higher than 1.12 so i woulnt know
i believe essentialsx has a good implementation for this. leme go check their code
essentials has bassically the same thing smile sent you
?jd-s
You are defo overcomplicating the problem
but its not a prototype and its actual code
???
are we talking about this? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/Inventory.html#firstEmpty()
declaration: package: org.bukkit.inventory, interface: Inventory
so u just yoink all your code from finished projects then ? this makes little sense
public boolean hasFullInventory(Player player) {
return player.getInventory().firstEmpty() == -1;
}
public boolean hasFullInventory(Player player) {
ItemStack[] content = player.getInventory().getContents();
for(ItemStack item : content) {
if(item == null || item.getType().isAir()) {
return false;
}
}
return true;
}
Both of those are viable
Yep
isn't the item supposed to never be air? I think I looked at stash and it was always set to null. Spigot is very weird with this
Hand item is air
if(inventory.isAir())
cave air
like why have 2 seperate airs
Regardless: better safe than sorry
one is for cave ambient noises
and surely there was no better way to do that right
Wait until we get misty_air in the "swampy & spooky" update (mc 1.36)
yep im waiting for it
1.13 was 2.0
because breaking changes
right after the "stalker" gets added that annoys the fuk out of you when you sleep too much
Every ver is breaking
And leprechauns that randomly switch items in your sorted chests
we'd have like 20.0 at this point then
lmfaooo noooo
Haha, almost didn't read that properly

And thought you referred to phantoms
👀
Imagine needing little mouse traps so mice dont eat all your grain...
I could cook up so many annoying things in mc
like yggdrasil?
i found it so funny whena gamerule was added to disable phantoms
like even minecraft knows it was a shit idea
<dangerous illness> sim when?
"You got a headache and cant mine because its too loud"
kinda a dumb question but how would i register a command executor for a command?
i forgor
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
theres a bukkit method where you put in the command name as in your config and then the class that extends the executor
alr thanks
You like Jared Leto?
wym?
Wasnt he this vampire marvel thingy?
wdym. Why did you name yourself after this cringe vampire marvel movie with Jared Leto then...
Im just fking with you 
Delete it
chop it with a giant axe
Just use a Firewall
hm thats an idea
can i just block all outgoing connections of a folder or smth
im under windows
echo "yggdrasil-server 127.0.0.1" > dev/hosts or something like that
was excited to test my new plugin but then i remembered that i didnt register the listeners 😐
ah well that'd solve the yggdrasil one but not the potential others there are
i really need a general solution
also that'd probably screw the servers that i want to connect to the net
locality's an issue here
Install a security manager :blobsecurity:
In the HopperInventorySearchEvent, how can I tell if this was triggered by a hopper or a minecart? How should I get this hopper minecart?
i think you can get the inventory it came from and check what that inventory belongs to
Get the Inventory -> Get the Holder -> Check if its instanceof BlockInventoryHolder or HopperMinecart
I think the inventory provided by the event is the container's inventory not the hopper's
Ah makes sense. Let me check the event again
Looks like this event might only be fired for hopper blocks?
It extends BlockEvent which means getBlock() should return the hopper.
Hello, i'm making a hologram armorstands using nms packets
showing the armorstand to the player and make it visible bla bla bla
and everything is working perfect, and the issue is when i go too far and the chunk that includes the armorstand made in packets unload and then i go back to the armorstand and the chunk loads again the armorstand will not be visible again, so what's the issue is?
and i can provide a code if needed.
Are you sure that its a virtual armorstand?
Do you hide the hologram if a chunk unloads?
I've tested that the hopper minecart triggers too, it's weird
What does getBlock() return in case of a minecart?
i'm 100% sure the armorstand is made using packets.
this.armorStand = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle()); // that's the armorstand.
// ========
PacketPlayOutSpawnEntityLiving spawn = new PacketPlayOutSpawnEntityLiving(this.armorStand);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(spawn); // and that's how i show the armorstand to the player.
``` hopefully this helps, btw the armorstand and the player 100% is a true value and nothing wrong with the code
there's a more code for titles.. etc
hello i have a probleme in inventory.
if(event.getCurrentItem().equals(new ItemStack(Material.SPAWNER))) {
i click on a spawner but no. This condition return false every times. i did a mistake?
The block where the hopper minecart is located
oof. That sounds like a bad design choice.
Well then get the nearest minecart in that block.
When do you hide holograms?
i don't hide the armorstand by any chance, when the player leave the server the hologram will be destroyed
This is bad if many hopper minecarts are in the same block:(
What version are you on?
1.8.x
Lol
Ask someone else for help then
Depending how its done, not necessarily true. Visually it may go away but if you dont take care of some code it may still technically exist
did i something wrong?
?1.8
Too old! (Click the link to get the exact time)
^
nonsense the players wants a 1.8 pvp server sadly
Maybe there's a new event, maybe it's fixed, but who knows because you're living 8 years in the past
1.8 is a minority bubble community.
The audience is shrinking with each day.
1.8 has its place but asking for support on software that
is almost a decade old is what bothers me.
isnt there old versions of the api online
*sad hypixel noises*
1.12.2 has such a low percentage???
What do you mean low? Its on par with 1.8
And apearantly this is the biggest community in mc 🙂
honestly unless its 1.12 or 1.8 your mc version equals the power of your computer
lol
I remember my friend would play 1.15 and 1.12.2- because his computer was shit
couldnt be me
coughs in 2 GB ubuntu
yes i have 2 2 GB 128 Drive ubuntu computers why do u ask
Damn
It's always "Hypixel uses it so it must be good"
nah it's '1.9+ is shit'
I just wish people would stop trying to be Hypixel and make something new and unique
im not trying to copy hypixel but im not doing minigames much either
Like, yes with 1.20 you can't perfectly replicate 1.8 PvP. However, there is just so much more you can do with 1.20 that makes 1.8 look like a cheap knockoff.
well u cant have stable UPS with 1.20
UPS?
Apparently not. Well back to the true best version beta 1.2
eh i prefere 1.5.2
Does he mean tps maybe?
maybe
i saw this collect money from mcdonalds
1.7.3 beta was pretty sick
cant remember what the right name was
Buy a better CPU & RAM™️
In that case: You can optimize a lot in 1.20
The heaviest things are vanilla features like giant chunks
with a ton of tickables in them. If you have minigames
then that does literally not matter. Just learn how to optimize
the game for your needs.
why so?
oh nvm, you're most likely trolling haha
It added pistons
oh
i don't know much about the beta, i just remembered playing uhm 1.4
the version potatos and carrots were added
I started playing Minecraft in 1.5
People always forget hypixel is hypixel because they did a load of cool shit slowly.
Then everyone and their mum tries to recreate it from scratch and it ends up unoriginal as you cannot realistically create something that vast without the cheat of copying
I personally never tried recreating hypixel
Because that is the most unnecessary shit ever
Method invocation 'getAttributeModifiers' may produce 'NullPointerException'
how can i prevent this? it does produce NullPointerException but i want the MultiMap for attribute modifiers
That is an IntelliJ warning telling you that invoking that method can cause a NullPointerException to occur
Check that the instance you're invoking the method on isn't null
ItemStack item = new ItemStack(material);
ItemMeta itemMeta = item.getItemMeta();
Multimap<Attribute, AttributeModifier> modifiers = itemMeta.getAttributeModifiers();
ArrayList<String> lore = new ArrayList<>();
if(stats.size() != 0){
for (Stat key : stats.keySet()) {
lore.add(ChatColor.RED + key.getName() + ": " + ChatColor.GRAY + stats.get(key));
modifiers.put(key.getAttribute(), new AttributeModifier(key.getName(), stats.get(key) * key.getMultiplier(), AttributeModifier.Operation.ADD_NUMBER));
}
}
lore.add(ChatColor.GRAY + additionalLore);
lore.add("");
lore.add(rarity.getColor() + "" + ChatColor.BOLD + rarity.getName() + " Item");
this is the code im using it in
and i cant just do new AttributeModifiers()
do you get an npe
I gave you the answer, man :p
It says that because ItemMeta could be null I think
yeah
but its not
I always just put a if(itemMeta == null) return; just to remove the warning
?paste the error and the full class of where the error occured
Or assert itemMeta != null
in seperate pastes
alr
nvm theres a more serious problem than this
i may only be able to paste the full class. is that alright?
if you dont have the error we cant fix it
okay but the error is in my RDC server so it may take some time to get it to you
how do you know there was an npe without the npe on ur screen
try{
p.getInventory().addItem(HypixelCustomItems.getPlugin().getItem(args[0]).build());
p.sendMessage("SUCCES!");
}catch (Throwable e){
try {
p.sendMessage(e.toString());
}catch (Throwable e2){
p.sendMessage("error");
}
}
with this
wtf
that just hurts
why are you try catching a sendMessage
you should be using e.printStackTrace()
i thought e.toString() would not work
Lol catching throwable
im new to java
Amusing piece of code right there
why am i unable to save the code in ?paste
let me guess, its all 1 class and 2 thousand lines long
and the error?
leme just rebuild the plugin with e.printStackTrace and i will tell you
See convos like this make me wanna do a unit testing guide 😅
Hi, I want to ban one nbt tag when setting up a stand! At first I found information about Persistent Data Container, but it does not work with nbt tags from minecraft. I've also seen nbtcompound, but I don't have it. I tried the netapi and powernbt libraries, but each did not want to work in its own way, I did as they have on the wiki. How can I remove the "Pos" tag from Armor stand in the playerinteractevent event? Below is the nbtapi error who is interested (2.11.2)
https://i.ibb.co/X29py7t/18.png
https://i.ibb.co/RHqSP0J/20.png
change the code to ```java
Multimap<Attribute, AttributeModifier> modifiers;
if (itemMeta.hasAttributeModifiers()) {
modifiers = itemMeta.getAttributeModifiers();
} else {
modifiers = ArrayListMultimap.create();
}
ok thx
Anyone got a clue how I could go about making blast proof glass like in hypixel? I have adjusted the hardness of the glass very high, so when tnt is placed behind glass it works (like this https://i.imgur.com/WFWI2cW.png)
However when tnt is placed on an edge (like this https://i.imgur.com/GB6Ibkr.png) the wool breaks when the tnt blows up. Any suggestions?
Is there a tnt blows the hell up event?
Yeah there’s an event
But just removing the glass from the event won’t prevent it from destroying the wool behind the glass
^^
Particle.SOUL has variations - https://minecraft.fandom.com/wiki/Particles#Particle_textures
How can i spawnParticle only with 1 variant?
Yeah its really puzzling me
I was going to ray trace it but the actual distance between the two doesnt seem to detect the glass because its on a corner
so there isnt technically a block inbetween them
sand soul?
yeah
you dont need extra data unless its a particle that has variations
yeah but its spawns different types of this particke
u can see in this link
im pretty sure thats a timing thing you cant affect
also my particles spawns in different locations
also in different y
@EventHandler
public void onEntityDead(EntityDeathEvent e){
LivingEntity entity = e.getEntity();
if(entity.getType() != EntityType.DROWNED) return;
Location loc = e.getEntity().getEyeLocation();
System.out.println(loc);
entity.getWorld().spawnParticle(Particle.SOUL, loc, 3, 0,0,0, 1);
}
offset is 0
The middle of a block is 0.5 iirc
That's how particles work ig
also if i put count = 1 i dont see any particle
Is it allowed to add this in spigot page
If you want other payment method buy here (Polymart/ BBB)
Ping me imma busy irl
What's the difference between the profile field and the serializedProfile field?
One contains the profile as an nbt compound.
Why would you need to worry about that? Dont touch either.
Cannot invoke "net.minecraft.nbt.NBTTagCompound.equals(Object)" because "this.serializedProfile" is null
Do you have any idea how to fix this?
I edited the profile field so I can set the texture
Spigot has an api for that. No need to use reflections or nms.
is that new?
ok thanks
Use PlayerProfiles
oh I see, thank you for your help
Since 1.18.1
is there any way to make intellij add annotation not like this:
but like this instead
Sure, just edit your code style
how can i modify a block's drops
while autogenerating
i cant find
the setting for it
i've tried searching it in code style
BlockDropItemEvent
nvm i will just spawn an item at the block's location on the BlockBreakEvent
i mean this is arguably better because then you can do:
@NotNull List<@Nullable Object>
a bit easier
Or, you just use the BlockDropItemEvent...
i dont wanna register an additional event, add an onBlockDropItem to my abstract class Custom Item and rewrite my logic twice
What are you fabricating there?
nvm i have to use BlockDropItemEvent
Have the new versions already removed nbtcompound? I just don't have it for some reason
I am a newbie in coding and I do not know which version of spigot is in intellji
(plugin "MinecraftDeveloping")
?nms
thats the --remapped thing right?
I tried to find out what the problem was, I even added the spigot 1.18.2 kernel to the project, but there was nothing related to nms or nbt tags
Okay
e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), new ItemStack(e.getBlock().getType()));
why isnt this working
no errors no nothing
@Override
public void onBlockBreak(BlockBreakEvent e){
if(!allowedBlocks.contains(e.getBlock().getType())){
e.setCancelled(true);
return;
}
e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), new ItemStack(e.getBlock().getType()));
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent e){
if(e.isCancelled()) return;
if(e.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR) return;
if(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(HypixelCustomItems.getPlugin().getItemKey(), PersistentDataType.STRING)){
HypixelCustomItems.getPlugin().getItem(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().get(HypixelCustomItems.getPlugin().getItemKey(), PersistentDataType.STRING)).onBlockBreak(e);
}
}
💀
?
Variables exist
That takes longer than creating variables though
ctrl+c ctrl+v
doubling the drops of wood
Don't cancel the event for that
public class DuperAxe extends CustomItem {
private ArrayList<Material> allowedBlocks = new ArrayList<>();
{
setId("DUPER_AXE");
setMaterial(Material.STONE_AXE);
setName("Duper Axe");
setRarity(Rarity.RARE);
setAdditionalLore("Double Wood Drops!");
addStat(Stat.SPEED, 10);
addStat(Stat.HEALTH, 5);
allowedBlocks.add(Material.OAK_LOG);
allowedBlocks.add(Material.BIRCH_LOG);
allowedBlocks.add(Material.DARK_OAK_LOG);
allowedBlocks.add(Material.JUNGLE_LOG);
allowedBlocks.add(Material.ACACIA_LOG);
allowedBlocks.add(Material.SPRUCE_LOG);
}
@Override
public void onBlockBreak(BlockBreakEvent e){
if(!allowedBlocks.contains(e.getBlock().getType())){
e.setCancelled(true);
return;
}
e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), new ItemStack(e.getBlock().getType()));
}
}```
You can just edit the drops directly
im cancelling to prevent breaking any other block with this axe
BlockDropItemEvent?
Yeah
There is no <version>1.18.2-R0.1-SNAPSHOT</version>
only 1.20
alr
?
They both exist
you didnt use buildtools on 1.18.2
That's not what the guide tells you to use though
you put spigot-api instead of spigot
Did you run build tools like the guide told you to
how can i add block drops using BlockDropItemEvent Exactly?.
You need to be in the folder with the BuildTools jar
wrong folder?
I just forgot to download XD
🥲
You can't directly. You'd have to manually drop items
In this case you can
If i drop buildutils in external libs this can work?
how?
Since they want to double the existing drop
You can just get the existing drop and increase it's amount
Oh I did not read about that. Only the last question
i dont think thats gonna work...
Well it's an item and it has getItemStack.
ItemStack has a setAmount()
So it could work
Well try it and see
You can remove them. You aren't allowed to add any
yea i mistyped
e.getItems.set(0, (Item) new ItemStack(e.getBlock.getType(), 2))?
no
So, I download buildutils
you have to mutate the itemstack i think
Get an item, get the item stack and set the amount
is there any examples on the web for this or something
declaration: package: org.bukkit.entity, interface: Item
declaration: package: org.bukkit.inventory, class: ItemStack
but the e.getItems() only accepts Item interfaces
You are not supposed to add anything to that list
wait im dumb
Take one from the list and go through the functions mentioned above
e.getItems.get(0).getItemStack().setAmount(2)
yes
thank you so much
Keep in mind that the list might be empty or have multiple items (breaking a chest). So you need additional checks. But basically that's what you do
And if you want to take fortune into account you should set the amount to getAmount()*2
that did absolutely nothing
e.getItems().get(0).getItemStack().setAmount(2);
lemme just spawn the item
its so hard to code with 6gb of ram and 2 cpu cores omg
2 cores 👀
its a 10yo asuz laptop
and when i had to choose between a gen Z latop and an xbox...
Bro I have worse pc
exactly what I want, thanks
8 year old 4 gb ddr3 200 gb HDD no gpu dusty motherboard shitty cpu
It can barely run intellij and google at the same time
You can probably upgrade that
😭
Add some more ram
The problem is, I don't have money lol
what is the difference of dropping an item vs droping an item natuaraly
Yeah, naturally just gives it a random offset
Think more like what happens when you break a block. It kinda sputters off at a random offset
Should have been a boolean parameter tbh, but meh. Old Bukkit
Could add a third method with the boolean and deprecate the old ones
Nah. Not at all worth it
It would be a trivial change with practically zero benefit
Well then add an offset parameter to it - there's your benefit :p
Can anyone teach me command encoding of more than 2 words? Like:
/kits create . . .
/gm setup
*command more than 2 words🗿. Yes, I don't know the term
I have a plugin that plays a sound when 🗿 is in the chat, It scared me out lmao
@chrome beacon Thx for help, now I have nbttagcompound
You mean adding prefixes
??
Yep😅
Try to use switch statements
Idk seems like it'll do the job
Check if the user gives an arguement
Then use switch statements to check if that argument is the thing u wanted
Like "create"
"Setup"
Tbh I don't really know if that works lol
I'm just a mere beginner
Seems like it'll do the job though
Sorry for the terrible explanation, my english isn't fluent.
Or idk maybe theres a better way? Ig so
better than if else chains
What my way?
yea
switch is slightly bigger but has constant access time
if-else is done sequentially
switch just jumps
Holy shit I used my brain for the first time
i'm trying to spawn an entity armorstand w/ nms packets
everything works fine, but when i go far away like 100 blocks away or so
the armorstand disappeared for no reason
that's my code:
Location loc = this.location.toBukkitLocation();
World worldServer = ((CraftWorld) loc.getWorld()).getHandle();
this.armorStand = new EntityArmorStand(worldServer);
this.armorStand.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
this.armorStand.setGravity(false);
this.armorStand.setCustomNameVisible(true);
this.armorStand.setCustomName(Major.C(this.text));
this.armorStand.setInvisible(true);
this.armorStand.setSmall(true);
// this.rainbowCheck(hologram);
((CraftLivingEntity) this.armorStand.getBukkitEntity()).setRemoveWhenFarAway(false);
worldServer.addEntity(this.armorStand);
``` and the line `worldServer.addEntity(this.armorStand);` when i add it the armorstand disappears so i put a comment behind it
isnt that entirely dependent on client entity distance when it does?
you might wanna look into entity tracker
can you explain more? cuz i have no clue what are you talking about
all the entities are tracked by a class and when they're far away they get despawned from players
you must circumvent your problem in there
uhmm i can do something like check if the player go far away and comeback
but why the armorstand disappears when i go far? i tried to check the events or the chunks
I previously used this
plugin.yml
commands:
create:
description: abcde
usage: /kh create <argument>
#same in below
That doesn't seem to be the right thing🥴
as i told you, they are removed from players who are far away
you need to edit the entity tracker
Me have no clue tbh, is that something in spigot api?
onpe, it's in nms
I'll give it a shot
public Set getSet() {
Set<Material> materials = new HashSet<>();
materials.add(Material.OAK_LOG);
materials.add(Material.BIRCH_LOG);
materials.add(Material.SPRUCE_LOG);
materials.add(Material.DARK_OAK_LOG);
materials.add(Material.JUNGLE_LOG);
materials.add(Material.ACACIA_LOG);
materials.add(Material.MANGROVE_LOG);
materials.add(Material.CHERRY_LOG);
materials.add(Material.CRIMSON_STEM);
materials.add(Material.WARPED_STEM);
return materials;
}
public double getXPValue(Material material) {
double xp;
switch (material) {
case OAK_LOG:
xp = 3;
return xp;
case BIRCH_LOG:
xp = 3;
return xp;
case SPRUCE_LOG:
xp = 3;
return xp;
case DARK_OAK_WOOD:
xp = 2.5;
return xp;
case JUNGLE_LOG:
xp = 2;
return xp;
case ACACIA_LOG:
xp = 3;
return xp;
case CHERRY_LOG:
xp = 5;
return xp;
case MANGROVE_LOG:
xp = 5;
return xp;
case CRIMSON_STEM:
xp = 4;
return xp;
case WARPED_STEM:
xp = 4;
return xp;
default:
return 0;
}
}
}```
Is there a way that I could improve on this? Making it more efficient?
Use a map.
use an enum map instead
whats that?
it's a map specially designed for enums
it stores elements more efficiently
Like this?
public class ForagingSet {
private Map<Material, Double> xpValues = new HashMap<>();
public ForagingSet() {
xpValues.put(Material.OAK_LOG, 3.0);
xpValues.put(Material.BIRCH_LOG, 3.0);
xpValues.put(Material.SPRUCE_LOG, 3.0);
xpValues.put(Material.DARK_OAK_LOG, 2.5);
xpValues.put(Material.JUNGLE_LOG, 2.0);
xpValues.put(Material.ACACIA_LOG, 3.0);
xpValues.put(Material.MANGROVE_LOG, 5.0);
xpValues.put(Material.CHERRY_LOG, 5.0);
xpValues.put(Material.CRIMSON_STEM, 4.0);
xpValues.put(Material.WARPED_STEM, 4.0);
}
public Set<Material> getSet() {
return xpValues.keySet();
}
public double getXPValue(Material material) {
return xpValues.getOrDefault(material, 0.0);
}
}```
Basically, yes.
but?
EnumMap.noneOf(Material.class); instead of new HashMap();
^^
it is in term of what the implementation is
Each map has it's own features, like sorting, etc.
for enums you don't have to compute hashes
it just uses ordinal
and an array of values
OAK_LOG(3.0),
BIRCH_LOG(3.0),
SPRUCE_LOG(3.0),
DARK_OAK_LOG(2.5),
JUNGLE_LOG(2.0),
ACACIA_LOG(3.0),
MANGROVE_LOG(5.0),
CHERRY_LOG(5.0),
CRIMSON_STEM(4.0),
WARPED_STEM(4.0);
private double xpValue;
private Material(double xpValue) {
this.xpValue = xpValue;
}
public double getXPValue() {
return xpValue;
}
}```
you mean like this?
this is even better
xD
but you can't use the material properties
idk, you might laugh but i asked chatgpt to convert my code to an enum
i dont really understand any of it
A map is like key-value store, but each instance does it's things, mostly sorting, optimization, specific tasks, general purposes and so on.
okay, but why are enums prefered over normal classes?
Well, enums are static, classes are not.
They have different purposes as well, like, a class can do much more.
What r u doing
Just register the kh command
And I think you should ask for advice on others because I've only been coding in java for like 4 days
I still have alot of stuff to learn
I dont think that's how it works
Tbh I don't really know lol
I'm just relying on common s3nse rn
I'd avoid the use of enum map just so you know materials days as an enum are numbered
so i shouldnt use enums?
No just don't use an EnumMap with material
so i should do it like this?
Oh if you're making an enum you can keep it I'd use a map personally but to each their own
like this?
Basically yeah
Just avoid the use of EnumMap
Which extends map
Using hashmap will be just fine
okay, i was told that it isnt as good, because enums are static and classes are not
Just make your class final singleton if you're worried about multiple instances
even if material as an enum is gonna be gone, which is not true since nothing is deprecated, enumsets and enummaps are the most efficient way to store enum keys
as far as i know material isn't deprecated
Underneath the hood their will be commodore doing the hard stuff with converting enum maps
But it'd be better if you just didn't force commodore to do anything to your code
uh?
I'd have to look at exactly what they do to material in the pr again
Are you not aware of the registry pr on the experimental branch?
I'm the same, it's only been 2 days
nope?
but i'm sure materials aren't gonna be gone anytime soon
so you're talking about materials or enummap?
What are you even making
they're actively being replaced
everything that implements Keyed will soon(TM) not be an enum anymore
hopefully its merged in 1.21
so you should not use an EnumMap for Material
You shouldn't be making hard stuffs when you have vague understanding of java ( says me who is absolutely making a hologram plugin with 300+ lines of nested code )
i see
if you have stash access
if you don't ^
this should work
what is that
it gets you an enummap of amterial in versions where material is an enum
and a normal map in versions where material is not an enum anymore
also wth is a @UtilityClass annotation?
its lombok
hm
unless jetbrains adds one too
makes sense
it's a pretty useless annotation and probably won't go into stable
I don't use lomkob anyways
I wish @ExtensionMethod was actually useful
there are some edge cases where ExtensionMethods would be nice if you add something to a type with NMS
but you have to copy paste @ExtensionMethod around literally everywhere you use it right now
and no IDE autocomplete for exntension methods too
Manifold definitely does it better atm
reminds me of kotlin
Can someone explain me the basic concept of changing a nametag with NMS packets and scoreboard?
just the basic, so i could done it with a way to follow
https://github.com/MrMicky-FR/FastBoard this scoreboard is all packets
check what they do
does manifold have tab complete
i just mean the nametag
i have a base, but i wanna get what exactly i was supposed to do
oooo
I need to create a new EntityPlayer with the same UUID of the player, with scoreboard prefixes?
Spawn it using PlayerInfo? or with NamedEntitySpawn too?
thats what i'm trying to mean
idk a ton about scoreboards which is why I sent you that API that's a really well executed one with packets
don't wanna an external API
look at their code?
i'm not telling you to use it
I'm saying look how this API does it because they executed their API very well
?paste
i just need to know which steps i need to follow
- Remove the player with REMOVE_PLAYER from the PlayerInfoPacket
- Create a new EntityPlayer with same UUID of the player
- Spawn this new EntityPlayer with ADD_PLAYER info packet
- Add name and tags with NMS scoreboard and send the packets
??
https://paste.md-5.net/kimixalucu.java
Can anyone help me? Details in the paste link
What does you mean exactly with doesnt works?
why are we not following java conventions either?
also what about it doesn't work
one works but the other one is not
error?
private Map<Material, Double> xpValues = new HashMap<>();
you are creating a new variable
at ForagingSet
class
why just not extends SkillSetBuilder
?
public abstract void Set() method in SkillSetBuilder is a bad method
i need to extends because i will create more sets with the same features
Set() -> set()
why small?
it's the java pattern for methods
ok
ClassName
methodName
fieldName
Classes are UpperCamelCase, methods and fields are lowerCamelCase
so, the problem with the two being, is that in the lower oen the set is empty
in the upper one, the set is like it should be
why are we just ignoring the set method is aboslutely useless and shouldn't exist
ofc its empty are you even calling the Set method
yes im calling it in a blockbreakevent
its crappy design just put it in the Constructor
why are you calling it every BlockBreakEvent
that's terrible overhead that's not needed
how should i know when the block is in the set if i dont call it ???
you don't need to fill the map literally every single block break is my point
why would you ever ever ever do that
@Override
public void Set() {
xpValues.put(Material.OAK_LOG, 3.0);
xpValues.put(Material.BIRCH_LOG, 3.0);
xpValues.put(Material.SPRUCE_LOG, 3.0);
xpValues.put(Material.DARK_OAK_LOG, 2.5);
xpValues.put(Material.JUNGLE_LOG, 2.0);
xpValues.put(Material.ACACIA_LOG, 3.0);
xpValues.put(Material.MANGROVE_LOG, 5.0);
xpValues.put(Material.CHERRY_LOG, 5.0);
xpValues.put(Material.CRIMSON_STEM, 4.0);
xpValues.put(Material.WARPED_STEM, 4.0);
}
this method just plain sucks it provides 0 value and a lot of confusion
move these put calls into a constructor
wdym constuctor
?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.
no
i dont know why there should be a constructor
no
im gonna guess ur Set method is never called
which is just a bad copy of what a constructor should do
i define the materials in the hashmap and then create a set through hashmap.keyset?
it worked before, but once i made an abstract class it didnt work anymore
Do you know what abstract does?
Yeah...
Then remove abstract. It makes the class not instantiable
As in to get instances of the class you need to extend the class - or more specifically all instances of the abstract class are direct instances of another class unrelated to the abstracts class' hierarchy.
you dont need a class to be instantiable to extend it? wym geol?
Hello, I would like to create a spigot plugin but I have a lot of trouble. To start, what is the best software to make your plugin? Do you absolutely have to use Maven? If yes, why ?
are you also asking about your ide?
im remaking a plugin which uses databases for saving player data, i need to store an array of itemstacks, how would you recommend me to do it?
if so, i would use maven and intelliJ
no. most people use it to not manually build their plugins, its an hour of annoyance then it helps.
Most people here use either eclipse or intelliJ as their IDE
Hm? I asserted that you cannot directly create an instance of the class if that is what you are misundestanding
I also have a problem, I don't understand why when I import a spigot library (server version), I don't have access when I create a class to "Java Plugin" (the essential class to create a plugin)
maven + IntelliJ is the easiest
No, maven is not a must
maven is shit
Okay so long story short the biggest benefit of java, and indeed why ive pushed you towards abstract classes, is that it is object orientated.
What Y2K is trying to explain is that Java is a lot like telling a story.
"Once upon a time there was a prince, who wore a yellow crown, blue robes and a nice pair of shoes. The prince (who wore a yellow crown , blue robes and a nice pair of shoes) lived in a castle that had white bricks and a moat. When the prince (who wore a yellow crown , blue robes and a nice pair of shoes) walked around his castle* (Which had white bricks and a moat)** they realized there was a stray cat **with orange fur *walking around. The prince (who wore a yellow crown , blue robes and a nice pair of shoes) chased the cat (who had orange fur) around his castle (Which had white bricks and a moat) all day long"
*"Once upon a time there was a prince, who wore a yellow crown, blue robes and a nice pair of shoes. The prince lived in a castle that had white bricks and a moat. When the prince walked around his castle, they realized there was a stray cat **with orange fur *walking around. The prince chased the cat around his castle all day long"
One of those stories is a lot easier to read than the other.
The reason?
Context
Once the things (the king, the castle, the cat) had been defined in context, there is 0 need to write all their details out again.
I imagine the reason Y2K has pushed so hard in terms of constructors and good practice is simply this: You are missing out on the greatest strength of the language you are trying to learn.
Its like having bread without butter.
Its like having fish without chips.
Bangers without mash.
Java allows you define "objects". This is what, in most cases, a class should actually be.
E.g:
Lets say you made a "King" class. You could give it 2 fields like this:
public class King {
private String name;
private String robeColor;
private boolean hasNiceShoes;
public King(String name, String robeColor, boolean hasNiceShoes) {
this.name = name;
this.robeColor = robeColor;
this.hasNiceShoes = hasNiceShoes;
}
public String getName() {
return name;
}
public String getRobeColor() {
return robeColor;
}
public boolean hasNiceShoes() {
return hasNiceShoes;
}
// You can add other methods and behaviors here if needed.
}```
I can then call this class like this:
```java
public class Main {
public static void main(String[] args) {
King king1 = new King("King Arthur", "purple", true);
King king2 = new King("King Richard", "gold", false);
if(king1.hasNiceShoes){
System.out.println("The first king has nice shoes")
}
}
}
The trick is that code is now tiny. Its because king1 has been defined as an object.
Now imagine if i had to redefine what the king was every time i wanted to use it.
But lets say now you wanted a queen too... well a queen has robes, a name, nice shoes etc.
So now we would need to make a whole new class for queen! Waste of time and lots of code not needed.
So instead we could use an Abstract to make a "Monarch". And then have a king and queen class that extends monarch.
Part 2 incoming
how so?
?paste
You can use Gradle or manually fetch the dependcy from spigots maven lib
Everyone who says maven is shit either hasn't worked with it or doesn't understand how it works
Intellij + Maven, and not Visual Studio Code + Maven? Because I code in python with it and I think it's great, but I'll listen to you ok ^^
And you think groovy is better?
i just imagined it, it was nice
kts?
VSC should also work generally
Isn't that just reskinned groovy?
why the fuck would you use VSC
if it works well together with maven, sure
it opens faster
I haven't seen the appeal yet
however IntelliJ is probably much easier and doesn't require 100 plugins to make it work
in IntelliJ everything just works out of the box
and I can only repeat myself, here's my 100% foolproof tutorial for IJ + maven https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
100 reasons to use gradle over maven:
I download IntelliJ, i watch so many tutorials but most of them are not updated ...
abstract class Monarch {
private String name;
private String robeColor;
private boolean hasNiceShoes;
public Monarch(String name, String robeColor, boolean hasNiceShoes) {
this.name = name;
this.robeColor = robeColor;
this.hasNiceShoes = hasNiceShoes;
}
public String getName() {
return name;
}
public String getRobeColor() {
return robeColor;
}
public boolean hasNiceShoes() {
return hasNiceShoes;
}
// Abstract method to be implemented by subclasses
public abstract String getTitle();
}```
Now you have made a monarch abstract, look how tiny we can make king and queen!
```java
class King extends Monarch {
public King(String name, String robeColor, boolean hasNiceShoes) {
super(name, robeColor, hasNiceShoes);
}
@Override
public String getTitle() {
return "King";
}
}
class Queen extends Monarch {
public Queen(String name, String robeColor, boolean hasNiceShoes) {
super(name, robeColor, hasNiceShoes);
}
@Override
public String getTitle() {
return "Queen";
}
}
So the reason everyone @inner mulch is ragging on at you isnt to be mean or push you to learn the new stuff. its because you are on the cusp of learning the greatest part of Java, and it'd help you a tonne! 😄
?paste
before someone else does 😉
want me to just guide you through setting IJ up for minecraft in dms?
well I sent you a blog post twice already
I hope that helps and at the utter least gives you an appreciation for why everyone is trying so hard to push you to learn Constructors, Abstracts and interfaces 🙂
Yes i watch your tutorial, i install Intelij
https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/ < explains every single step to get a working .jar
i will try to rewrite the code, thank you for the explanation
I don't think there is much use in overwhelming beginners with this BS
@stuck imp ur blocking DMS
I beg your pardon?
Sadly I am on mobile so typing speed is massively reduced for me
I'd suggest going back to bare basics and asking "why is java used? How is it used? What am i trying to do with it".
Object Orientated programming is a headache when you first start
but moment it clicks
b.isPreferredTool(new ItemStack(Material.IRON_SHOVEL)) && !p.getInventory().getItemInMainHand().getType().toString().endsWith("SHOVEL")
why it gives true when I dig a grass block with a shovel?
boom a whole world of posibilties opens up
Before you write anymore code i'd legit suggest watching this fully through (it has twists and turns and realisations that even I didnt realise until a few weeks into Java development https://youtu.be/drQK8ciCAjY?list=PLkeaG1zpPTHiMjczpmZ6ALd46VjjiQJ_8)
Learn all the essential basics of Java in one video in just 15 minutes. No programming experience required.
Complete Java Course: https://codingwithjohn.thinkific.com/courses/java-for-beginners
Variables, loops, methods, classes, objects, and more!
This is a Java beginner's lesson for the ultimate Java beginner, or just someone curious to know...
the better question is, why do you create a new iron shovel itemstack every time?
it's not better
?paste
would using /summon trigger a spawn entity packet being sent?
No, but the existence of the new entity would
how would you create a new entity?
World.spawn
@stuck imp You can use this link to get proper API jars
You preferably use the shaded ones
Maven is superfluous overhead when beginning to learn a programming language. Even more so if one already is comfortable with an IDE like VSC there is little reason to make them switch
Maven is useful, but only once you have already nailed down the essentials
tbh if you explain it as 'copy this into that file and replace those two spots with your project name and minecraft version' its not that difficult lol
i saw some gluten free breaded chicken schnitzels in costco earlier
But simply adding the jar as a dependency is easier nonetheless, I must agree with that
Especially as most beginner tutorials dont begin with maven, making it even more confusing
it will not work
i did maven specifically because dependencies were absolutely fucked for me
Is it a pain if you have many dependencies? yes. But it doesn't matter if you just work with spigot
i did
Hence I did the resolution for you by providing the direct link
i added the spigot dependency jar from the thing geol linked
no matter what i did it refused to recognize it
so eventually i said fuck it and just ran buildtools and cleaned out the project
You can't add the spigot.jar that is your server jar with the newer versions, as the classes are packaged within other files within the jar, hence your IDE won't find it. You'd have to specifically import the Spigot API
i know that, and i did use the api
(you can check for yourself by checking for module-info.class files)
If those exist I'll have a stroke
i mean i have since switched computers and not used anything but maven
if i find my old drive sure
Because apparently everyone is too incompetent to shade stuff
🤷 I haven't been using maven for like 3 or 4 years since I started working with spigot
i used maven for 1 project then swapped to gradle
Meanwhile I used Gradle for 1 project and switched to maven lil
Although before I always used JDT
I used both and maven is a lot more comfortable imho
im too lazy to learn gradle
Gradle is comfortable when you have spend hours getting to know the annoying shit
It can be used pretty freely without though
i used to just use the IDEs artifact builder
Can affirm
I have this error with your example config
but then i started actually needing dependencies
My first time coding i used that too articfact export
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
used Gradle at first but debugging with it took foorrreeevvvveerrrr
switched to Maven and never looked back
continue reading the blog post
jk i actually just stopped having workflows that benefit from gradle over maven
How i reload Maven project ? Yeah didn't saw this step
just continue reading...
there is a huge screenshot telling you how to reload maven
am i stupid or is minecraft stupid
Just click on Maven in the top right corner, and then hit the Reload All Maven Projects button.
That was small icon but work
To be fair, top right corner isn't exactly clear. It's technically in the top left corner of the maven panel.
it says "maven tab in the top right corner" and then shows a screenshot of th ebutton
format it
neither, just floats being floats
round it off or somethin
I added a red square, I hope it's clear enough now
In this part, i don't understand : The most important part in your plugin.yml is the main part. It tells Spigot where the Main class of your plugin is located. The most commonly used convention for choosing the name of your Main class is this:
<yourGroupId>.<yourPluginNameInLowerCase>.<YourPluginName>
again, my suggestion is that you keep reading the next sentence
!img
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
!verify
Usage: !verify <forums username>
!verify XDorgLuck
A private message has been sent to your SpigotMC.org account for verification!
Can you explain me in my config for analyse what is my groupid and pluginname please ? https://zupimages.net/up/23/31/wh4b.png
Your main path should be org.xdorg.Main
you seem to have problems in reading the post sentence for sentence, and following its precise and clear instructions
main in the plugin.yml refers to the path to your main class.
I'm not English and sometimes it's not detailed enough, I'm a complete beginner in java even though I know how to code in python
The post is aimed at beginners and uses simple language
Alright, thanks 🙂
your main class should be called org.xdorg.partnership.Partnership
and the "main: " part in plugin.yml should have the same value
Except that's not where his main class is.
yes, that is why I mentioned it?
So, what do i use ? org.xdorg.partnership.Partnership or org.xdorg.Main on plugin.yml ?
alright
and also for the "main" value in plugin.yml
you will need to refractor tho
Refractor is it reload or something else?
ok it's good
I have not finish, but i continue reading the tutorial, thanks ^^
Strange, but i don't have the gray "msg" same as exemple, do you know why ? https://zupimages.net/viewer.php?id=23/31/tjym.png
thats just an exaple
example
its only getLogger().info("Partership of XDorgLuckUniverse Load");
Ohhh i understand, i shouldn't mark the msg in the line of code, right?
no
So how do you fix it ?
bro what the fuck is zupimages 
I mean, it's pretty obvious, I included the copy/pastable source code literally in the post
this
that msg: is just a popup from the ide
Ok :), thanks for the info
?nms
Ok great ! Finally a tutorial work, thanks mfnalex and all people who help me 🙂 ^^
There is any other tutorials for create commands, and give stuff (like armor) ?
whats that in $
200$ monthly
bruh
💀
@sterile axle how much would you make
I'm gonna migrate
go to US software devs get payed the most here :P
Mhm, gotta save up money first to ensure that I don't starve to death and become homeless lol
well thats true but i would rather have a eh salary than sit on half a million in medical fees
no insurance?
or bad insurance that's when that would happen
insurance in us doesnt work like you think it does
I suppose I've never been in a severe enough medical situation to test out my insurance properly lol
go jump onto a car from 2nd floor
you can most likely get more if you expand ur skillset
eg more than just java and lua
that's not a great salary for software engineering
Mhm
webdev stuff is normally useful, or some scripting lang
webdev makes me wanna lose it
well a computer scientist is something different than a bachlors degree
but mainly c or its children or anything sim
Yeah I'm gonna spend 3+ years in java then move to c++, c and c#
oh true I didn't see the scientist part lol
that's a computer scientist
that's a 3 year university
Its 4 years here
"only"
maybe good for an internship
💀
I mean in perspective of other fields its a lot
i mean if you go to be a teacher 54k a year is a ton
Man I hate how I spawned in a 3rd world country
in a lot of european countries, computer engineers and computer scientists are treated the same
who said you need a degree to get hired at hypixel
i wouldnt wanna work with 1.8
for any money
or anywhere technically
I just got denied for Microsoft dev center lol
whats that
if you know enough i doubt some people would even care to hire you, you know more than they need
Basically Microsoft office they have in every country
defamation
hey, I am trying to get player's client version through protocollib but couldn't make it work properly for some reason, any idea why? (I have viaversion installed in spigot but trying to make it work even when viaversion is installed on proxy)
int version = ProtocolLibrary.getProtocolManager().getProtocolVersion(event.getPlayer());
```for some reason this returns the server's version and not client's version
any ideas?
whats that for
perhaps you are using viaversion
thats why
maybe
wdym
actually how the fuck does one work as a freelancer
i looked around out of curiosity and couldnt find squat
You'd usually have some company help you find work as far as I know
hi guy who know how to delete my resources?
that or get extremely lucky
report it and write "please delete"
thank
it still working >:
what?
you have to wait for it to be read
What packet does /summon send
You mean from client to server or the resulting spawn afterwards?
ServerboundChatCommandPacket
like any other command too
the resulting spawn
not the command
Ty
Huh?
they said thank you
Thank you
I got that. I was just buffled that this was his question.
what are you gonna do? sue me?
i would like to add that, i wasn't serious
@EventHandler
public void onJoin(LoginEvent e) throws SQLException {
DatabaseSettings databaseSettings = new DatabaseSettings();
FriendSettings playerInfo = databaseSettings.findPlayerByUUID(e.getConnection().getUniqueId().toString());
if (playerInfo == null) {
playerInfo = new FriendSettings(e.getConnection().getUniqueId().toString(), 0, e.getConnection().getName());
databaseSettings.createPlayerStats(playerInfo);
}
else {
playerInfo.setFriendrequests("online");
databaseSettings.updatePlayerStats(playerInfo);
}
}``` someone have any idea for that ?
why login event not working ?



