#help-development
1 messages ยท Page 328 of 1
not completely sure tho
before going on a witch hunt, do know that most who host servers don't know what they are doing to begin with and typically use more then just 1 plugin lol.
I'm trying to figure out why that would happen
yeah I know but I figured I might aswell check like check broadly
items are entities
like if its really as bad as people say it is then it should be easy to find some cause
ill try out spark
Does dropping an entity count as death?
yeah doesn't hurt to still check, but I doubt your plugin is going to be the primary cause of their problems
you cancel the EntitySpawnEvent to prevent entities that do not come from spawners
Like just throwing the item
items are entities that do not come from spawners
yeah it could also just be the fact that java just likes to reserve ram
Thank you
you said you wanted to prevent entities from being spawned lol
check if the spawned entity is instanceof Item, if so do not cancel it
or check if the spawned entity is instanceof Creature
just wait till you learn items have health ๐
and only then cancel it
np
if i make a plugin for the latest mc version will it work on older versions like 1.8?
no
only if you only use api that was already there in 1.8
because they only use the 1.8 api or have different modules per version
usually they create implementations for each version
when their code is version dependend
1.8 is dead anyway
pretty much
well yes but its pvp is still gold
no, its pvp is ajoke where all you gotta do is click very fast
in 1.9 you actually have to time your attacks
but sure, that's too complicated for most 12 year olds
both require skill
so they say "1.8 pvp is so gooood"
just differently
jumping and clicking is hardly something I would call skill
i don't remember saying my age so thank you for being respectful here
this behavior doesn't seem to be from an aged person tho
jump click eat a god apple or two
well pvp right now they dont fight at all
yes
i didnt say you're 12, all I said is that most 12 year olds prefer 1.8 because the 1.9+ pvp is too complicated for them
the new pvp which have a delay between trades actually breaks everything
that's a personal preference tho
but i prefer the old one
i do think the new pvp has been better for the game tho
it just fits the game better
so basically, there is classes for each version?
yes essentially
also keep in mind, MC isn't designed for hardcore pvp either
just use 1.8 api if you don't use NMS
then it should also work on all higher versions
you would depend on multiple API versions for the relevant changed interfaces etc or multiple server versions if using NMS
tho, only if required. like alex said for most stuff u can prolly just use 1.8 api
each module has their own dependency
alright
which means essentially. ur on ur own in those areas haha
since theres not many people here that would help out with 1.8 nms anymore
?1.8
Too old! (Click the link to get the exact time)
which is understandable
so in my case, i code using idea which asks you to choose a jdk version when creating the project. What version someone would choose to make his plugin compatible with most versions?
jdk 8, spigot api version 1.8.8-R0.1-SNAPSHOT
so just like the api i choose 1.8 as well
yeah but that's a coincidence
?jd
minecraft <1.16 uses java 8, 1.17 uses java 16, after that it uses java 17
i've choosen 1.8 for my project so i'm good
yeah
Ummmm
Hello. How can i put this elements in a item? {HideFlags: 4, Damage: 0, display: {Name: '{"extra":[{"text":"hola"}],"text":""}'}, AttributeModifiers: [{Name: "generic.movementSpeed", Operation: 0, UUID: [I; 1461744232, -864534134, -1964839385, 1725294635], Amount: 2.0d, AttributeName: "minecraft:generic.movement_speed"}]} if i have this list in the config.yml
i already told you yesterday
Bukkit.getUnsafe().modifyItemStack
yea, but it does not work
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
in what way?
Which event works when a hopper does stuff with items
InventoryMoveItemEvent
Tyyyy
should probably be carefull with that tho. depending on the server type
some have a lot of hoppers
Just gonna make a custom one
Some outright disable that event
Like a custom hopper I mean
yh
paper does it by default iirc
is there a reason this doesnt create the specified kingdom?
if (args[0].equalsIgnoreCase("create") && !plugin.getMember().containsKey(player.getUniqueId().toString()) && !plugin.getKingdoms().containsKey(player.getUniqueId().toString()) && !plugin.getKingdoms().containsValue(kingdom)) {
//player is not in a kingdom and kingdom doesn't exist
plugin.getKingdoms().put(player.getUniqueId().toString(), kingdom);
plugin.getOwner().put(player.getUniqueId().toString(), kingdom);
plugin.getAdmin().put(player.getUniqueId().toString(), kingdom);
player.sendMessage(ChatColor.WHITE.toString() + ChatColor.BOLD + kingdom + ChatColor.GREEN + ChatColor.BOLD + " created");
return true;
}```
As in the message is not sent or something else?
com.mojang.brigadier.exceptions.CommandSyntaxException: Expected '}' at position 45: ...{Name: '{'<--[HERE]
item = Bukkit.getUnsafe().modifyItemStack(item, "{HideFlags: 4, Damage: 0, display: {Name: '{'extra':[{'text':'hola'}],'text':''}'}, AttributeModifiers: [{Name: 'generic.movementSpeed', Operation: 0, UUID: [I; 1461744232, -864534134, -1964839385, 1725294635], Amount: 2.0d, AttributeName: 'minecraft:generic.movement_speed'}]}");
it doesnt send a message or create the kingdom
Does whatever type kingdom is implement hashcode() AND equals()?
no
that will be an issue down the road
Your actual issue most likely lies somewhere else though
why do u make strings of things like a uuid
only slows down the check & complicates things
computeIfAbsent pls
good to know
@tall dragon so you said to be careful with hoppers cause there's a lot right. I'm trying to think of a way of insantaly returning nothign if the event is something I don't need. What are some good ways to check if a hopper is at a specific location meaning the item below is a customchest
no need to check contains before removing
I assume getting the location of the event and checking block under is already resource intensive
try it without the "display" part
i.e. without setting the name. You can do that through the bukkit api manually either way
well in your case probably the most light check u can do is checking if the block above is a chest
fair
ok
first check the type tho
then continue with any check to make sure its ur custom stuff
can you save UUIDs to a file without .toString()?
yes you can
iirc ๐ฎ
as far as i know. in those cases that will be done automatically. without a toString call
but having a UUID as key in a hashmap vs the string version just doesnt make sense
u mean their order?
or actual different locations
no, you have to store them as list of strings.
// Save
myConfig.set("listOfUUIDs", listOfUUIDs.stream().map(UUID::toString).collect(Collectors.toList()));
// Load
listOfUUIDs = myConfig.getStringList("listOfUUIDs").stream().map(UUID::fromString).collect(Collectors.toList());
Can you change the player name above their head? (Using hex colors)
last time i did that, i did it using score board teams
but that was for 1.8 :s, api might have a better way now
thats the way I know too
you just need to figure out how to use hex colors on a scoreboard but other than that its doable
Hey so before I disabled natural mob spawning and only spawners but
I'm using a custom spawner plugin and I don't think it behaves the same way as normal spawners
So those got disabled too
How can I check that the entity spawned from that as well
Please for none coding related, you should use #help-server
it is coding related
It is code related wym
Alex I just realized entityspawnevent is a shitton of stuff
ofc it is
Gonna need 20 lines of checks but still have the different spawner issue
I tried looking at the code
You're fine. I'm trying to cancel normal mob spawns unless they come from spanwer
But using that spawner doesn't work with instanceof spawner
@EventHandler
public void prohibitMobsExceptFromSpawners(EntitySpawnEvent event) {
if(!(event.getEntity() instanceof Creature)) {
return;
}
if(event instanceof SpawnerSpawnEvent) {
return;
}
event.setCancelled(true);
}
shouldnt this be enough?
That's what I had
But the spawner doesn't actually count as a spanwer
So it doesnt spawn
and how can i do it?
then use the CreatureSpawnEvent and check the SpawnReason
@EventHandler
public void prohibitMobsExceptFromSpawners(CreatureSpawnEvent event) {
Location loc = event.getLocation();
Bukkit.broadcastMessage("CreatureSpawnEvent near you at " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ": " + event.getEntityType());
if(event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.SPAWNER) {
Bukkit.broadcastMessage(" --> Cancelled not-spawner spawn");
event.setCancelled(true);
}
}
this definitely works
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
no context andy
That spoonfeed is fine
Ignore him he has no idea what was going on
he clearly has already debugged and attempted, pushing him to know spawn reason will work when the event isnโt a SpawnerSpawnEvent is fine

Hey guys, im getting a java.lang.ClassNotFoundException: io.netty.util.internal.ThreadExecutorMap at the tests folder, but ive already defined the dependency...
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>5.0.0.Alpha2</version>
<scope>test</scope>
</dependency>
(maven compiler sucks)
are you sahding it?
you mean shading?
And shade the dependency
how i can shade for the tests folder? (i mean that foldeer)
hello. is possible to save custom items with a menu?
The normal shading will affect the tests too?
hey ive got a question when using an sql database can it be hosted on the minecraft server?
and how would i connect to that
i dont found any article about the tests folder
Using OpenNBT, how could I make a dictionnary that uses other classes than int/string for storing data?
Like If I need to store a location object, how could I do it? Since OpenNBT only allows you to store primitive data types
what you mean
I want to put items in a chest, and get the items with all the propierties.
?paste
okey so i don't need to host it apart somewhere?
Same https://paste.md-5.net/adeqekugas.xml (my pom.xml)
good thx
still getting a ClassNotFoundExc
i didnt relocated
i need?
bro maven compiler: ๐ฉ
You marked it has provided don't shit on maven lol
Tbf it's your mistake not mavens
i know
its not provided
look at the last dependency
5.X.X is not the netty version you want
Unless you are insane
๐ค that makes sense, i will try others
Use 4.X.X, which is actually maintained
xD
Hey so I'm running FurnaceSmeltEvent but when I get to
event.getBlock().getType() != Material.FURNACE || event.getBlock().getType() != Material.BLAST_FURNACE
it fails
It thinks it's false
?paste full method
do a debug
@EventHandler(priority = EventPriority.HIGHEST)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
plugin.logger.info("Furnace smelt event called");
if (event.getBlock().getType() != Material.FURNACE || event.getBlock().getType() != Material.BLAST_FURNACE) return;
plugin.logger.info("Furnace smelt event passed");
I checked to make sure and event.getBlock().getType() actually returns the right thing
what messages do you get
FURNACE and BLAST_FURNACE
Just the first
I know it's that time
It happened out of nowhere, was working before
do a debug
are you blind
plugin.logger.info(event.getBlock().getType())
sysout be like
ive got no idea
lmao
oh im sorry xDDD
can any other blocks actualyl call furnace smelt event
np still can't seem to understand wtf
You know I was thinking about that epic
but
Why would it fail anyways
It was working before
thats weird asf
What other events interact with furnaces
Maybe I'm screwing something up elsewhere
InventoryMoveEvent
might be one of the prepare events
that methods is suppose to do not show the second message if the block is a FURNACE or BLAST_FURNACE, right?
it should
yeah
it should return if it isnt a furnace or blast furnace
wait no
but it shows the second message even if the block is a FURNACE or BLAST_FURNACE?
It should
No no
Somehow the check
Things it failed
Like event.getBlock().getType() is not actually a Material.FURNACE
change the return to a sysout/logger.info and see what you get
When it should be
?
Could be conflicting too no/
that doesn't makes sense
Thought inventoryMoveEvent also applies to furnaces
try this
Yes doiung rn
โฌ๏ธ
create a yoghurt and inject it into netty
What the fuck
is the YoghurtFactory in spigot-api or only in spigot?
So it actually
still with 4.1.87.Final
Thinks the block is not a furnace
bro just wanted to test a code ๐
Why would that be
whut?
do you have an api version in plugin.yml
Yeah then relocate
dafuq
if !block.getState() instanceof Furnace
Chances are that you are not using the same version as minecraft and that stuff goes bangzai if you use mismatching versions
The thing is
event.getBlock().getType() is actually returning the right thing
event.getBlock().getType() != Material.FURNACE thinks this is true
I mean ig I can just remove the check but I'm so confused on why that would fail
magic
Now i'm straight up confused
like this?
<relocations>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>codes.laivy.tests.libraries</shadedPattern>
</relocation>
</relocations>
if everything goes right, yea
it not ๐
Issue are netty natives, they could be PITA
i will try a old version then
I guess just pray that it doesn't call something that isn't a furnace
๐
So weird
so where exactly do you get that issue`
Redis Lettuce
While executing tests? If so, how do you execute them? Do other classes cause the issue too?
intellij run
And mvn test?
already, it just creates me a .jar
oh no...
what ๐
You are likely not running it with the debug configuration
Well not debug, but unit test config
You have to use an actual unit test framework with maven
Such as JUnit
Isn't too hard
yeah it's a bit confusing
for me the person who has priority means that he'll go first
but yeah okay i can understand why its called otherwise too
thanks!
And MONITOR is even higher than HIGHEST right?
Yea
so why is highest called highest if its not the highest ๐
ok this is weird
but monitor shouldnt modify the event
Monitor should only read stuff not modify
monitor is for stuff like discord relay etc etc
event modifications can overwrite eachother so to have the highest priority you must apply your changes at the end
what if I do modify?
nothing
you get bonked
then other plugin devs will call you a jerk
Your just an asshole nothing more nothing less
What's the knockback formula? I need to simulate it without a player being damaged.
i don't care about other plugin devs they can piss off with their "code of conduct" and take their good practises up their aaarrse
sorry xd
i needed that out
i'm so irritated by the dev community

