#help-development
1 messages · Page 499 of 1
Got all the logs removed, how can I remove the leaves?``` public void timber(Block block) {
List<Block> logBlocks = new ArrayList<Block>();
do {
block = block.getRelative(0,1,0); logBlocks.add(block);
} while ( logs.contains(block.getRelative(0,1,0).getType()) );
for(int i = 0; i < 8; ++i) {
for(Block log : new ArrayList<Block>(logBlocks)) {
for(int x = -1; x <= 1; ++x) { for(int y = -1; y <= 1; ++y) { for(int z = -1; z <= 1; ++z) {
if( logs.contains(log.getRelative(x,y,z).getType()) && !logBlocks.contains(log.getRelative(x,y,z)) ) {
logBlocks.add(log.getRelative(x,y,z));
}
}}}
}
}
for(Block log : logBlocks) { log.breakNaturally(); }
}```
Lots of entities kills the fps
I have a region plugin and i dont want players from outside the region to activate a redstone block at the edge of the region by connecting redstones, how can i check for redstone going from block to block?
Charged creeper incoming[10:00:06] [Server thread/INFO]: [MrnateGeek: Summoned new Lightning Bolt]
Hello all! Im having trouble working out the placeholder for the ammount of people online, can someone help/tell me?
Like the way you would use placeholders like %vault_eco_balance% to show your balance, i need one for all online players using PlaceholderAPI
I don't know, is this like a plugin feature? Maybe #help-server
Already asked there
Well, I don't know. Not quite there on dev
so I'll explain my problem for the third time because I tried to fix it but it keeps not working...
https://paste.md-5.net/tuveyowoxa.js
why doesn't the inventory open when i rightclick the book?
Im trying to use BuildTools, but each time I run it, the line "Maven doesn't exist, downloading. Please wait." appears, and I can't use nms (I correctly set up the path)...
no
you asked for a short answer
it is the shortest one I know
use the paste site
not sure what is with people thinking posting such long ass code stuff in discord is ideal to read
?paste
not sure how that is a counter argument
the message is just long because I tried to explain it well
but ok next time i'll use the paste site
the advantage to using a paste site when you start posting code or configs
is that I can zoom out and see it all
also highlighting is better
How can I make it so that when the BossBar title is updated, the already displayed bossbar is also updated?
and if I want to toss it into an IDE its easier to copy
My idea was to save the Set<Player> of those who have the bossbar active, remove everyone and add them back, but I think it's counterproductive if every second I update the bossbar
Hi guys I coded a custom API and I want to use it in one of my other plugins but I get this error :
java.lang.ClassCastException: class dev.littlebigowl.api.EssentialsAPI cannot be cast to class dev.littlebigowl.api.EssentialsAPI (dev.littlebigowl.api.EssentialsAPI is in unnamed module of loader 'EssentialsAPI.jar' @612f6df7; dev.littlebigowl.api.EssentialsAPI is in unnamed module of loader 'test-plugin.jar' @21f16c88)
I added the API jar as a dependency in my pom.xml like so :
<dependency>
<groupId>dev.littlebigowl.api</groupId>
<artifactId>EssentialsAPI</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>path-to-jar</systemPath>
</dependency>
FYI I'm using vscode. Does anybody have a fix to this? I think the correct solution would be to add the jar in a different manner with the <provided> scope but that can't work if the jar is added with the <systemPath> tag.
that should be better
"And then every second set the bossbar to whatever u want it to and send the players the updated bossbar"
What about my previous idea?
There's a Per-World Bossbar
And, since bossbars are stored inside a map, that's why I believe it doesn't get updated
seems you are casting
ironically its complaining about casting to the same thing it started as
Is it the best way to achieve that result?
so I am going to assume you were wanting to actually cast to something else?
Yeah...
yep that's my problem
no EssentiasAPI is a separate plugin
that I want to re-use in another
with also date and something more
So i'm using getPluginManager() to get my plugin and cast that to the EssentialsAPI Object
I am aware of what EssentialsAPI is
however
it seems you are shading it?
Even with 50 it ought to be fine
this isn't going to work, API's need to be implemented
Unless you run a serial gc jvm with like minimal resources available
you can't just toss them in with your plugin and expect them to work
hmm. Not sure what shading means
how? as a dependency?
i found a solution to my previous task
now i rephrase it
How to find N closest(by value) elements of an array to the given number
for example:
Array = [1, 2, 3, 4, 5, 6]
Element 1 = 1
Task: Find 2 closest(by value) elements to 1 in the array(excluding element1 itself)
Result = 2 and 3
no bitches

i wanted to find all possible combinations of size N of elements in the array
are you just posting leetcode questions here xD
nah i need this to get a job bruh
😭

