#help-development
1 messages ยท Page 854 of 1
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
k
I was thinking instead of setting night and day every x ticks
delaying by x ticks every y ticks the cycle
so I get a smooth cycle
hmmm
declaration: package: org.bukkit.entity, interface: Player
accordingly if you set the boolean to false
presumably it would be up to you to make the time progress
so it seems doable with what you want
however, downside of this method, is that it desynchs with server time. In other words you could have a situation where the player is still seeing day
but the server time is night
and thus they see mobs etc spawning that normally spawn at night, but they see day lol
ah ok, then that method should work for you then ๐
so mob spawns are disabled etc
what was the way to make an entity with a lambda or whatever?
would anyone happen to know if there's an actual way to have a tablist like this one? I am looking into implementing a tablist with 2 columns displaying players of (2) different teams in each of them
That prob modded server
In not quite sure but i think ppl do this with paxkets, the send a few addplayer packets witz probably an empty name until the 1 column is filled
Or i guess ressourcepacks could help too
So... I can't understand how to download CoreProtect API... At the docs it just said "if using Maven, you can add it via the repository https://maven.playpro.com" but i don't know how...
maybe it's a bit stupid question but.. yeah
yeah
All my plugin is just register events events/EntityExplosion
and i want to add coreprotect
No no, i mean the plugin you want to add
ohh
The link
here's the docs
https://docs.coreprotect.net/api/version/v9/
Um i might be blind but i havent found the import studf yet
<repository>
<id>playpro-repo</id>
<url>https://maven.playpro.com</url>
</repository>
<dependency>
<groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId>
<version>22.2</version>
<scope>provided</scope>
</dependency>
Okay so @kindred sentinel open you pom.xml
Oh
THanks
You know how to add that
I know, I just didn't find this
yeah
to repository to repositories, dependency to dependencies
Yes
So but where did you find it?
Github
it's also mentioned on the docs you sent yourself
oh... Maybe i'm blind
Is it possible to use Block#breakNaturally and get a reference to the dropped item(s) from it?
only called when a player breaks a block
could listen for ItemSpawnEvent, that's it
whats the best way to remap a 1.8 gradle plugin from spigot mappings
Still wont tell me which items were dropped from the block break
why not? you'd know that as soon as the items get spawned
just keep track of the block you broke
im"
org.bukkit.command.CommandException: Cannot execute command 'veldoryaclaim' in p
lugin VeldoryaClaim v1.1.1 - plugin is disabled.
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[pat
ched_1.16.5.jar:git-Paper-794]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:15
9) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServ
er.java:826) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(Cra
ftServer.java:788) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.DedicatedServer.handleCommandQueue(Dedi
catedServer.java:470) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:
437) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:
1347) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:
1135) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftSer
ver.java:291) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.Thread.run(Thread.java:831) [?:?]```
I am using a plugin and I get this error.
But items don't have a reference from where they came or have they?
no, you gotta keep track of that yourself
for example like this
private boolean iJustBrokeABlock = false;
public void breakNaturally(Block block) {
iJustBrokeABlock = true;
block.breakNaturally();
iJustBrokeABlock = false;
}
@EventHandler
public void onBlockDropItem(ItemSpawnEvent event) {
if(!iJustBrokeABlock) return;
// Do stuff
}
Isn't the whole method being executed on one tick? Then the bool would be set back to false before the items even spawned
Oh wait the method triggers the event right
no, breakNaturally() will call the event, the plugin manager calls all registered event handlers, and then it's set back to false again right after that
Yeah true, then this should work. Thankyou ๐
np
how to make item frames to not blow?
like... EntityExplodeEvent.blockList() hasn't item frames in
ItemFrames don't work with EntityDamageEvent and in the HangingBreakByEntityEvent.getRemover().getType() returning PLAYER even if it was broken by tnt, so I need to know if the item frame was broken by explosion and if it was broken by player
Oh
i found
Cause EXPLOSION
So... I found a error but can't understand why
your java version is too high
So... How to change it?..
depends on the system
idk how windows work so I can't help you there
"java path" -args
on linux you just go into your .bashrc and change the JAVA_HOME path
or you can just invoke the bin file directly
^ thats whats happening here
Can't you EXPORT it to change it only for this env/session or whatever?
sure that too, but why bother at that point just invoke the bin file directly
So... I still can't understand to what version I should change it... Sorry..
java.version meansnothing
Hm, yeah
unless you use it anywhere that variable does nothin
well it means something if you use it
ohh
set the maven compiler plugin source and target
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>```
in properties?
yup
like this?
im getting a net.minecraft.server.CancelledPacketHandleException which apparently occurs when the player received a specific packet asynchronously, and im getting this error semi-consistently with custom GUI related things. issue is I don't know where this is coming from, the error doesn't list any of my code and as far as I know im not doing async stuff to the menus in question, has anyone experienced something like that before?
ye
?paste
https://paste.md-5.net/ahicuwareb.txt in case the error is important
Still have this problem
how are you compiling
run a clean package
just run the clean task then package after
Still the same..
How if they just spawned?
Sorry, this is the second time I've asked, but for some reason I can't edit my own resources or upload new files
So.. I tried the version from target and it still returns this error
have you enabled 2fa?
no...
thx ๐
this works fine for me
Yeah... I tried .getRemover but needed getCause
I did everything
pom is correct. are you even using the correct jar?
And now I still have this problem
From target
did you enable the "export to test server" profile?
I disabled it
ok good because it has an invalid path
Why invalid?
you have set thje java version to 21 in maven-compiler-plugin
anyway yo uhave set 3 different java verisons in your pom, clean it up
Yeah... It's not invalid
first you set java.version to 8
._.
then you set it through properties to 17
and then you set it again to 21 in the compiler plugin
and on top of that, you even additionally enabled preview features
so which java version do you really wanna use? 17, 8, or 21?
17...
then set java.version in properties to 17, remove the 2 other properties that are currently set to 17, remove the compilerArgs in maven-compiler-plugin, and set both target and source in the compiler plugin to ${java.version}
So... Firstly I created project threw plugin... Then I added API and code because of that I needed to change the version to 21 and changed it using Intelij Idea notification, then I wanted to change it to the 17
Like this?
remove the compilerArgs
and as mentioned I'd use a property to set it to 17 so yo udon't have to change it twice, but sure you can also do it like this ^
So what should I leave there?
nothing
Just leave 1.8?
no
Maybe I can just delete this?
yes, that's what I told you twice already lol
Sorry
but as said, I would still use a property to set it so you don't have to declare it twice. like this -> https://paste.md-5.net/ikikepaqeg.xml
My brain is not braining
after that run mvn clean package
So I changed the version of java to the 21 and there is no error now, but I still need to make it usable for java 18, (It still returning error in java 18) How can I check if the version was really changed?
why the hell did you change it to 21 now
?
ofc it won't run on java 18 (which is end of life btw) if you're compiling it for 21
So.. How to run it using java 18..?
compile it for j18 or lower?
by setting the java version in your compiler-plugin to 18 or lower
i really have no idea why you're mixing java versions all the time
first you wanted to compile for 17, but set it to 21, 8 and 17, then you again said you wanted to use java 17, and sent a screenshot of the correct settings for 17, I even sent you the whole pom, and then you changed it again to 21 and wondering why it won't work on java 18 (why 18 now?)
so now you've been mentioning java 8, 17, 18, and 21
just use the pom I sent you
and set it to 17
java 18 makes no sense, it's end of life
whatever you set as java version in the maven-compiler-plugin is the minimum required version needed to run it
So, I had java 21 on my computer, and java 18 on the host, I started creating a plugin using Intelij Idea (minecraft plugin) (Initially for java version - 8), then I started working with the library and code from the documentation, but Intelij Idea gave out error that a higher version of java is needed, using this error notification I changed the version to 21. Then I tested and saw the error that I posted above, after which I tested on a local server (With JDK 21) and it was without an error, I asked about the error in this discord server, and I was told to install version 17, and since I constantly had problems changing the java version, I asked how to do this and was told to write "<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>" I wrote and then sent my pom.xml
no need to install java 17
just use exactly this pom and don't change anything lol
Yeah I know... I always had problems with changing java version.. Sorry
I didn't understand pom.xml so it was difficult to download dependencies and change java version, then I found out how to add dependencies, and know I found out how to change java version. Thank you so much
Hello, can this code cause any performance problems? I'm trying to check if pressure plate have been left by player to remove him from list. And I think that's the only way to do it
@EventHandler
public void onPlayerMove(PlayerMoveEvent event){
if(!this.MAIN.playerList.contains(event.getPlayer())) return;
if(!(Objects.equals(MAIN.getConfig().getLocation("firstPlate"), event.getPlayer().getLocation().getBlock().getLocation()) || Objects.equals(MAIN.getConfig().getLocation("secondPlate"), event.getPlayer().getLocation().getBlock().getLocation()))){
this.MAIN.playerList.remove(event.getPlayer());
}
}```
bruh
it's not
Do that
it's varaible in my lsitener class
ok well
dont name it that then
what
is it a static constant
private Duels MAIN;
public PlayerListener(Duels duels){
this.MAIN = duels;
}```
that's how it works
Alr so
why?
ye but why
conventions
Main is very vague
but that's my main problem
also you should use variables for this
Block blockAtPlayer =...
yeah i dont understand what hes trying to do
I'm always not sure if i should declare variable in void or just use it
if you do it more than once then make it a variable
does it really change anything or just convetion?
Is there something like stack in java except you take the last out instead of the first one?
its easier to read and modify
I have 2 presurre plates and whenever someone enters on it (PlayerInteractEvent), he's added to list, but i want to check if somoene goes off with this code and remove him from list
and as i said im just curious if it can cause any performance problems at all
I wouldnt recommend using a playermoveevent for this as it can get quite expensive. I sadly dont know a different solution tho
How large is your playerList?
ye that's the problem if i knew any other solution i would just use it
it will be max 2 players
after there is 2 players, list empties
and just fires void and empties list
There has to be an event for when a player stops triggering the pressure plate
I hope so
i think there's no event for that
at least no one pointed it in about 50 forums posts
You could create a bukkitrunnable for all the players in the list and check every 20 ticks
It depends on how important it is to know when a player leaves the plate
If you need to know instantly thid might not be the way
Just check the material of the block below the player each tick or on each move
Chunk is loaded anyway
u sure this wouldnt get expensive?
If you only check the material, thats no issue at all
Just think about what vanilla checks for each entity on every single tick
Oh and i would recommend creating a static plate location that u save in memory (when the plugin starts) instead of checking your config all the time, thats at least what i do, as far as i know reading a file is slower than havinh that value in memory
Config is loaded into memory regardlessly
how i can pakage the plugin with an library?
i have create directory "lib" and click add as library
are you using maven or gradle?
Me, debugging a web page: huh, why is my page showing up blank when I load contents from another page?
Oh yeah, I forgot to write anything on the page getting loaded
I am a good web dev
Iโm trying to get the grass color override of level.biome, but biome.getSpecialEffects().getGrassColorOverride().isPresent() returns false in the biome Iโve tried, which is minecraft:forest
I will make you website for only $50,000
marven
Does anyone know how to get the color?
https://blog.jeff-media.com/common-maven-questions/ second headline
People just getting started with maven always ask me the same 3 questions, so hereโs a a short FAQ! How to change the output directory? Read this. How to shade dependencies and what it means Sometimes you are using certain libraries (for example, my CustomBlockData class, or similar stuff) that is not already present at...
ok
someone knows why? I can send pom screenshot
It is?
@tender shard is arealy shade:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>pk.ajneb97.libs.hikaricp</shadedPattern>
<includes>
<include>com.zaxxer.hikari.**</include>
</includes>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
need to run buildtools
I also tried biome.getGrassColor(0,0) but that returns black
Then just run โmvn packageโ
on the workflow?
Then use the jar from the target folder
no, just once so NMS is in your local repo
I have alredy installed BuildTools
Yes
Hes using GitHub workflows
oh
pain wirkflows
dont go, get errororg.lifesteal.it does not exist
https://github.com/Taskeren/SpigotBuildAction maybe this helps, idk
Use GitHub Action to build SpigotMC. Contribute to Taskeren/SpigotBuildAction development by creating an account on GitHub.
this is in a PlayerJoinEvent and I dont get set the gamemode. I tried two functions. They dont work. I get the message.
How to change players gamemode
player#setGamemode
I was looking in the same site xd
Why hashtag
?
Javadoc notation
Are u new to Java? If yes
# denote a method or a function in the class so
Car#drive is to say drive is a function/method in the class Car
This is part of the javadoc notation
Of course it is lol. Would be stupid for it to be IO for every message you get from config. (also reason you must reload config when changing file)
im using it right
player.setGameMode(GameMode.SPECTATOR);
I havent claim that you didnt
Why else it wouldnt work
should be fixed should
Nice, didnt know this
If I want to make compatible the pl from 1.13 to latest what version I should use?
i guess 1.13?
this works
I think most of them otherwise you couldnt cancel them
then you got another plugin that sets the gamemode on join
Eg, Multiverse
yay
Is it good idea to save data in 70000+ blocks using CustomBlockData?
in one chunk? no
Where does data of CustomBlockData is saving?
in the chunk's PDC
I want to mark blocks saving "WasPlaced: true" on block place event using CustomBlockData
so just a boolean - then it shouldn't be an issue
I just want blocks that were placed by players not to blow by tnt/creepers
yeah that shouldn't be an issue
Oh ok
you might beable to even do cheat optimizations and if a bunch of player placed blocks are next to eachother condense them into regions
How can I execute a java command with a especific JDK version?
I think it will just overload server
Instead of just java provide full path to java binary
this C:\Program Files (x86)\Java\jre-1.8
โฆ\bin\java.exe
I'm at the bin directory, but can get access to downloads folder
What
Pretty sure Users is under C drive
add a . to the beginning of that path
Error
then just put a C: instead of a .
i'm getting this error #help-development message
ah yeah, you have to run teh whole command where buildtools is
mine is %cmd% -jar BuildTools.jar
the %cmd% is my path to java
bin
May I recommend #1117702470139904020 message
buildtools is expecting you to be in teh same directory
Gui nice!
thanks coll and ElgarL
um I was going to say https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html#getBoundingBox()
Please i need some explaantion for this debugs im struggling for hours, i cant understand why the heck is giving the data debug data like if am i executing the /faction points commad. When im executing a child of points, called info
Adjust capture of the debug
does anyone know of an algorithm/formula for the largest possible step size on a raycast to cover all blocks
1 not 1 meter
if your direction is across a corner a step size of 2 would miss the block at the corner
yes but your raytrace is not
if you are ALWAYS facing a direction like 90, 180 then yes you can step size of 1 meter
yeah ik im trying to derive it for any direction vector tho
0.1 then
that would be a waste on an axis aligned raycast tho
to calculate the minumum step size based on vector would be a nightmare in math
yes it would
it really doesnt matter probably but i like optimizing
ill just do the more a component differs from 1 or -1 the smaller the step size
wait cant i js use the direction vector then
why not simply use a BlockIterator? ?
Isnโt that what the normal raytrace method does
Itโll return either the first mob or first block it hits
watch some tutorials
Spigot Plugin Development - 1 - Your First Plugin
im on 1.8 there is no raycast
Hello
F
then just check stash and implement your own
wheres the imports and package
thats why im asking for the algorithm i know how a raycast might work but i thought maybe someone better at math has an indea
IDE does that?
in the next tutorial i will add
my IDE is a paper
The algorithm is in NMS somewhere
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
what exactly to do you envision here?
I don't fully understand why one would do preconditions in a static factory method. But if the constructor is hidden and the only way to create an instance is via the factory - you might go with the factory. For as long as the preconditions are the same for everyone
im sure this is not going to break!
1.8 hasnt changed for the last 8 years, and it surely wont start changing now.
If you stay on your ancient version then this wont be a problem.
ik
There are no public mappings from mojang before 1.17
I thought 1.14 had mappings?
wait ig not bc if im using a buildtools jar in gradle and to run the server they should both have the same mappings
ye
You sure? I thought they only made their mappings public in 1.16.5
They retroactively published a few ones
Spigot took a bit till they supported them - like many other projects out there
Hm ok i see them back to 1.14.4 actually
Turns out people didn't quite trust the license of the mappings back then
Yeah the license change was in 1.17
looks good enough, as long as end and origin live in the same coordinate space
yeah
ok so heres the probably broken current version of nms raycast for 1.8.8 only!
https://pastes.dev/7DYdDyEmRQ
also is paste.md_5 down
it gave me an error
Depends on what you are trying to do
Hm, i dont think this is a black and white problem.
Both are viable. Reading BlockData is quite fast for loaded chunks.
But my first intuition for working with entire chunks would be through a snapshot.
@blissful crow
hello there i was wondering how can i access an item/entity NBT using spigot?(i am new to spigot and bukkit so i am not 100% full)
Depends on the purpose. 95% of the vanilla nbt data is covered by spigot API.
so what function/propeties should i use to access it?
there is nothing like it
also i will be using kotlin
Depends on the purpose. 95% of the vanilla nbt data is covered by spigot API.
only item stack?
ok i want to use resource pack but the resource pack will give skin bassed on NBT tag so i have to change it
i want entity too not just item stacks
so can you give me an example code?(kotlin or java)
You can set the predicate using ItemMeta#setCustomModelData(Integer data)
Just follow the guide on how to modify the ItemMeta for ItemStacks and use the mentioned method.
so ItemMeta is the NBT right?
Its a layer to modify properties of items. Its not directly linked to the nbt data.
so is there any way to directly access it? cuz i want to add custom tags
You very very rarely access the nbt data of an ItemStack directly in Spigot.
What is the purpose of your custom tag?
i want to use resource pack to put multiple models on items based on the NBT tag(i know it is a bit too much for me but don't worry)
then what about entity and blocks?
is there anyway to access there NBT directly?
Minecraft introduced an integer called custom model data which can be used in predicates for resourcepacks.
This integer can be set using the method ItemMeta#setCustomModelData(Integer data).
For more concrete examples on ItemMeta you can take a look at the guide i've sent ๐
so can i access NBT data directly?
Entities are PersistentDataHolders themselves. But this is useless for his case.
its not just model really really need to access NBT thats why
What for?
you know what i am a bit confused i think i am missing something about resource packs sorry to bother let me research a bit more will look to this a bit more
this SetModel thing seems like the answer but i am not sure
This is pretty much how every modern resourcepack adds new item models to the game.
The json for your models should contain a predicate like this:
"overrides": [
{"predicate": {"custom_model_data":1234567}, "model": "item/cool_sword"}
]
You can overwrite the model of an iron ingot, with the model of the vanilla gold ingot using this:
{
"parent": "item/generated",
"textures": {
"layer0": "item/iron_ingot"
},
"overrides": [
{"predicate": {"custom_model_data":5}, "model": "item/gold_ingot"}
]
}
And creating an Iron Ingot which has the custom_model_data set to 5.
This can be dont through spigot by the method explained above
i see
what about blocks?
is it the same>
Blocks and Entities cant have multiple models as of 1.20
You could only completely replace them with a resourcepack.
There are some tricks to replace blocks and entities, but they are pretty dirty.
i see
what do you mean by dirty?
I mean that those tricks result in unclean experiences for the user, require a lot of work and drain CPU resources of your server.
Blocks are really bad. Entities can be ok, but you need a lot of very complicated code to kind of hack them together.
And they are not really entities in the end.
Oh cool 7smile you got helper good job!
I barely come here, aha!
can someone tell me how can i make the tnt not damage and not push the player on explosion?
mostly the push part
Is it safe to use Block as a hashmap key
?jd-s
oh yeah abt that im on 1.8.8 lol
So go search up a 188 javadoc
well
i saw this
This is a live object, and only one Block may exist for any given location in a world
does that mean its ok?
If it implements hashcode, sure
From my memory it does implement equals though so I think that is safe though (given that equals often implies hashcode)
Ok
thanks
im just keeping track of what blocks are player placed
idk if smthing like Location would be better or
Probably
sadge we dont have identity and value based class semantics yet
can someone give me a hand? This is just a simple command, when run, it should change "is-mod.value" in the (playerUUID).yml file to "TRUE"
instead it does nothing
what am i doing wrong?
package com.dioz.plugin;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class setmod implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
File playerData = new File(Bukkit.getServer().getPluginManager().getPlugin("Utils").getDataFolder(), File.separator + "PlayerDB");
File f = new File(playerData, File.separator + p.getUniqueId().toString() + ".yml");
FileConfiguration pData = YamlConfiguration.loadConfiguration(f);
if(args.length == 0) {
p.sendMessage("ยงcPlease specify a player.");
} else if (args.length == 1) {
Player target = Bukkit.getPlayer(args[0]);
if (target != null ) {
File a = new File(playerData, File.separator + target.getUniqueId().toString() + ".yml");
FileConfiguration targetData = YamlConfiguration.loadConfiguration(a);
if(targetData.getString("is-admin.value").equals("TRUE")) {
targetData.set("is-admin.value", "FALSE");
}
if(targetData.getString("is-mod.value").equals("TRUE")) {
p.sendMessage("ยงcThat user already has MOD privileges.");
} else {
targetData.set("is-mod.value", "TRUE");
p.sendMessage("ยง6Successfully granted ยงa" + target.getName() + "ยงc MOD privileges.");
try {
pData.save(a);
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
p.sendMessage("ยงcPlayer must be online to grant MOD privileges.");
}
} else {
p.sendMessage("ยง6Incorrect syntax.");
p.sendMessage("ยงcUsage: /setmod <player name>");
}
return true;
}
}
CraftBlock does override hashCode() and equals() at the block position, so yes, it's fine
It will be unique for that position in the world. A block can be equals() to another but not necessarily ==, just something to keep in mind
I see, so listening to blockbreakevent and doing stuff from there
hmm but what about if
ok so
for example if you put tnt inside of a netherrack box
it will probably destroy everything
but if you put it inside deepslate
it doesnt break everything
can I replicate that? Or should I jsut use reflection or nms
Uhh
You could get real hacky and actually change the blast resistance internally
Not the best idea tho
public final class BlockTracker implements Listener {
private final Set<Block> playerPlacedBlocks = new HashSet<>();
public BlockTracker() {
}
public void addBlock(Block block) {
this.playerPlacedBlocks.add(block);
}
public void removeBlock(Block block) {
this.playerPlacedBlocks.remove(block);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
this.playerPlacedBlocks.add(event.getBlockPlaced());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
this.playerPlacedBlocks.remove(event.getBlock());
}
}```
would it be OK for this class to register itself
Like I pass in Plugin via constructor
is there an alternative?
hmm
honestly ill just do a tracker of the blocks and probs listen through event
not sure if I can replictae this though
do I have to make my own type of resistance system
and somehow disperse the explosion to the other blocks
Probably
hmm
I would avoid that
coupling registration to the instantiation of the class
just register it in onEnable
Should I feel wrong about making it a listener without mentioning the class is a listener in the name
A little bit
In general having a listener that also defines state implementation can be tricky
and by tricky i mean messy
yikes you're
using fileconfigs as a map
ow
Yeah that's what it feels rn lmao
Messy
I thought about having a BlockListener and inject the BlockTracker into it
Sounds good
Listeners, CommandExecutors are usually at the bottom of the food chain
No classes depend on them in your infrastructure
But they depend on higher ordered classes in terms of hierarchical abstraction
Please people, im too much struggling for some fucking reason when i execute /faction points info command. When getting the argument field data in my case must be taken from info argument. But its giving me his parent data (name, permissions, etc) which is wrong
Got some code?
yes!!
I can send it for sure
im totally sure its something related to recusivity thats making me struggle
https://paste.md-5.net/bapadoremo.java - This is my code which causing the issues
All the issue started because i was a getting no permission message when executing a child from a parent with the chid permission
So starting to debug i realized the data from argument field was containing the parent's data, instead of the argument itself
You are my last help lmao none of my friend know what happening and i really wnat to understand what happening
Can your permission be null?
not really
How can I apply {Marker:1} nbt tag to armorstands that I'm spawning in
if i use a constructor with no permission i pass them as an empty string (" ")
setMarker
And my isAuthorized() method checks first if the permission isEmpty() and them checks if the player has the permission
world.spawn(location, ArmorStand.class, as -> {
as.setMarker(true);
});
So i dont think its an issue with permissions, its something related to how the argument are parsed or something similar. Because when i run faction points info, where info is the argument. I get the data from his father (points in my case)
@glad prawn sorry for tagging
Worked perfectly, thanks
Hey, how can i get all registered commands that there are on the server. (Like luckperms getting all the permission nodes from every plugin)
getCommands() on the command map
Idk if the CommandMap has a public getter
If not: its a field in SimplePluginManager
Not wondering to fuck, but have you worked before with commands Tree structure?
Tree structure?
If you have worked before, how you treat them if you would have to code to simple classes to managing them
Like sub commands of sub commands to be mo pointless
I just use ACF and let that handle it
oh right, thanks tho
Just asked because im struggling haha trying to fix something
Thanks, i will look into this
in case the getter is private you can just reflect it
if you using legacy versions CommandMap is getted from reflections from server class to be more precise
Ok
I have an idea, if it works ill share it here
Explosions give you a list of blocks affected. So you would use that list cancel the event. From that list check the blocks and either do nothing or destroy the blocks etc and track how much more it needs before it breaks. Or you can do the hacky way.
yup like before any of the explosions happen, make a hashmap of all the blocks I want to track and a double as their resistance and then take the damage of the tnt and get the affected blocks then subtract their resistance so if 0 or less then it will be destroyed.
the hacky way changes all the blocks of that type iirc so thats not what I need
The hacky way changes their blast resistance in the nbt data and then you let the server do the rest. To make this work you would need to check all the blocks for your type when chunk loads and change accordingly before anything happens. Or just make use of the api lol. I would stick with api because you dont have to worry about nms and end result is the same
I think the problem with this way is that
it doesnt really disperse the damage properly
like all affected blocks will get
subtracted with the damage
equally
idk how to go around that tbh
If you want a dynamic dispersal you can just measure using distance and decide how you want the damage to fall off. You could do is something like for every 2 blocks distance damage is reduced by a third or 0.33
is the affected blocks in order tho?
But i am pretty sure server already does this though.
what number do I base it off
Order of what?
basically how to do this
Maybe, dont think order is guaranteed
But you can always check distance
The explosion events give you the location of the block or entity that exploded. The affected blocks list you can just check their location. There is a method in location for getting distance to another location
Anyways, i can talk further when i get home in 4 hours. Currently at work
Itโs only the blocks that will be destroyed though
Say you want to make obsidian much less blast resistant, the blocks behind the obsidian wonโt be in the list
Since by default the obsidian stops the blast rays
So youโd have to manually recalculate the blocks to explode with the modified blast resistance of the obsidian
on scoreboard, how i can put a empty line?
Score emptyLine1 = objective.getScore(" ");
Score emptyLine2 = objective.getScore(" ");
Score emptyLine3 = objective.getScore(" ");
i try this, but doesn't work
so that means obsidian can't be less blast resistant than it already is without nms?
alr
getScore#setScore(int)
You need to set a score as well
How does #hasPermission() check for the permissions? For example if I gave a player a random permission via luck perms would #hasPermission(random permission) pick that up?
pretty sure plugins like luckperms change Player#hasPermission() to check if a player has a luckperms node
so probably best to use their api to check then?
just use has permission
alr ty
Use their apis if you want to make like my.permission.(value)
Nothign do but, i have seen the luckperms api and is really messy when you want to just simple values. I think their api is too much robust for just being a plugin
just use Player#hasPermission, or Vault if you need to check offline player permissions
LuckPerms injects their custom PermissableBase that overrides hasPermission: https://github.com/LuckPerms/LuckPerms/blob/master/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissible.java#L167
I have the next command tree structure for some strange and weird reason the debug is giving wrong outputs. I dont know the reason of them please i really need help. Ive been with this for 2 days for being exactly and i cant even understand the reason fo it. None of which i talked knows whats actually happening please just try giving a hand instead of ignoring me
Command structure:
faction(hcf.faction.*)list(hcf.faction.list)points(hcf.points.*)info(hcf.points.info)
When debugging the commands for some fucking reason im getting as debug output the object data from points command, which is the parent of the child node im executing as debug - So what i mean is that the debug info must be the one from points child command (named as info)
I wont stop until i find a clarify explanation of what causing this issue i know it must be something really simple to fix but i dont know the reason of it. And less when using recursivity which can bug everything pretty fast
Adjusting code thats causing the issue https://paste.md-5.net/cokawarisu.java
I can tell you really sure thats not an issue related to the usage of the api, meaning that its not an issue realted to a wrong typing of the permissions into the permissions plugin nor wrong permissions name. I already make sure everything is okay so no other way thats the issue is in the command api itself im creating
I will now adjust captures of the debugs i have done with the different outputs
lmao this is trolling too much i still with this fucking shit and cant udnerstand the reason, please dont ignore me ๐
is points supposed to be a command from faction?
yes, points is child of faction. And info is child of points
okay so I guess you just named them wrong in your command structure above
shouldnt it be hcf.faction.points
the whole issue is that when debugging i get the output like:
name=points, permission=hcf.faction.points
When im executing any child of points
Have you checked my code? maybe you realized what wrong
how did you define the command structure in the code
created 2 SubCommands (faction and points), then 2 childs list which is from faction
where
Via code
By creating their own classes
There you have an example how i register them, where points is ParentCommand too
I mean the names of the objects are no the best for this case but the structure is simple ParentCommand represents a list of children, which those children can have more children. Like how a linked list works
yeah more like a tree but sure
yeah a tree thats the correct term
I will send you the debug caps so you have a better seen f whats happening
how did you register the info and list commands
I dont see where you set the values of some of those variables before using them? Specifically the permission one
this actual execute method from ParentCommand
Same as faction
whats singlecommand
Ok but the parentcommand itself needs to have a default?
command which doesnt have defined arguments
Which i dont see you set one
what do you mean by a default? i dont wanna sound weird
Typically you dont want to leave something null
constructor probably
i mean all the command begin from FactionCommand, on it i register the FactionList and PointsCommand
Your permission variable is null in the parent. Yes the child ones set it but not the parent if its only the parent executing
I dont know how java works regarding this but if you have a bunch of final fields without constructor does it initialize them in implicit constructor?
I have constructors for them
Both of them, SingleCommand and ParentCommand
Yes but they can be initialized as null as well
where
Also if you are going to be using super its probably best you dont use final
Since its expected to change
https://paste.md-5.net/fagotuqode.java - Parent command
https://paste.md-5.net/ebemaqinot.java - Single command
You use final when you dont want it modified or make it more difficult
yes i know that
i did them final just for the constructor reason, them i will make them like setters
But the issue is more to permissions or recursity (this i think is more sure) because of the outputs im gettng
Ok but that could be a reason for issues possibly?
I am on phone so i cant just check lol
then why not remove the recursive lookups
if i send photo you can check them frost?
What i mean by check is tossing into ide and just seeing for myself lol
so what did you do to debug
from what i know it wont make possible creation of tree structure. Or ima be wrong here
you can look up elements using a stack, you dont have to use recursion
i did 2 souts of toString() methods of ParentCommand and the argument one
the toString() from parents is correct but the argument is wrong (only when executing a child of a child)
alright heading home now. Take about an hour
its okay there no probem i just appretiate the answers of you tring to help
Im sending you up the pictures of debugs
so you are testing the execute command of the parent right?
the issue is mainly with child of a child, example of where find issue is with commands like: /faction points info
where info is a child of child
what if you remove points, can you then get info successfully?
(if you reparent info to faction)
yeah i set info as faction child works with no issue
just issue starts when having a child of a child
discord doesnt upload the caps, give me 2
there i would make info a ParentCommand
do you want me to test that? i can do it np
yeah I guess
right i will do it
or just add another parent command between points and info
the most weird thing is that help thing works perfect
there is no issue with giving help messahge dynamically
but im too stupid that can make a simple permission not work haha
wdym help
debug 1 - Success (An argument)
Debug 2 - Success (A sub command with no arguments)
If you see up to there the outputs are correct, because faction is the base and points has faction as parent, which is okay too
Debug 3 - Not successfull
There starts the issue Steaf, if you see the command output is from the base command and not from points (which is the parent of info) . And also the argument info is wrong too
So.. Where is chunk pdc saving data? I mean, item's pdc is item tags, container's pdc it's container's tags, and what about chunk?
okay and now what if you put another parent command in?
i will do that, giveme 2m
Creating a 3 parent and a command with it, will tes tthat case
and how is the argument info wrong
if you realize in the execution the output must be in command={ name= points, bla} and argument= { name=info }
Because im executing a child of child, the output i getting is liked im just executing faction points
yes but its recursive so you will first print the faction information
in your prints, argument is just whatever child command you are calling next
hmnn i dont udnerstand pretty well this thing tho, could you make a small deep explanation
because thats what it does, and after that it needs to execute .list on points
small deep explanation is an oxymoron
so i have wrong recusivity?
i dont know yet
thats why I wanted to see what happened if you add more commands in between
okay i done that,m cap is uploading
but regarding your recursive code, you have this list of arguments, like [points, info], it starts by taking the first argument points and then looks up the object for it, which it finds. after that it will print the parent command of this argument object (factions) and the argument itself (points)
then it will take your list and remove points, this leaves you with just [info]. now it will try to execute info on the points command
thats where it somehow fails
yeah, so at this point command cant be faction and argument points, thats where it fails hehe
Its extrnage because i have been looking at it for hours and cant even realize
since it doesnt print command help its safe to say that argument is null somehow
do you want me to send help prints?
so better debug?
now the structure for debug is next:
- faction
- list
- points
- info
- meta
- info
right
sorry for taking so long im trying to make the debugs okay and being sure they are correct
its fine
in fact final goal is to learn whats happening for them trying to find a solution haha
Is this correct? before starting to debug
right perfect, sorry for being really asshole
no its fine
you arent being asshole xD
btw are you getting any messages in the game chat?
yes
with the messages i realized the issue with permissions there started everything
i realized that when i was giving the child of child permission message was still "no permission" when i give correctly the permission in luckperms
what permission did you put in luckperms then?
usage message is okay, thats is discarded out
testing with 1 permission which is the hcf.points.* i messed up when typed here
and how did you give yourself that permission?
yes, via luckperms
and the permission is the same as PointsCommand class
how, im not super familiar with luckperms
lp group user permission set hcf.points.*
lp user alexito2060 group set user
with op everything working
let me clear everything and recheck
Console debug from /faction pointsi nfo
can you send PointsCommand class?
yes
public class PointsCommand extends ParentCommand {
public PointsCommand() {
super("points", "hcf.points.*", "Faction points command");
register(new PointsInfo());
register(new PointsMeta());
}
}
public class PointsMeta extends ParentCommand {
public PointsMeta() {
super("meta", "hcf.points.meta", "Points meta command");
register(new PointsInfo());
}
}
public class PointsInfo extends SingleCommand {
public PointsInfo() {
super("info", "hcf.points.meta.info", "Points meta info");
}
@Override
public boolean execute(CommandSender sender, List<String> args) {
sender.sendMessage("info command executed");
return false;
}
}
There you have all the classes
Also i realized when i try to execute /faction points meta i cant even the usage message
in ParentCommand you have this line if (!isAuthorized(sender) && !argument.isAuthorized(sender))
does this mean you also need the hcf.points.info permission?
isAuthorized() is for checking the parent permission and argument isAuthorized for it child
so if i run /faction points info must be able with even hcf.points.* or hcf.points.info (any of it)
okay but what if you just give both explicitly?
you should be able to execute it
did you try that?
will try now
just fyi, bukkit doesn't know what * perms are
Having both permission (not being op) works
but they are not part of bukkit. I dont think thats the issue i already discarded that from debugs
you actually have to make code to interpret what * means in the permissions, but bukkit it treats that as a literal permission itself
yeah so sender.hasPermission(points.) will check if the player has the `"points.") permission
I will give you an example of how to handle * perms yourself
yeah, and the argument isAuthorized will check if you have hcf.points.info
yes, but you wont have that if you dont add it to the player explicitly
isAuthorized() just make sure the permission is not empty and then do Sender#hasPermission
what do you mean? for debugging im adding the permissions via luckperms plugin
exactly, and this is why I mention the star permission, because bukkit won't interpret what a star permission other then its a permission itself. It won't treat it as some global permission
from what I understand what frostalf is saying, hasPermission will not work for hcf.points.info if you just give the permission hcf.points*
but you are not using the luckperms api to check perms
you are using the bukkit api
namely bukkit.CommandSender.hasPermission
not wanna be dumb but i udnerstand the issue is just because im using an something.* withing my permissions?
yeah
if you used luckperms api then it should work as you are expecting it to, because luck perms knows how to handle star perms
bukkit does not know what you mean by that
but why? im just comparing literal strings
not according to bukkit, because * and info are two different things
ok but your demonstration proved it when you gave yourself the explicit permission
and not just the *
@pseudo hazel
you are using hasPermission
yeah
this is not from lp
i know, but luckperms add the permission to player ๐ค
so the fact that you have luckperms permissions does not matter to bukkit
luckperms doesn't add extra perms
it does something similar to what I showed
however, bukkit api doesn't use luck perms or invoke luck perms
you need something like luckperms.hasPermission(sender, permission) from the luckperms api instead of sender.hasPermission(permission)
^
but i never used luckperms so I dont the exact syntax
or you handle star permissions yourself
i mean if thats the reason, why when i give myself the parent permission (hcf.points.*) i can execute the /faciton points info
if thats what you are saying, that what i said wouldnt work ๐ค
I thought you couldnt
I thought the whole issue is that you couldnt use /faction points info
that is what I thought I read too, especially when you said it worked when you used the specific permission
the only thing I know with permissions and bukkit, is that bukkit doesn't know that star perms means global perms
steaf if you see, i can execute the info child with the parent permission. But not with the child permission itself
Luckperms integrates somewhat decently with bukkits permissiom api
So the problem is not related to how i call my nodes or the permission plugin
so it only doesnt work if you just have the hcf.points.info permission?
thats because you dont have the hcf.points permission
thats how you wrote your permission check
what what? im too losted sorry but i dont wanna sound troller this is not really easy for me
unless you are supposed to get hcf.points. if you just have hcf.points.info
you are saying you cannot execute the command if you only have the permission hcf.points.info is that correct?
which makes sense still
Basically you have to be able to execute a child command, either with the permission of the child or its parent. That's what I want to achieve so far
is what I am saying the case ?
yeah thats correct, we are understanding hehe
okay
atm just working the execution having his parent permission (hcf.points.* one)
so what you are wanting is inheritance, which I think luckperms can do?
bukkit api doesn't do this either
i already add code for checking those things they are inside my ParentCommand
not sure if you have to enable it or structure it properly in luckperms to have inheritance work
so that means that you not having the hcf.points permission will fail the permission check of if (!isAuthorized(sender) && !argument.isAuthorized(sender)) { since you are checking both the parent command as well as the child command
check frost
isAUthorized
why? im returning in case having none of the permission
because the check fails unless you have both perms
you are returning in the case where the command does not have a permission
yeah exactly
frost is referring to this one im pretty sure
yes
okay will change it to an or and test again
it should be an or check if they want the inheritance to work
lmao
i will shoot up im totally sure thats the whole issue ๐
but i wont sang victory without testing haha
i really appretiate both of your helps, really thanks bros
i will check it and came back it doesnt work, But there i will shotup haha
being with this since from 6 pm and its aroud 5.15 am
still not wroking ๐
Permissions are correct i copy-pasted
still saying no permission?
same as with child
now i cant run the command with none of them
i added the parent and no permission
then tested with child and no permission
this is chaotic at this point lmao
steaf are you still up? we continue struggling with frost haha
try flipping the check around?
instead of checking for false, check for true
and return true
right wil test that
take in care im returning true in case you dont have any of the permission
well if they don't have permission it should be false at the end
all the if statements should be returning true
the only time you should return false, is if some how none of the if statements executed
which usually means no permission or something else wrong
still same message
well if you flipped the checks around and returned true
that means it executed succesfully fyi
tested like that. thats what you mean
since you know that if check can't pass if it wasn't true ๐
yes, that means unless one of those is true
sendmessage won't execute
but it did execute
which means one of them is true
so it works
so if i dont have any of the permissions will join there right? just making sure we tlaking same thing hehe
if you don't have any permission, it won't execute that if statement
but if you have one of the perms
it will execute
oh lmao thats backwords what i need
i need player joining that if, when you dont have any
also, change all your other if statements to return true as well, and leave the one return false at the end of the method for command
ok,
this makes no sense and isn't how code works
typically defaults are left outside of code blocks and in the main method
this is called early returning
now frost?
i know about early returns just being too confused
also returning false in the command block causes bukkit to interpret that as meaning the command wasn't succesful ๐
this is why you generally return false at the end of the main method, but return true in the if statements XD
because to not hit any if statement means either no permission, something is null, or something else
ok, up to know my code should work right?
give it a test
yeah im doing it hehe
also you should return argument.execute(sender, args); instead of returning true there
thats a pretty big part of the recursion
right will apply that, thanks steaf for still being here
re debugging momment hehe, dont care with having it fixed haha
lmao this is fucking shit
i removed his parent permission and cant run the command, same issue we start doesnt allow to run sub command argument with it own child permission
have it print all the permissions and if you have permission to it when using /faction etc
then you can see all permissions and on which one it fails
i already seen the issue before and tell it on the start
the data is wrongly outputed in the child debug
only thing I can think of doing is using bukkit api to list the permissions it sees since you are using bukkit api. It doesn't matter what luck perms knows, its whether or not the api knows since you are making use of the api methods from bukkit
yes but not a permission problem
is something with the objects storing
because the debug output in the info child, as command the object data from faction and argument the object data from points
if it works when you have OP its by defnition a permissions problem
the only thing I do see interesting is that No Permission is sent twice, which means both child and parent are executing
and both are failing if checks
unless you didn't fix the child one to be similar how parent is checking
give me 5m
im re compiling
and sent all okay?
starting from faction until info all debugs
because im too much hard. And really want to fix it haha
maybe the parent thinks their child's a failure and the child also hates their parents and so they don't talk to each other and that's causing communication issues?
btw whenever I feel like making something involving permissions, i would make sure the system fully works if I am just in OP first, this usually filters out more than half of the issues
ok will tes ttoo
testing with op right now
op works all okay ๐
right
now you know 100% sure its a permissions thing
so you just need to know which permissions you have, which ones it checks, and which ones pass the checks
at every step
i discover a new issue ๐ก
having more than 1 child of child, its messing the base command (which is faction )
why don't you just use a command framework like acf ๐ฅฒ
you have told me that like thosens haha and i still with this
because its fun to make your own
yes!! and not has 100gb with shity annotations which i dont care
starting from there haha
maybe my parenting thing is broken?
in what way
if your .jar is 100gb after using acf, you must have done sth wrong in your shading configuration
have you seen in each parent i calling a register method? that register method takes the command object and makes a command.setParent(this)
Just trying to discover what happens the permissions are wrongly in the outputs
i said it in the start the outputs are wrong when debugging
I mean do you even use the parent except for printing it?
look ๐
thats what i said before, giveme the argument data the info parents and in the command the base one. Whcih is all wrong the outputs
Because output must be first line data from points and second line data from info
do you understand me @pseudo hazel ?
no
oh lmaoo 
it first needs to go to the factions parent command does it not?
so the first command it passes is factions
then points
then info
yeah, faction and points parsing outputs correct
it isn't xD