Most spigot devs suck
```what is this?
anyway thx for the support
the drops plugin uses nbtapi but doesnt depend on it
add nbtapi to depend section in plugin.yml
ok, thanks
@tender shard
So remember how you told me to use CreatureSpawnEvent instgead
Cause the dumb spawners from wildstacker
I know there's Bukkit.craftItem(...) but is there a similar thing for cooking recipes, e.g. furnaces, blast furnaces, etc?
hmm yes Enter an expression or type exit() to exit: 35356666666666666666666666666666 ExpressionParser result: -8.9478486E7 (28.0 ยตs) (new algorithm) ExpressionParser result: -8.9478486E7 (19.2 ยตs) (old algorithm)
all plugins from this "Wild" author are ridiculously bad
I mean
WildStacker is the worst
They are cool but maybe code wise yes
ALSO I love the fact that i made my plugin in one file
People get mad when they see this hahaha
idk I only them from them always causing troubles with other plugins
a lot of plugins seem and are really cool, like the minimessage library that looks really cool, until you have to implment it
another thing. I have this:
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
NBTItem itemNBTI = new NBTItem(item);
double movementSpeed = getConfig().getDouble("espada.AttributeModifiers.movementSpeed");
ItemStack espada = new ItemStack(Material.DIAMOND_SWORD);
NBTItem nbtEspada = new NBTItem(espada);
nbtEspada.setInteger("HideFlags", getConfig().getInt("espada.HideFlags"));
nbtEspada.setString("display.Name", getConfig().getString("espada.display.Name"));
nbtEspada.setString("display.Lore", getConfig().getString("espada.display.Lore"));
List<String> enchants = getConfig().getStringList("enchants");
for (String enchant : enchants) {
String[] parts = enchant.split(":");
String enchantName = parts[0];
int level = Integer.parseInt(parts[1]);
item.addUnsafeEnchantment(Enchantment.getByName(enchantName), level);
}
item = nbtEspada.getItem();
```with this config:
```yml
espada:
HideFlags: 1,
display:
Name: "HolaTest"
Lore: "Este es el lore"
enchants:
- "SHARPNESS:3"
- "FIRE_ASPECT:2"
``` and the item was not created with the custom values
discord formatting on its best
So if I use CreatureSpawnEvent
It disabled that holo too
Gonna put it in 1 message:
I'm using ```java
public void preventNaturalMobSpawn(CreatureSpawnEvent event) {
if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER) return;
event.setCancelled(true);
}
But when I do that my item stacking can't display the entity above it for some dumb reason. What kind of checks could I add to make sure only natural creatures are canceled
Hello when I send a block change to a player and that same player aims a bow at the block the block disappears. How would I fix this?
Hi, I am trying to use maven dependency. I added repository and dependency, but groupId, artefactId and version is red. And I am getting error:
Could not find artifact me.zombie_striker:QualityArmory:pom:VERSION in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
There is my maven:
https://pastebin.com/gEcjHxwA
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.
did you reload maven?
yes
epic any clue on my issue ๐ฆ
try building that plugin yourself
And using mvn install
it's cursed, but the best one can do sometimes
ok, i will try something
whats going on
.
Why does your error say VERSION instead of the actual version?
uh oh lol
You need to replace VERSION with the actual version @pulsar parcel
2.0.7 is definitely in the repo https://repo.codemc.io/service/rest/repository/browse/maven-public/me/zombie_striker/QualityArmory/2.0.7/
oh, true, I didn't reload maven after changing the version, sorry guys, thanks for help
ive got no idea lol
Alex back to CreatureEntitySpawn
- What an idiot for adding a hostile mob to display a holo...
wtf
AreaEffectClouds should be used for holograms
that hologram is a mob?
It's getting deleted using CreatureSpawnEvent
armor stands or aoe clouds for holos
Thats also ok
go into spec and check
But they cause client lat when you have many of them
I once checked with my rtx 2080 super and 10k armorstands in one chunk killed FPS, but 10k effect clouds worked fine
I think
It's working
nvm
If there is an entity there
How can I get it
If I make a /see command
There it is
LMAO
We found the little bugger
if (event.getEntity() instanceof ArmorStand) return is wrong then
Cant you just ignore named entities
Don't all creatures have names?
I mean maybe isCustomNameVisible could work
But I feel like if if (event.getEntity() instanceof ArmorStand) return; didn't work it's the same bs as the spawners
That they are not actually spawners
the custom name, I meant
Yeah there you go
Perfect
Works for now lol
Until the next wildstacker bs breaks it again
How do I prevent fake blocks from disappearing when I interact with them?
do you guys also have like 20 "Test" plugins lol
just send another blockchange
not too many
ive got like 2
Yeah I did that for right click but the problem is it also makes the block go away if you aim a bow at it
bukkit test plugin, config test plugin
Dont know how to watch for someone aiming a bow at a block
I don't end up with many of them because I just re-use it when I need to do a quick test
player.getTargetBlock(null, 15);
on what event?
Just need a player
If you're shooting arrows I believe is projectileLaunchEvent
Could be wrong tho
Yeah except you dont have to actually shoot the arrow
If you start aiming it removes the block
What?
interact event
^
If you want the player to have to do the windup and then hold it without releasing interact event otherwise if you want them to release and the block looking at gets broken do launch event
Doesnt work as its a client sided block
how would I check if its the correct block is the right one though?
If I can't actually check if there is a block there
Yes that is for server sided blocks/regular blocks, the server doesnt know there is a block there
what
Im going to try vectors to see if the player is aiming at the location of the block
What?
Have you done basic debugging to see if PlayerInteractEvent is called when a fake block is broken client side?
What is server sided?
Calculating the vector works fine
Yeah
I would do two checks one; rayTrace and a vector calculation
Why 2?
So you don't have anything in the way obstructing the view of the block
If that doesn't matter you can just skip the rayTrace
well it would matter but players wont be a able to place blocks there so it shouldnt be a problem
only problem is you won't really be able to know if they are aiming the bow
client doesn't give that information. Only information in regards to aiming the bow that client sends is when the arrow is fired and that is to inform how much power or how far back the bow draw was
so you are going to have some challenges with that unless you just want them to have the bow in hand which you could detect that
Doesnt really matter
Fake blocks disappear when interacted with
So I dont need to check if its a bow
Also am I doing this wrong? Sometimes it works sometimes it doesnt and I cant really find a reason to why it doesnt work
Vector direction = p.getEyeLocation().getDirection();
for(Location loc : fakeBlocks.get(p.getUniqueId())) {
if (loc.toVector().distanceSquared(p.getEyeLocation().toVector().add(direction)) < 1) {
loc.getBlock().setType(Material.BARRIER);
}else {
p.sendMessage("NOT LOOKING");
}
}```
How can I convert this to an enum or something better for the purpose
public static final Map<Integer, Double> MAX_ALLOWED_ITEMSTACKS_UPGRADES = new HashMap<>() {{
put(1000, 10.0);
put(5000, 50.0);
put(10000, 100.0);
put(50000, 500.0);
}};
The Integer would actually be how much the upgrade would modify and the Double is the price.
So it's like a table of
amount->cost
not a key -> cost
api
isnt it the same formula everytime?
Yes
Or I mean no
It's an example
I want to be able to hardcode a custom amount of those
With any values
But since they are prices they will never change
But where to store it is the question
I need it accessible from many files
nono what object
I don't think what I'm doing right now is the best
I was thinking an enum for example
Like accessing the data in that list is odd
put it in an utils class or smth
The problem is I don't what what the correct datatype is
Not that I can make it static final
wdym correct type
sth like this?
public enum UpgradeTier {
TIER1(1_000, 10d),
TIER2(5_000, 50d),
TIER3(10_000, 100d),
TIER4(50_000, 500d);
private static final UpgradeTier[] TIERS = values();
private final int modifyAmount;
private final double price;
UpgradeTier(int modifyAmount, double price) {
this.modifyAmount = modifyAmount;
this.price = price;
}
@Nullable
public UpgradeTier getNextTier() {
int nextIndex = ordinal() + 1;
if(nextIndex >= TIERS.length) return null;
return TIERS[nextIndex];
}
}
into infinity lets goo
Thank god
I'm cleaning up my project
It's the first one I did and since then I've improved a lot and this 800 line file with terrible GUI management ain't gonna cut it
In what language lmao
german
tier is like a level
Well I can tell you the word tier doesn't come from german lol
no, tier is an animal ๐
dier is an animal
deer is an animal
sponge is an animal
So alex
If I want to have multiple enums for different types of upgrades do you recommend putting them all in 1 enum file
i wouldnt use enums in the first place but make it configurable
then use 1 enum per "type"
Ok gotcha
public class TotallyCoolEnumsBeLike {
public enum Enum1 {
}
public enum Enum2 {
}
}``` calling itwould look like this
i dont do guis much
Yeah thought about that too
hmmm
yaml anchors are bae
wtf
why does your gui files have 100 lines combined
how terrible am I at doing this
because he has a lib
not for gui stuff
angelchest's gui code is more sophiscated lol
show him yaml anchors
I want to have a gui:
I want to have half of that GUI to not actually change elements but it can update, so like refresh.
I want to have submenus for the gui that will only change the bottom portion of it
is anyone familiar with opennbt willing to help me?
So like panels in html lol
I need to be able to always access the top half ( one that never changes ) from the child gui ( bottom ones )
i doubt that anyone can help you if you don't ask any specific question
I'm talking file structure specifically
I've tried creating my own custom tag to store objects inside NBT, because this is what I need.
But when I try to create my new tag and add it, it doesn't work.
First of, it gives no value to the tag (can't access the object I stored)
second, I can't read the nbt file after I've written it using my custom tag (Gives me an error: "Could not find tag with ID '255'")
Would like to resolve both of theese issues
pdc?
You can't add pdc to blocks
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
you can to chunks
blocks also cannot store custom NBT tags
use this ^
I can make a nbt file, store info
Trying to get a custom slime and im gettin 'y()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'y()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type And cant find much info. Im extending EntitySlime. Anyone know what to about it?
I want to have a gui:
I want to have half of that GUI to not actually change elements but it can update, so like refresh.
I want to have submenus for the gui that will only change the bottom portion of it
I need to be able to always access the top half ( one that never changes ) from the child gui ( bottom ones )
yeah I think that's my only option
it gives you one PDC per block per plugin, and you don't need any NMS like NBT requires
what's NMS?
NMS is the version dependant, internal minecraft code
net minecraft server
uh okay let's keep it there ๐
basically, if you see "NMS", you should try to avoid it if possible
profound take
Ok so I pretty sure I asked this a couple days back or something but is there a way to remove items in inventory if it has specific PersistentDataContainer the key is flash_coins
loop over the items in the inventory and check if they contain your pdc key
omg
What is the name of when you have a picture that has like everything going on inside a class
Like it shows the methods, fields, access, etc
it's like a map
diagram
THANK YOU
or do you mean the stuff on alex' screen?
you've heard of yml, now we have uml
if you mean this, it's Ctrl+Alt+Shift+U in IJ
only on ultimate
Sort of but
I want to draw my own
So I can send it here
See if what i'm about to do is good or not
i need to get a support discord made
ive got so much to do 
Is placeablekeys a way to check if the item has keys like PDC
what are placeablekeys?
sender.inventory.contents.itemMeta.hasPlaceableKeys()
im not finding any ItemMeta#hasPlaceableKeys
with an ItemStack in config can i use Color Codes
for(contents in sender.inventory.contents) {
if(!contents!!.hasItemMeta() || !contents.itemMeta.hasPlaceableKeys()) return else {
if(!contents.itemMeta.persistentDataContainer.equals("flash_coins")) return else {
contents.removeAmount(Int.MAX_VALUE)
}
}
}
bite me
!contents!!.hasItemMeta() yeah gl with npes
inventories can have nullable entries.
how is itemmeta even on the contents
Really its a quick write up
It's not, he made the variable in for loop contents
So it's a single itemstack.
wait bruh
He's saying it's not null though, even though it might be.
!contents.itemMeta.persistentDataContainer.equals("flash_coins") Will always be false.
Also you can just use == in kotlin.
It will always be false. (true with the ! in front)
Is this some sort of extension function? contents.removeAmount(Int.MAX_VALUE)
fun ItemStack.removeAmount(amountToRemove: Int): Boolean {
this.amount -= amountToRemove
return this.amount > 0
}
Noted
Should I ask in Paper discord?
Yeah no clue what that function is. It's not spigot atleast.
@fervent gale ItemMeta will always have pdcs.
Well it won't work on some versions. I know it didn't work a while back.
setting an item's amount to 0 on 1.16.5 removes it
nice.
How i can cancel tnt explosions inside a specific region im already cancelling the event but i cannot figure why explosions breaks blocks
declaration: package: org.bukkit.event.block, class: BlockExplodeEvent
yeah i malready listening but its doesnt cancel it
and pls put that region code on gh
The problem is that tnt event doesnt have a getter for breaked blockes that is causing
blockList()
yeah I also once searched it for 5 minutes before I found it
very weird name
sounds like paper api
sounds like minestom naming conventions
"fluent" bullshit
sounds like orbyfieds getters
rate code 1-10
if (!player.hasPermission("server.summon")) {
player.sendMessage("You do not have permission to use this command.");
return true;
}
if (args.length < 2) {
player.sendMessage("Usage: /summon <entityType> <amount>");
return true;
}
int amount;
try {
amount = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
player.sendMessage("Invalid amount. Please enter a valid number.");
return true;
}
EntityType entityType = EntityType.valueOf(args[0].toUpperCase());
Location location = player.getLocation();
for (int i = 0; i < amount; i++) {
Objects.requireNonNull(location.getWorld()).spawnEntity(location, entityType);
}
player.sendMessage(colorize("&aSpawned &e" + amount + " &a" + entityType + (amount > 1 ? "s" : "") + "."));
1
w h a t m a k e s i t b a d
not using a framework
why would I need one
checking the permission is not needed if you properly registered the command.
using Objects.requireNonNull is also not needed since you just got the location from the player.
And you could achieve the same thing using ACF with only 4 lines
ignoring errors is so easy
other than that, it's fine to me
no it isnt
So how would i block the event without cancelling it on every loop? Because that wont cancel the event
Minecraft mobs, items, particles, etc are all entties
it would throw a NoSuchElementException when someone enters /command asdasd
sure buddy
Why dont u use use ACF? You are over engeeniering something already done
if it doesnt throw an error, you are not using the code you sent
buddy I can assure you the code does at it does
run it yourself
ok gimme a second
wait i found smth
here you can see that it throws an error
[00:13:55 INFO]: mfnalex issued server command: /test asd 5
[00:13:55 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin Test-Spigot v1.0-SNAPSHOT
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.CraftServer.dispatchCommand(CraftServer.java:929) ~[paper-1.19.3.jar:git-Paper-373]
at org.bukkit.craftbukkit.v1_19_R2.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.3.jar:git-Paper-373]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.3.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:313) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:297) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2288) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:114) ~[?:?]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1445) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-373]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-373]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalArgumentException: No enum constant org.bukkit.entity.EntityType.ASD
at java.lang.Enum.valueOf(Enum.java:273) ~[?:?]
at org.bukkit.entity.EntityType.valueOf(EntityType.java:23) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at com.jeff_media.testspigot.TestSpigot.onCommand(TestSpigot.java:38) ~[test-spigot-1.0-SNAPSHOT.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
... 23 more
yes because I was stupid
and I forgot that second args are a thing
hold on a second
i'd do it like this
EntityType entityType = Enums.getIfPresent(EntityType.class, args[0].toUpperCase()).orNull();
if(entityType == null) {
player.sendMessage("Invalid entity type. Please enter a valid entity type.");
return true;
}
oooor use acf
and you can just do it like this:
@Default
public void onCommand(Player player, EntityType entityType, int amount) {
Location location = player.getLocation();
for (int i = 0; i < amount; i++) {
Objects.requireNonNull(location.getWorld()).spawnEntity(location, entityType);
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&',"&aSpawned &e" + amount + " &a" + entityType + (amount > 1 ? "s" : "") + "."));
}
sure
hold on lemme find my old code
ah Y e s
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (sender.hasPermission("eagle.multisummon")) {
if (args.length >= 2) {
try {
EntityType entity = EntityType.valueOf(args[0]);
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
p.getWorld().spawnEntity(p.getLocation(), entity);
}
p.sendMessage(colorize("&aYou've spawned &e" + args[1] + " " + args[0] + "s"));
} catch (IllegalArgumentException e) {
p.sendMessage(colorize("&4This is not an entity."));
}
} else {
p.sendMessage(colorize("&e/multisummon [mob] [amount]."));
}
} else {
p.sendMessage(colorize("&4You don't have permission to do this."));
}
} else {
sender.sendMessage(colorize("&4You cannot do this. "));
}
return true;
}```
I want to make a gui:
I wanna know what a good file structure for this is
I want to have half of that GUI to not actually change elements but it can update, so like refresh.
I want to have submenus for the gui that will only change the bottom portion of it
I need to be able to always access the top half ( one that never changes ) from the child gui ( bottom ones )
How do you split up tests into multiple classes? I have one testing class using MockBukkit and its already 180 lines long
that is awful lol
y
nice did this thanks
its so boring and you spend 99% of your time trying to shift elements with css
i mean
if you learn css
it's easy
JavaScript is a mid ass language and there are 10 billion frameworks you have to learn
to have an effective setup
exactly I'm also no designer
I can't do CSS not because its hard, but because My sense of design doesn't exist
I can do the site I'm also just not a good designer
I mean I code code a website I've just never posted my portfolio websites because its designed to poorly
Hey can anyone provide a project with well defined abstract classes, Interfaces and enums connected.
Trying to wrap my head around what the best way of doing what I want is and would be great to see some examples
?stash
I said well defined
There's too much going on in there
not really
Bukkit is pretty well defined
"Internal Excecption: java.net.SocetException: Connection reset"
Trying to understand how basics work and that has way too much stuff
bro what
?stacktrace
We cannot help without the full stacktrace; Please paste it here: https://paste.md-5.net
what does that dol
read it
wdym with language type?
like language type 9 or 16
It just changes color.
language level
File -> Project Structure
you also will have to change it in your pom.xml
thx
the SDK has to be >= the language level
welp new java time
why I don't post my website ๐
better than mine ๐
Hold up lemme bring in the light mode
๐ @river oracle
Why its not recommend to cancel the events while looping? I having some issues related to that
wdym?
I got this
share your code
chatgpt it gonna answer this
It is not recommended to cancel an event while looping through its handlers because it can lead to unexpected behavior.
When an event is cancelled, it will stop all remaining event handlers from executing. However, if an event handler that is currently being executed is also responsible for cancelling the event, it will stop all remaining event handlers, including itself. This can lead to an infinite loop, where the event is cancelled, but the event handler that is cancelling it is not finished executing yet, so the event is immediately uncancelled, and the loop starts again.
Additionally, cancelling an event while looping through its handlers can also cause the event handlers that have already been executed to be skipped, which may lead to unexpected behavior.
It is generally better to cancel the event before it is passed to the event handlers to avoid these issues.
Also, if you need to cancel an event inside a loop, you should use an Iterator to remove the handler from the list of handlers, instead of cancelling the event.```
and again, chatgpt produced utter bullshit
yes
completely untrue lol
yes
anyway with the acd thing how would I send a message when they don't have the correct entity or if it isn't a number
ACF automatically does that
if you want to provide your own message, then do not make the method take an EntityType, but make it take a string
right:
now I am a very stupid guy alright
what's wrong
}
its not CommandExecutor
and do you even have acf imported
btw acf can also send the text in the translated language, e.g. german for people who set minecraft to german
you need to add ACF as dependency to your pom
I ain't want it to send that long ass message ๐
bruh
never have i ever
use a library
as said, you can just change that
oh you sent so many lines that my issue got losted haha
so you're getting the regions at a block location, then you're checking again if the region cuboid contains that block
right
getRegion() internally performs a loop of the List<Region> via Cuboid object
Im a bit mixed sorry for looking like a noob
because there is a null check before
what's the platform
acf-paper
if the region object is not null, then you already found the region on that block location
you could just use setCancelled(true)
Rigth so i dont need all that thing
Let me test it
and add a break; so the loop stops
oh ok that why it wasnt working before
Here's an example with working tab complete that only accepts proper entity types, but sends your own message:
Command class:
@CommandAlias("multisummon")
public class SummonCommand extends BaseCommand {
@Default
@CommandCompletion("@entitytypes @range:0-999")
public boolean onCommand(Player player, String typeName, int amount) {
EntityType type = Enums.getIfPresent(EntityType.class, typeName.toUpperCase()).orNull();
if(type == null) {
player.sendMessage(ChatColor.RED + "Invalid entity type");
return true;
}
Location location = player.getLocation();
for (int i = 0; i < amount; i++) {
Objects.requireNonNull(location.getWorld()).spawnEntity(location, type);
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&',"&aSpawned &e" + amount + " &a" + type.name() + (amount > 1 ? "s" : "") + "."));
return true;
}
}
Main class:
@Override
public void onEnable() {
PaperCommandManager acf = new PaperCommandManager(this);
acf.registerCommand(new SummonCommand());
acf.getCommandCompletions().registerStaticCompletion("entitytypes", Arrays.stream(EntityType.values()).map(Enum::name).toArray(String[]::new));
}
you kinda forgor something there
what?
alr now why would I need the tab completor in the onEnable
so that you see this
can that not be replicated with a normal tab completor
sure but the ACF way is much easier
ik I can do smth about it being upercase
I gotta add #toLowerCase somewhere in that stream
damn bruh acf if replacing my normal register command stuff
now I can just use .acf
acf.registercommand
alr I can't figure out where to put the lowercase thing
can you tell me where tf I'm supposed to place it
acf.getCommandCompletions().registerStaticCompletion("entitytypes", Arrays
.stream(EntityType.values())
.map(type -> type.name().toLowerCase())
.toArray(String[]::new)
);
if you dont know how lambdas and method references work, read this: https://blog.jeff-media.com/understanding-lambdas-and-method-references/
where did type.name come in place
Enum::name
Enum::name is the same as myEnum -> myEnum.name()
Still not cencelling it, its really weird because the block is inside a region and the block/break and palce works perfectly
yes because it includes all the translations for the messages
atleast its not megabytes
true
you can make it smaller by setting <minimizeJar> to true in the maven-shade-plugin
then only includes the classes you need
i mean who really cares how big it is
And what will do that?
it only includes the classes you need
Hmnn and what if you call another class?
it cannot trucate classes
the nit's obviously a class that you need
it will simply add the class
since you need it
don't trust me tho idk what i'm talking about
okay, but wha tif the class implements/extends a super class will it truncate it?
@tender shard knows this
also my tab completor isn't working ;- ;
then you didnt add the CommandCompletion annotation
you use it, so yeah
bruh I got to add that as well
how else would ACF know that you want it to complete entitytypes there?
it cannot magically know that
it would magically know it if you used the enum instead of a string as parameter
yes
^
?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.
Why does this only happen to literally random mobs after we've already done like 60 more.
It happens to some, they are all the same
It can't be an event getting canceled cause some ar still spawning
ignore that
alr
also me being stupid Idk where the maven shade plugin this is
ask chatgpt
it doesn't know shit
or well it doesn't know the correct shit
to complicated
copy pasting this tiny part is too complicated?
yes
i doubt you should be making plugins then
i doubt you should exist
same
exactly we're on the same page
yeah kinda true, everything is explained there in as much detail as possible
shut stop agreeing
Are there any possible downsides of minimazing jar?
not if you do it right
java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.ConfigurationSection.getKeys(boolean)" because "section" is null
at info.sokobot.locksmith.items.Keys.init(Keys.java:44) ~[locksmith-0.0.1-SNAPSHOT.jar:?]
public static void init() {
File dataFolder = new File(Main.getInstance().getDataFolder().getPath() + "/keys");
File[] files = dataFolder.listFiles();
for (File file : files) {
if (!file.getPath().endsWith(".yml")) continue;
YamlConfiguration config = parseYaml(file.toPath().getFileName());
ConfigurationSection section = config.getConfigurationSection("keys");
Bukkit.getLogger().info(file.getPath());
for (String item : section.getKeys(false)) {
keys.put(item, file.toPath().getFileName());
registierRecipe(item);
}
}
}
imagine you have classes like
my.package.v1_19_R2.MyNMSHandler
and you access them like this:
Class.forName("my.package.v" + nmsVersion + ".MyNMSHandler");
then the shade plugin won't know you use that class and get rid of it
that's why you have to add filters in such cases
e.g. like this
But if you don't use any reflection or hacky things like that?
then you can freely use <minimizeJar>
Hi im back i still cannot understand why the blocks are still being open on tnt exploision, while i already checked many times my code
Cool, thanks ๐
np
LMAO im exausted i still cannot cancell the fkg tnt ๐
maybe do some debugging, check if the region object is being found
System.out.println(region)
you never remove anything from the blocklist
remove?
and you still use BlockExplodeEvent although you said you were doing TNT stuff
and I told you that TNT is an entity when primed
primed? context please
tntn is a block until it gets primed / ignited. then it becomes an entity
like a falling block
EntityExplodeEvent
Im checking both of the event and none of them are being cancelled
Also the region system it isnt the problem
show your getRegion(Location) method
your region stuff must be the problem
if you'd actually cancel the event, nothing would explode
if you only want blocks inside your region to stay intact, do not cancel the event but remove the blocks that are inside your region from the blocklist
private static YamlConfiguration parseYaml(Path path) {
return YamlConfiguration.loadConfiguration(new File(Main.getInstance().getDataFolder(),path.getFileName().toString()));
}
I dont think its the problem, but okay
check if it actually returns sth
Yes, returns the object region
Because the blocks are actually in the region
getDataFolder would return the folder of your plugin in plugins
it doesnt return anything in your event
as you can see, cancelling the entity explode event will NOT damage any blocks
He?
Im mixxed with what you mean
I just need to make blocks not breaken when any explosion is done
so your loop only reaches "setCancelled" if the region object is not null, since the event isn't being cancelled, it means the regions is not being found at the location
First of all somethign weird it happens because my debug messages are not displayed
๐
there must be something wrong with Region.getCuboid().contains(Location)
@EventHandler
public void onExplode(EntityExplodeEvent event) {
event.blockList().removeIf(block -> {
System.out.println("Checking whether to protect " + block + " from explosion...");
boolean isInMyRegion = isInOneOfMyRegions(block.getLocation());
if(isInMyRegion) {
System.out.println(" -> Yes, it's in my region");
return true;
} else {
System.out.println(" -> No, it's not in my region");
return false;
}
});
}
yeah that's what I'm saying the whole time lol
fixed that now ConfigurationSection config = parseYaml(keys.get(name)).getConfigurationSection("keys."+name); is null
No, because i use the same method for block break/place events and works perfectly. If the method wouldnt be working then my others events werent working
it obviously does not work perfectly
^
oik
one more thing, you should use Priority Lowest instead of highest, since you will be changing the outcome of the event
I must HIGHEST because the plugin should work over another protection plugin
highest is totally fine?
all of the stuff in that class depend on this
private static YamlConfiguration parseYaml(Path path) {
return YamlConfiguration.loadConfiguration(new File(Main.getInstance().getDataFolder(),"keys/"+path.getFileName().toString()));
}
i have this being sent
ConfigurationSection config = parseYaml(keys.get(name)).getConfigurationSection("keys."+name);
the error happens in registerRecipe() because config is null
what's wrong with using highest?
if another plugin uses the event and wants to get the list of blocks exploded, the blocks will still be there. By using lowest you remove the blocks from the list before the event of this other plugin is called.
if a plugin wants to know the final outcome, they should use MONITOR
yes, but sometimes it's better to leave a headroom, specially if you're doing a region plugin
I think that especially when they want to protect their regions, they should highest