I mean, those kind of tasks have solutions online
why ask here lol
any ideas?
is the array sorted ?
no
there is literally StringBuilder#reverse
Have a look at kotlin
java extension
but its different from java
and the syntax is a piece of shit
if you really want to waste your time, learn assembly
Thats wrong
what?
Kotlin can compile to jvm compatible bytecode
o
...
What did you do? Is that apart of Java?
i believe orbyfied was making his own jvm compatible bytecode java extension
does a ClientBound packet mean the packet is headed from server to player?
or smth like that
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Dont mind me
yes
nice
mb
well regardless their question was answered
https://paste.md-5.net/tuveyowoxa.js
why doesn't the inventory open when i rightclick the book?
did you register the listener?
@wet breach You know EssentialsX? Check #help-server
You know how to not be annoying??
just say it like that "a packet that bounds to client"
a packet that bounds to server: Serverbound
bound as in sent to
ong
yep
if i replace t1book with stone it works
anyideas?
?jd-s
is there a way to remove the players current block damage progress
setting the stage to 0 with the packet is technically the first stage
((CraftPlayer) player).getHandle().b.a(new PacketPlayOutBlockBreakAnimation(-player.getEntityId(), position, stage));
stage is any integer between 0-9
could anyone troubleshoot my java plugin?
Why unmapped ;/
Also why NMS...
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#sendBlockDamage(org.bukkit.Location,float)
declaration: package: org.bukkit.entity, interface: Player
why packets? just use the API sendBlockDamage
yes
Yea
getMethod, getDeclaredMethod
mhm
Method::invoke
where you pass (null, args…)
null dictates the method should be invoked statically
(:
Class.class.getDeclaredMethod("myMethod", String.class).invoke(null, myString);```
Ah then getDeclaredMethod("myMethod",String.class).invoke(null,argument);
// myMethod(argument)
cool time to try
the APIuses a float 0-1 and it just looks cleaner with packets
Nothing you have said makes any sense
im confused what youre confused about
We’re not confused
like what about what i said doesnt make sense
But rather, your preference and justification regarding nms is quite incomprehensible
you would prefer to go though the extra steps of accessing NMS/packets just to copy something which is already in the API
its slightly different in the API
and that difference makes it annoying to use
and results in the same problem anyways
it does exactly the same job, and is a single method call
How is it annoying
identical across versions
because the API uses a float between 0-1 to get block damage
but the packet uses an int between 0-9
But how is that annoying?
so what?
adding 1 is easier than adding 0.1
It doesnt affect cleanliness whatsoever
lol
plus either way that doesnt really have anything to do
with my problem
because in either one setting the value to 0 doesnt remove block damage
it just sets it to the first stage
Seeing my eco at 4T+ on this casino game I play, I surprised. Now I in the mood to create plugins, Because EssentialsX has errors on 1.19.3, I going to try to create that
https://wiki.vg/Protocol#Update_Teams
I need some help understanding this
Using ProtocolLib:
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.SCOREBOARD_TEAM) {}
To listen to the packet
final PacketContainer packet = event.getPacket();
This contains the packet data. What layer does it actually contain from the wiki link
Like, the wiki link has field names and types. How does this actually work
You don't really need NMS for teams
The Spigot API can do everything you want
Yep you can do that with the api
No...
You can
Player specific as in
I know
I can only see the glow effects for other players
You can do that
But
Plugins like LPC
Interfere with the colors
If I use teams
I need to change the color only for the player to see the glow
I already did all the testing
Client-side custom color glow effects only on specific people
I'm just wondering if I should use a packet wrapper or not
What versions do you want to support?
If its not legacy, then in principle just stick with nms + mojmaps
Yea, much easier imo
i'm saving a class in a config file using FileConfiguration.set, but when i do FileConfiguration.get with the same path it returns a MemorySection, can someone show me how to fix
Then you just inject the packet channel
did you implement ConfigurationSerializable? and register it?
And ^ register it before using it
how would i do that, my class has variables that are other classes aswell?
read teh ConfigurationSerializable javadocs
You have to make those implement config serializable or just have methods such that you can turn instances of those classes into/from Map<String,Object>
Are Bukkit interfaces that use the Bukkit vector going to switch to using the JOML Vector3f
Do I have to copy the old transformation into a new object to change something about it
For a display for example
That seems wasteful of objects
isnt the bukkit vector like mutable
Hmm
Like itemdisplay
It seems like they’re immutable
Oh wait no
Because the underlying objects are mutable
sendBlockChange requires block data so how would that reset it if im passing the block data from the block to the new block?
im probably thinking about that wrong
As long as get translation doesn’t clone the underlying vector3f
But I’ll have to check that later when I’m home
Yea
you can create block data
First I'd try just sending the BlockData from the actual block. It will not have any damage as thats all been faked
I'm making a front end API that supports multiple Databases namely both NoSQL and SQL databases. I setup my arrangement which is more geared to Mongo database however, I also want to support something like SQlite for local database option. I looked around for NoSQL options like SQLite but couldn't find any. I'm currently trying to brainstorm a way to even set this up.
https://paste.md-5.net/kitowizani.json - sample data
Currently I was thinking of creating an empty table and appending rows as I needed my main issue is what to do with nested values like
for example object.object which conatins a string and int value my first idea was to append a column to the table named something like object.object.string or object.object.int, but I feel like eventually the table would get so unnecessarily large. Unfortunately I'm not sure what else I could do. I really don't want to have to resort to putting json into SQL that would be messy as hell.
anyone having problems creating a new IJ project with plugin development?
im getting
update ij
i am is update ij
how can i open a anvil so i can type a player name or sometihng
where does compass point originally?
World spawn I believe
if i set compass target to null
would it just reset
back to what it should be
i mean player.setCompassTarget()
can I stop a permission set to a permission attachment being reset every time the player joins the server?
apply it on join. Every time a client joins it gets a new Player object
i dont know what i changed but for some reason other classes cant find my main class?
clear caches
You'll need to write a bunch of code to convert a document -> table
Just made this plugin, please give me suggestions,
https://www.spigotmc.org/resources/chunk-claim-1-19-4.109567/
impossible to review as you show no code
I guarantee I could open a door in a claimed chunk though, even without seeing your code
com.yourname.claimplugin hmm
hello, can i receive help with my spigot acc in #help-server , right?
no saving, so claims only last until server restart/reload
uh and dont expose collections, write a layer above them instead
a static ClaimData class?
possibly
not much to look at meh
I'm trying to setup a cooldown for splash potions.
each time you throw a potion you gotta wait a few seconds to throw another one.
here's my code:
@EventHandler
public void onLaunch(ProjectileLaunchEvent e) {
if (e.getEntity().getShooter() == null) return;
if (e.getEntity().getShooter() instanceof Player) {
if (e.getEntity().getType().equals(EntityType.SPLASH_POTION)) {
Player p = (Player) e.getEntity().getShooter();
Map<UUID, Long> cooldowns = FFASystem.getMain().getCooldown();
if (cooldowns.containsKey(p.getUniqueId())) {
if (cooldowns.get(p.getUniqueId()) > System.currentTimeMillis()) {
long timeLeft = cooldowns.get(p.getUniqueId()) - System.currentTimeMillis() / 1000;
p.sendMessage(ChatColor.RED + "You must wait " + ChatColor.RED + timeLeft + ChatColor.RED + " second(s) to throw another potion!");
e.setCancelled(true);
}
}
FFASystem.getMain().getCooldown().put(p.getUniqueId(), System.currentTimeMillis() + 3000);
}
}
}
eaerly returns my friend
Not verified? Upload screenshots here: https://prnt.sc/
ah 1s then
!verify
Usage: !verify <forums username>
if its null it wont be an instance of a player
!verify AngeloContre4324
A private message has been sent to your SpigotMC.org account for verification!
here's the issue
also when u keep triggering the event it resets the timer
id recommend you to work with Instants instead of longs that say nothing
you probably want / 1000 after you substract curr millis ig
@EventHandler
public void onLaunch(ProjectileLaunchEvent e) {
if (e.getEntity().getShooter() == null) return;
if (e.getEntity().getShooter() instanceof Player) {
if (e.getEntity().getType().equals(EntityType.SPLASH_POTION)) {
Player p = (Player) e.getEntity().getShooter();
Map<UUID, Long> cooldowns = FFASystem.getMain().getCooldown();
if (cooldowns.containsKey(p.getUniqueId())) {
if (cooldowns.get(p.getUniqueId()) > System.currentTimeMillis()) {
long timeLeft = (cooldowns.get(p.getUniqueId()) - System.currentTimeMillis()) / 1000;
p.sendMessage(ChatColor.RED + "You must wait " + ChatColor.RED + timeLeft + ChatColor.RED + " second(s) to throw another potion!");
e.setCancelled(true);
return;
}
}
FFASystem.getMain().getCooldown().put(p.getUniqueId(), System.currentTimeMillis() + 3000);
}
}
}
that code could use a lot of cleanup 😢
Birb
I know that much, but is my plan like semi plausable
that did the trick, but now it says:
You must wait 2 seconds > You must wait 1 seconds > You must wait 0 seconds
just round up
I would like it to send
You must wait 3 seconds > You must wait 2 seconds > You must wait 1 seconds
Math.ceil i believe
ohhh i see
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
@EventHandler
public void onLaunch(ProjectileLaunchEvent e) {
if (e.getEntity().getShooter() == null) return;
if (e.getEntity().getShooter() instanceof Player) {
if (e.getEntity().getType().equals(EntityType.SPLASH_POTION)) {
Player p = (Player) e.getEntity().getShooter();
Map<UUID, Long> cooldowns = FFASystem.getMain().getCooldown();
if (cooldowns.containsKey(p.getUniqueId())) {
if (cooldowns.get(p.getUniqueId()) > System.currentTimeMillis()) {
long timeLeft = ((cooldowns.get(p.getUniqueId()) - System.currentTimeMillis()) / 1000) + 1;
p.sendMessage(ChatColor.RED + "You must wait " + ChatColor.RED + timeLeft + ChatColor.RED + " second(s) to throw another potion!");
e.setCancelled(true);
return;
}
}
FFASystem.getMain().getCooldown().put(p.getUniqueId(), System.currentTimeMillis() + 3000);
}
}
}
and use getOrDefault for the sake of god
oh my bad
when you write smth long you should wonder twice whether you can shorten it and how
we are repeating each other
how do i put code blocks morice?
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
If you plan to also support MySQL then I'd likely implement a proper native solution. But if it's just sqlite, then I believe that it doesn't really matter if you simply store it as json
I did have plans to implement MySQL at some point, but honestly I prefer noSQL
This better?
public void onLaunch(ProjectileLaunchEvent e) {
if (!(e.getEntity().getShooter() instanceof Player)) return;
if (e.getEntity().getType().equals(EntityType.SPLASH_POTION)) {
Player p = (Player) e.getEntity().getShooter();
Map<UUID, Long> cooldowns = FFASystem.getMain().getCooldown();
long currentTime = System.currentTimeMillis();
UUID playerUUID = p.getUniqueId();
if (cooldowns.containsKey(playerUUID) && cooldowns.get(playerUUID) > currentTime) {
long timeLeft = ((cooldowns.get(playerUUID) - currentTime) / 1000) + 1;
p.sendMessage(ChatColor.RED + "You must wait " + ChatColor.RED + timeLeft + ChatColor.RED + " second(s) to throw another potion!");
e.setCancelled(true);
} else {
cooldowns.put(playerUUID, currentTime + 3000);
}
}
}
also didn't know you could store json in SQLite
Then it's likely worth it to implement something properly if it's supposed to run on production
Json is just a string
damn that is dope
shhhh
what are you gonna declare you column as? varchar(10000)?
working with text in databases generally goes brr
I believe there's an explicit json data type
oh god
probably just JSON
that seems like the best datatype
hey I don't wanna be using SQLite but there is no equivalent for NoSQL
lol
its okay I don't fw god anyways
he can suck my big MongoDB
ALL THAT DATA
mmmmm
last one probably
Maven
My neighbor is called Marvin
i somehow want to use gradle to avoid using xml but that stuff caches half the universe lol
I'm about to go put JSON in a relational database and no one can stop me 😈
i live in your walls
I really don't want to 😭
Are you a brick
but I also don't want my tables to have 10,000 columns
🤷♂️ not 10,000 but its abit of an overexageration
like idk how well sql would handle a query of player settings if it had like idk 100 settings
that isn't a ton
but probably hurts response time
Overexxegeration, nice neologism
use a bitset id say
how would you do that though because can't you only query 1 key
UUID would be my main key
could I do like
SELECT WHERE UUID = ? and SETTING = ?
Yes
oh okay
You can have as many keys as you want
makes sense
PRIMARY KEY (uuid, settingKey)
ok this really is the last one
what about nested objects e.g. if i have
Setting.subsetting.thingy1
Setting.subsetting.thingy2
another table
that's the only place I'm actually hung up
relational databases my friend
Thats two different keySettings
I tend to think about data in a json format
its just how my brain be working
which is why it takes me like .3 seconds to setup mongo but 10,000 years to setup proper sql
Skull* issue
so how would I do this then? I'm just curious
💀
I'm just kinda confused on how to structure the queries
would I need a table for every sub setting
clearly forgot that stuff bruh
Writing queries is very boring
ah fun i gotta make this a db
Like woo I have to join 5 tables
when you're too lazy to write sql
JOOQ
Java object oriented query
hmm honestly this sql from non relation database thing looks like a huge pain json time 😈
i once wrote a reflective pojo mapper but i got scared of myself
I love writing pojo mappers
its so fun
soo much awful stuff exists
I’ve made one of those for configs
It’s a bit yikes to look at but shhh
Just don’t look at it
mine was with annotations and it looked awful, couldnt even handle all possible cases
and a lot of those awful stuffs are my code
my mapper is quite the monstrosity
It’s painful to look at but very pleasant to use
you aren't doing it right if its not both painful to use and look at
If it was painful to use I wouldn’t use it
It just magically turns maps and shite from and to config files
https://github.com/Y2K-Media-Creations/Raven/blob/master/core/src/main/java/sh/miles/raven/core/interfacing/object/processing/DataObjectProcessor.java
https://github.com/Y2K-Media-Creations/Raven/blob/master/core/src/test/java/sh/miles/raven/core/interfacing/object/processing/MockObjectProcess.java
just ignore the most hideous test class ever and I'd say its pretty nice
I sent the wrong test class 💀
Y'all need jooq or whatever
Jooq deez nuts
No
Is there any way to bypass the f character limit for player names? I mean over the head. The only thing I've come up with is to hide the name and then add an ArmorStand passenger with the desired name 💀
oh okay
Prefix and suffix with scoreboard give you more characters to play with
oh this is help dev
honestly more about safety
What is more safe about it
type safety
no malformed query
knowing that your statements are valid at compile time
of course doesn't replace testing
but assists it
someone know how to do darkmode in jd-gui?
why not
How long are you spending decompiling things
24/7 ofc
Hey guys
Anyone has an idea to turn TextComponent to a String with it's properties, or return TextComponent in PlaceholderAPI?
I'm trying to return a text with a custom font & the custom font is in resource pack.
Aka: /tellraw @p {"text":"SpigotMC", "font":"test"}'s return value should be the same as %customfonts_convert_test_SpigotMC%
I don't think that's possible
Oh...
You want the JSON format of a TextComponent ?
No
I want to return a text with a custom font (basically a TextComponent) in PlaceholderAPI
Oh ok
your obfuscator probably removing event listeners
need to retain methods with @EventHandler
why??? 😭
oh right it will take 30 seconds
instead of 5
obfuscation is pointless
your code is unimportant and ultimately useless
if a dev wants your code soo bad which I doubt they would
they will get it and you can't stop them
You are selling to consumers not developers, if you're worried about piracy it'll happen anyways, keeping yourself open source and non obfuscated will likely protect those who wanted to pirate anyways. No one deserves malware not even people who pirate
People who would buy or use your plugin probably can't code anyways
youre protecting yourself from developers who have the know how and persistence to break obfuscation
a good friend? yet you are obfuscating your plugin
seems fucking stupid
I'd just throw my friends source code lol
especially if they have devs
what does your plugin do
oh lol yeah no not worth it that thing has been done a billion times and probably been done better by someone out there. Its really not worth the time or effort
who cares if they decompile it anyways
non obf makes life easier on developers if there is an issue
for displays, if I only need one rotation, should I prefer left or right rotations
Both
ProGuard
I've alreday said there is no point
Obfuscation won't help you nor will it help anyone
Just write in kotlin. It pukes out weird jvm code
what do you mean?
there is no point, but additionally we're not gonna spoon feed you
you are making code for FOSS I think most things should be Open Source
there are plenty of premium plugins open source
No
oh I thought it was
open source actually I think
ProGuard is the free version
but definitely free
They have other paid options
ahh its a code shrinker
The best way to protect your code is to write code that’s so bad no one wants it anyway
Maybe that is why he wants to obfuscate
doesn't want anyone to look at their shit code
obfuscators only hide how shitty your code truly is
There's no other point
If you want a code shrinker then minify() on gradle's shadowjar thing
and fuck off
DRM is stupid and only slows things down
does anyone know what to do for this one
clockwise
okay yea
so right
why are there two?
I guess for axis angle you can't do all rotations with just one
I think
but for quaternions you definitely can so
idk its weird
shadow(jar) automatically looks at your fat jar and removes anything that's not used
actually
if left is left-hand
then that one would be clockwise
uhhhhhh
just gonna google
Is there any way to check for special characters?
like $%&/
and stuff
only abc123
thx
so does anyone know if left rotation or if right rotation is clockwise
I guess I can just test it out
see protocollib
lol
?xy
Asking about your attempted solution rather than your actual problem
they want to know why you need to get the tick that a packet is sent on
What things, why?
Why must it be tick based instead of time based?
Still unclear why that needs to happen on ticks
But packets are sent, received, and perceived by time
You don't view the world by ticks
Not to mention they're sent/received async anyway
It sounds like you're trying to make a replay system
Unclear why that system would be tick based rather than time based
If it is time based it will replay the events as they occurred to the real world perceiver (players)
System.currentTimeMillis
I used the gradle maven publish plugin to add a library to my local repo
I've gone to the folder to check and it's indeed there
But when trying to depend on it from a maven project it says artifact not found
You’ll never really be able to know when the other clients get the packet
I guess you could estimate based on ping
If you assume it's constant it doesn't matter
I used the gradle maven publish plugin to add a library to my local repo.
I've gone to the folder to check and it's indeed there
But when trying to depend on it from a maven project it says artifact not found
im trying to add tab completion to my commands that use a executor class to be added to the commandMap but i cant get the tab completions to work. the commands all still work on their own but just no tab completion, the relevant(ish) code for the executor class is in this pastebin: https://pastebin.com/bGS0XB9Y
and some of the tests i'm trying with the tab completes are:
@Override
public List<String> onTabComplete(CommandSender sender, String [] args) {
if (args.length == 1) {
return Collections.emptyList();
}
return Collections.emptyList();
}
}```
```java
@Override
public List<String> onTabComplete(CommandSender sender, String [] args) {
System.out.println("On tab complete called");
if (args.length == 1) {
ArrayList<String> options = new ArrayList<>();
options.add("name");
options.add("lore");
options.add("makeUnstackable");
return options;
}
if (args.length == 2) {
if (args[0].equalsIgnoreCase("name")) {
ArrayList<String> options = new ArrayList<>();
options.add("<name>");
return options;
}
if (args[0].equalsIgnoreCase("lore")) {
ArrayList<String> options = new ArrayList<>();
options.add("add");
options.add("clear");
return options;
}
return Collections.emptyList();
}
return Collections.emptyList();
}
};```
neither of those code examples for tab completions are working
minecraft does not organize events into ticks like other games
when the packet gets there it gets there
like the server has ticks
but its not realllllly synchronizing them with the client for the most part
Hello everyone so i was wondering how to make a plugin that removes specific blocks in newly generated chunks? I have spent a lot of time researching the right way to do it and a way to make it not crash the server by overloading it but unfortunately i have not found a decent way. I believe that once i've succeeded but my server crashed because i was trying to replace all ores to stone so it basically overloaded
I just need to know the event for generating new chunks and a proper way to loop through blocks to check which should be replaced/removed but also a way to optimize it
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/generator/ChunkGenerator.html Maybe within the generator? Not sure if it'd be better perf wise
declaration: package: org.bukkit.generator, class: ChunkGenerator
Thank you
I really have no idea too, last time i tried replacing blocks my server just gets destroyed
Well you'll be doing that regardless
The best way would be to remove the ore populators
where are they exactly?
I believe they are part of the biome
I'm okay with modifying the core
Hey I need help I keep having a exception in server tick loop and I can’t find any videos on how to solve it
what i want to do is a kind of complex anti xray which removes all ores on server and sets a tag on each replaced block, then whenever the player is around it sets the block to the tag that it has
by looping through players and getting blocks in 10 radius distance
pov: paper's anti xray
i don't know what you're talking about
it has no anti xray
It does if you turn it on
it literally has an anti-xray that sends fake block data to the client until you can actually see the blocks themselves
yeah well
it's not what I'm trying to do
sending block data to client
And you can make it either mask the real blocks as something else
or mask everything as a fake real block
one makes your client go completely transparent
I'm sure that's bypassable
it's not
It intercepts existing packets instead of sending new ones overriding old data
People just reverse engineer the ore spawning code anyway
run a custom world generator
Yeah that’s a decent solution
Also stops people using a seed cracker to find where ores would be
They generate the world
seed crackers
Oh
Usually the work off of stuff that’s tied to the seed
Structures, slime chunks, etc
The pillars in the end too I believe
then i make bedrock a 2 block flat layer
how would i go about it
.
or Iris
how about i just move all structures by 1-5 chunks in random x z coordinates
I mean structures are just one method
Plus you can already move them using the seeds in spigot.yml
Have a problem of my own. working on a crate plugin and on the gui side of things I am struggling with getting events to run. The event I am trying to call on is the InventoryClickEvent. The event will run the first time an inventory slot is clicked on but the second time I click on an inventory slot it won't work. I am using this library for 1.8.8 https://github.com/hamza-cskn/obliviate-invs . I'm really not too sure on what is causing this. the event is stored in the same class as the gui class. There is no error code and it shows no sign of the event being run as "onClick" is not printed to the console.
Event:
@EventHandler
public void onInvClick(InventoryClickEvent event){
System.out.println("onClick");
if(!Objects.equals(event.getClickedInventory().getName(), getTitle())){
ItemStack item = event.getCurrentItem();
System.out.println(item.getType().name());
addInvItem(item);
player.getInventory().remove(item);
}
}
Registering event:
public void loadCrateEditMenu(Player player, String crateName){
EditCrateMenu menu = new EditCrateMenu(plugin, player, crateName);
plugin.getServer().getPluginManager().registerEvents(menu, plugin);
menu.open();
}
I used the gradle maven publish plugin to add a library to my local repo.
I've gone to the folder to check and it's indeed there
But when trying to depend on it from a maven project it says artifact not found
Do you use shadow jar
publishing {
publications {
TSansHolo(MavenPublication) {
from components.java
groupId = 'me.tomisanhues2.lib'
artifactId = 'hololib'
version = '1.0.0-SNAPSHOT'
}
}
repositories {
maven {
// Adjust the path to your local Maven repository
url "file://${System.getProperty('user.home')}/.m2/repository"
}
}
}
It doesn't even find it on my other projects pom.xml
How does item pickup event work? How is it handled? Can someone send the source code page for it because I've tried and i haven't found anything on it
Check if the jar has -all at the end
-dev
tsansholo-1.0.0-SNAPSHOT-dev
<dependency>
<groupId>me.tomisanhues2.lib</groupId>
<artifactId>tsansholo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Theres the issue
In shadow jar add archiveClassifier.set(''
With closing parenthrsis
In the gradle task?
I believe gradle will also make a publishShadowJar task automatically
tasks {
// Configure reobfJar to run when invoking the build task
assemble {
dependsOn(reobfJar)
}
compileJava {
options.encoding = 'UTF-8' // We want UTF-8 for everything
options.release = 17
}
}
In shadowJar block if you have one
It's probably cause I'm using paperweight isn't it
You can use shadow jar to run reobf jar
Check the githud for how to run it with shadow jar
I always use it with modules so im not muxh hepp
Doesn't maven publish have a task to publish to local
Yes
yeah
Issue is it adsing -dev classifer
And then you just add mavenLocal() to repos
If you just want that add the classifier thing in maven
Top one
Yeah
how can I see if a bounding box is intersecting with the ground
or with blocks in general
and like maybe what direction that's happening in
I want to implement ground collision for an item display
anyone have any idea about this?
it looks like a lot of the time you're returning an empty list
yeah but that's kinda intended, it's still not even returning nothing though like returning an empty list should, it is giving the same behavior as returning null would (online player list)
Do you register the tab completer in time?
Also
i'm not sure
Consider implementing TabExecutor
Yes it wouldnt affect
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
new IdolTest();
new edit();
Just a bit shorter
true
Why do you extend BukkitCommand if I may ask first of all lol
Anyway
Override tabComplete instead
No need to use TabCompleter with BukkitCommand
Its for PluginCommand only
honestly i'm not very sure i'm pretty new to this and i mostly found this stuff from a tutorial
Extremely bad tutorial
Yeah
Did the tutorial tell you to reflect the command map also?
i dont think it did
Well then that’s on you
reflect the command map and extend bukkit command are only meant to be used in very niche scenarios where you hate adding stuff to plugin.yml
ok then i think it was the tutorial then
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
If you are just starting stick with the plugin.yml method
Follow that tutorial
yeah honestly that seems like a good idea
I only do so because my command engine is part of my utils and I just copypaste across projects
It also lets me not register certain commands if a database didn't load, for example
And then for TabCompleter,
implement the interface (or TabExecutor) and override onTabComplete(…)
where you use setExecutor(…) use setTabCompleter(…) also
you may have to do sth like
PluginCommand command = getCommand(…)
TabExecutor tabExecutor = …
command.setExecutor(tabExecutor);
command.setTabCompleter(tabExecutor);
I feel setExecutor also runs setCompleter
No?
I might be wrong but I don’t recall ever having to run both
Hmm
im pretty sure it should i think i saw smth about that on forums while i was scouring for answers to my original problem
Idk don’t take my word
I’ve been using my own system for long enough that I don’t remember
Coll thats not a thing
Unless md5 prd it post 1.18
Havent read that source file regarding 1.19
Fair enough
Ye I wish tho 🙏
Seems like a fairly simple change
If the provided instance also implements tabcompleter then do the do
(Or tab executor)
I think a better way is to have
<T extends CommandExecutor & TabCompleter> setTabExecutor(T tabExecutor)
But ye
Is there any way to check if a bounding box is intersecting the ground
Or like blocks or something
That’s an even better idea
I want to make it so an item display can “””collide”””
Yea
Yes but
Neat
:3
I don’t think it would allow it as an overload
Maybe not sure
Because of type erasure
Pretty sure that’s a unique name
You have the contains methods on BoundingBox
Hmm might be that type param is only allowed at classes and not methods idr honestly
Oh wasn’t paying attention
Should work with a unique name
But like I want to know if it intersects any blocks
Not specific ones
Any blocks that aren’t air
Do I gotta for loop through the adjacent blocks and do .contains?
mkay doing the command without the weird command handler thing fixed the autocomplete nonsense, also .setExecutor did in fact use the tab executor!
That feels slow
Yes it uses it
But you still have to set the tab completer to be the same instance
How would I go about getting the location of the BlockFace that a player placed a block on?
Hmm not too sure
BlockPlaceEvent
you have the block itself and place against block
Well yeah ik that i meant actually getting the specific blockface it was placed on
just call getFace
yeah just dont know how to determine which is the one that was placed on
BlockPlaceEvent#getBlockAgainst?
Conclure time to sleep it's 3 am
that returns only the block i need the BlockFace
Block#getFace
You could probably use the PlayerInteractEvent as the BlockPlaceEvent doesn't provide the face
Or just calculate it from the placed location and placee against block
alright thank u both for the help
It may not provide the face directly but you can use getrelative to get the face of the block you do want
wym the event provides the face directly
I meant if the block you wanted the face of wasnt the block in the event
oh i see
How would I check if that BlockFace was in the line of sight of a player?
Id have to use raycasting right?
You can cast a ray from the players eyes to the center of the target block face
Of course a player doesn’t have to see the center of a face to place against it so that’s not perfect
Either that or get line of sight and see if the block has open on the side towards player
Depends on some factors which would be more ideal
yeah that doesnt achieve the purpose though I need a specific blockface not any blockface of the block
Oh wait yeah you can just check if the players line of site collides with that block face
I’m fairly sure there is a getHitFace
RayTraceResult#getHitBlockFace
Ray trace from the player -> check if the hit block is your block and the hit face is your face
You cand get the direction of the player and direction of the blockface as the first check. Then if they are opposites check if there is a block in front. Get line of sight is sufficient for this. But now lets say you wanted to know if the player could see that face at all which would include weird angles then raycasting would be better for this
unfortunately im on 1.8.9 😦
That is alright you will just have to implement raycasting yourself
But reason i mentioned line of sight is raycasting has a performance hit or should say it takes a bit more power to do it. So if you dont really need it then dont use it. But do use it if its needed
Smells to me like anti schematica printer
yeah i have to include all angles so raycasting would have to do
Hey
I'm trying to do something for a specific player depending on the location
I need it to be extremely efficient. I was thinking of listening to the Update Entity Position packet. and perform as little calculations as I can
what are you trying to do
I want to send a packet to the player if they are in range of the hologram
Get the clicked block, get the placed block, basic math to determine the face.
Please don't raycast for that.
I need to be able to loop through a lot of hologram locations efficiently. Would a better way be just spawning it for every player on the server?
So you want the hologram to only be visible to specific people based on their location?
Position packet will work. Just use some math to know distance. You could at runtime create a map of locations. This would be the most efficient
Yeah so
Just to make sure frost
Keeping 1000+ holograms in a map on runtime
And looping through that is most efficient?
You dont need to loop
if there in different worlds you can filter some out by that and some other ways id imagine
Yup yup thought about this too
Isn't there a player#hideEntity method? Seems like it could be better than messing with packets. Or maybe it's only a hidePlayer...
Yes there is a hideEntity
Its not an issue to store 1k holograms in a map. However it is more important the map is setup correctly
That's what I would do, personally.
Gotcha
You want location as the key as that is what you have readily
Then each location has the hologram as value
That way you don't have to use a function just to get the data you need to check against all the time
But isn't that still heavy on the server?
No looping needed
If I want to get all the location within 20 block radius of a player
Only very slight mem increase. Like at most 100mb if that
GetNearbyEntities?
You use math to get your location 20 around and then check map for those locations and holograms
Isn't that still looping through the map?
No
Getting a "box" of 20 radius from the player and then fidning all the locations in the map that are inside that value
map.get(key) doesn’t loop
You find the locations first
.filter does
Does map#contains loop?
containsKey doesn’t
Beautiful
Your only other check is to ensure you skip duplicate holograms. Or holograms you already pulled from map
But that still didn't answer
How do I get all the valid locations from a map without looping through it
It's not just 1 location, it could be up to like 50
Its fine to have a loop for math. Thing we are avoiding is looping through an array or map
Beat me to it
So you're saying not to go through every map element and checking if the key is within the player radius?
Correct
How is that even possible I am so confused
I thought to find all the keys that are within 2 values in a map I still need to loop through all of them
If it's a square of 20 blocks width and length, check for(i=0; i < 20*20; i++)
So we get our locations first and then check if any exist in the map. Using get. Get will return something or nothing
But locations from a 20 radius from a player
Math loop like that is lightweight
Math
That's like a sphere of locations around the player
20+cuurent location. Make this loop to get all locationa first
its fast enough it wouldnt harm performance id imagine
8,000 isn't that many tbh
So getting ~500 possible locations and then getting the keys from a map
Is more efficient than looping through a map
Yes
yes as you skip the ones you dont need
Alternatively you could use some kind of spatial partitioning
Because get fails fast
So where do I store the locations?
You dont
I thought we're avoiding going through stuff
My brain cannot seem to wrap my head around this
Check in the loop as you do the math. Then pull the holograms you found into temp array
Should I use location or vector?
Location
You're only looping over an iterating integer, not over a map or list
Map<Location, Hologram> hologramList;
Then using math get a possible location radius X
Around the player
Then try to get that location from the map
And store into a temp array
And then eventually loop through the array
I would make it a concurrenthasmap
This loop for locations and checking map can be done in a separate thread per player
Tell me something, how much more efficient is this than doing hologramList.filter
Lets say, 1000 locations
for 100 players
a lot more id think
So 1000 map elements for 100 players being checked every move event.
since filter loops and get doesnt
This is without optimizing stuff like filtering out micromovements and useless stuff
I just want to get a raw estimate of how much better this can be
Will have to wait till my break to explain it to you in why it is better
What you could do is ONLY check the locations that are 20 blocks away. If you check every time their block location changes, that's all you need to update.
Then you only track those very few that are in range until they leave range.
Good luck
My brain works differently then most peoples so sometimes i cant easily explain why this is better in simpler terms. My brain just understands it lmao
your mid shift helping people? lmao
Its not even the mid of my shift
I practically started it. I work from 7:30pm to 6am
But yes i commonly while at work help people from my phone lmao
u must have a job that doesnt require that much attention lmao
I am a tire technician
pay too little attention and you'll have a fancy projectile heading someone's way
Lmao
I dont repair tires unless we have none
I just replace them and that doesnt involve removing from rims or anything
Only tires i commonly mount or unmount is super singles
you code in java and you are single, this is the most common thing ever
Java Developers are Tires confirmed
I was for years but I have since attained that which seemed unattainable: I am now married to a beautiful woman who actually LIKES to watch me code stuff. O.O
I really don't get it but she will sit there for hours, alternating between scrolling through social media and watching me code.
thought I was special :/
^
Since it gets a direction too
that ones hard to mix up
well unless you deal with other coordinate systems regularly i guess
omg this is gonna create so much garbage
but I'm too lazy to figure out a smarter way
Smarter way for what?
Now this is very strange
Most people die of boredom at the site of coding
there is also a lot of code replication
because once again im too lazy to extract it out
just look at checkUp and you'll get the idea
They probably just like seeing the work even if it doesnt make sense to see the end result. Its like acknowledging the beauty in how things work from start to finish even if you really dont understand how or why it needs to be that way
Why are you using vector3f?
All that could be condensed into just a single method of 3 for loops
I knowwwww
I want to check the square on that side
of the box
to see if its colliding with terrain
for example up should see if there's anything intersecting the top of the box
Anyways, your only issue is going to be working with negatives and positives together
But that shouldnt be hard really. Only need to compare the x's with each other. If both x's are negative then the smallest x is east. If one is negative the other positive. The positive is east