#help-development
1 messages · Page 503 of 1
what
Useful info: When running your server, it now unpacks the libraries it uses into a folder so you can just grab the version of Apache Lang (or whatever you want) that Spigot is using without having to look for the jar online
Snakeyaml for instance gets unpacked into the folder. It's great.
you can also download the javadoc with maven if you decide to use maven
Sure but why would you need the jar
...wdym why?
Why would you need the jar of the dependencies
Well, if you need to use StringUtils for a bunch of stuff, that is available with Lang. If you want to use YAML for a bunch of stuff, snakeYaml is right there available.
I guess alot of people here don't code outside of spigot though
True but if you want to use other dependencies you probably should be using a build tool
Depends on if it's a proper project or if it's a distraction-type side-chick of a project that you're doing out of curiosity and procrastination
Vaggos22 just create something unique or search good plugin ideas
Or take an existing idea and just make it yourself. Excellent practice.
Also that way you get to customize everything
I'm making a currency plugin, a chest-shop plugin, a cobblestone-ore generator plugin, and a skyblock plugin simultaneously. I have a hard time doing one thing at a time.
can we help me pls I have a NullPointerException
final DbConnection dbConnection = loginFactionPlugin.getDatabaseManager().getDbConnection();
import java.sql.SQLException;
public class DatabaseManager {
private DbConnection dbConnection;
public DatabaseManager(){
System.out.println("Mysql co");
this.dbConnection = new DbConnection(new DbCredentials("localhost", "root", "", "faction", 3306));
System.out.println(dbConnection);
}
public void close(){
try {
this.dbConnection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public DbConnection getDbConnection() {
return dbConnection;
}
}```
Here is my DatabaseManager Class
and you open the connection?
yes my database is connected
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;
public class DbConnection {
private DbCredentials dbCredentials;
private Connection connection;
public DbConnection(DbCredentials dbCredentials){
this.dbCredentials = dbCredentials;
this.connect();
}
private void connect(){
try {
Class.forName("com.mysql.jdbc.Driver");
this.connection = DriverManager.getConnection(this.dbCredentials.toURI(), this.dbCredentials.getUser(), this.dbCredentials.getPass());
Logger.getLogger("Minecraft").info("Successfully connected to DB.");
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
public void close() throws SQLException {
if(this.connection != null) {
if(!this.connection.isClosed()){
this.connection.close();
}
}
}
public Connection getConnection() throws SQLException {
if(this.connection != null){
if(!this.connection.isClosed()){
return this.connection;
}
}
connect();
return this.connection;
}
}```
is my DatabaseConnection
dont use minecrafts logger, and you are prob better using hikaricp
Okay so you think that can be better with HikariCP?
but do you have a request for resolve the problem ?
its a lot better setup and you dont need to include a driver
Hello, im getting an error when im trying to start my plugin. Is someone able to help?
error: https://pastebin.com/rimn42qT
Main-class: https://pastebin.com/Tjyq3fsc
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
should be another class
oh alright. that helps
thanks for now
does anyone know im I am allowed to use minecraft textures/models in a web editor for my plugin?
okay that's too bad
understandable but oh well
i guess I wont make a web editor đ
bruh last time i use gradle
yeah they are so fkg annoying, so far i blocked them so they dont send spam to me
you need it, for updating gradle or if you register on they site for doing other things
oh weird, in my case its asked to signup, like doesn Java for downloading Jdk's
where do you donwload gradle from?
the first link googles give, maybe wasnt the original site
oh no its was diff
Yeah Iâve never given gradle an email
dunno what they needed it for but it seems it was required or i wouldnt have done it
damn gmails ui looks still that outdated like 10 years ago
Okay so I need some help from you guys, is it possible to connect to a server with a .jar file, something similar to an afk client?
I know this is not spigot related, but I couldn't find anything.
What are you trying to make
Something like an AFK client, where you just put your email/password into a config.yml and it logs into a server.
so basically you want to hack?
Maybe he wants to do what i was planning, creating a real fake client which stays afk for the reason of plugin messaging channel, so then it doesnt sucks telling theres no online players - Hahaha
do anyone know how to solve this error? https://pastebin.com/zjbGkQR8
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Array out bound && NullPointer
can i somehow know what array?
what happened again with emails and passwords in a text file hmm?
Wut
How could I make it so player can continue flying after switching to survival from creative. This isn't working
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onGamemodeChange(PlayerGameModeChangeEvent event){
event.getPlayer().setAllowFlight(true);
event.getPlayer().setFlying(true);
}
Try delaying it a tick
kk
worked
I was wondering if someone could help me code something?
what
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
ask what you want
?ask help coding
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?ask coding a /withdraw command
tell us what you are looking for
?ask coding a /withdraw command
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Ok
why is it so hard to understand?
Have you code before? If not, have you learnt java before coding
Im ok
Not that good
what does this /withdraw command do
i think he wants us to code it
Withdraws attack dmge
No i just need a little help
But have you code before or not?
do you already have a code?
We cant help you if we dont know if you know how to code
Have you heard of strength smp?
Its when you kill someone you get +1 atk dmge
I was trying to make a command to withdraw strength
We cant help you if we dont know if you know how to code?? Also if you have any code provide it please
I do
Just not the best
đ„°
right
So whats exactly yo uare trying to do
You want to get help about coding smth?
Make a /withdraw command to withdraw attack damage
Yes pls
perfect
k
i watched kody simpson
dont be rude, he told he learnt java Âż?
he has to learn the spigot api too
it's not rude
but didnt he say he already code?
Oh ok
I can a bitâŠ
If you havent code anything, first steap is learning how to code in plain Java. Then learn how to use apis or libraries
Ty lemme try
I have some useful links if you want them
How can i change a player vision with the enderman vision in nms?
enderman vision is through a shader
i'm not sure you can
since I believe those shaders are loaded client side and there's no server packet for it
You could force them to spectate an invisible enderman I guess
There are some plugins that do this so it should be possible
then find those plugins and look at their source
Ah that's true, I hadn't thought of that.
jail
Ender jail
condemned to being an enderman
not that bad
just extremely hydrophobic and non confrontational
The one i found uses protocollib i wanted to do it with nms
the way they do it with protocollib will just need to be slightly changed to use NMS instead
ok, alex
Do you know why I have this error ?
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/zaxxer/hikari/HikariDataSource
I try to compile hikariCP in my plugins but it doesnt work
dependencies {
compileOnly "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation("com.zaxxer:HikariCP:5.0.1")
}
dont use the jar, its on maven central iirc
they are using central
what's that?
I don't have the jar
do you have multiple jars in the build folder?
no I just have my plugin in libs/
How? can you explain pls
ok so what I can do for implement Hikari CP in my plugin
this .
id 'java'
}
group = 'fr.spectr2155e'
version = '1.0'
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
dependencies {
compileOnly "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation("com.zaxxer:HikariCP:5.0.1")
}
def targetJavaVersion = 8
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}```
Here is my build.gradle
question
How I can do for implement hikari CP while using shadowJar
why do you use gradle if you don't know how to use it. If you want to start with developing use maven. its easier to understand and iirc you don't have to worry about shading since the plugin is added automatically by the intellij plugin.
Fairly sure all you need to do is add the plugin and then run gradle shadowJar
probably
bruh why am i not able to send images here
but don't use gradle if you don't know how to use it and if you are clearly not willingly to learn groovy/kotlin. If you want to use a builds stem then use maven. It does its job for small plugins
no verified
Alright so i have a question, how to get all of 3x2 empty spaces in radius of 50 and spawn a mob in the center of them?
Well youâd have to scan every block in that radius, if itâs air then check if itâs the right shape/size and then spawn the mob
Of course you can do some optimization
Since you are looking for spaces that are 2x2 you can scan every other block instead
it's not that slow
and you can only scan below a certain Y
i tried doing it and it does the thing instantly
i dont care what level it is
but the empty spaces are in the blocks
like in the picture
I mean of course it isnât going to take several seconds
But if you are doing it continuously itâs going to hurt
nope
only one manual use through the command
Youâll probably be fine then
yep but i still don't know how i should do it
i just need a general idea of how to
because i do not know
.
subtitles be like
what do you mean checking if it's the right shape
Once you find air, check nearby blocks to see if they match the shape you want
so i assume i have to make a loop to check nearby blocks of those nearby blocks
if I want to have a custom radius
Yes
and then since it's air space in blocks i just need to check if it's surrounded by something that is not air
Yep
are dashes an illegal character in SQL? is there anyway I can force the ability to use dashes or will I have to change up my current format
?paste
https://paste.md-5.net/ibepaxeqen.cs this is my error
INSERT INTO %s (_id, document) VALUES (?, ?))
why do you use dashes?
its what I was using with mongo
simply kept the same format
it'd be bothersome if it was an illegal character though
i would switch to proper sql conventions
as I'd need to add a restriction to every implementation of my database
I'm already ignoring like 99% of those
then its time to not ignore those
so if I can use dashes I'd like to know how
unfortuantely NoSQL formats don't work well with SQL, so no for my use case its not really practical
private static final String CONNECTION_STRING = "jdbc:sqlite:";
private static final String SQLITE_DATABASE_PATH = System.getenv("SQLITE_DATABASE_PATH");
private static final String COLLECTION_NAME = "test-collection";
private static final String DOCUMENT_ID = "test-document";
pretty much everything
is this a prepared statement?
that %s is confusing me
yes, but prior to execution the %s is replaced with a table name
private static final String INSERT_EMPTY_DOCUMENT = "INSERT INTO %s (_id, document) VALUES (?, ?))";
private static void addEmptyDocument(Connection connection, String collectionName, String id)
throws IllegalStateException {
final String query = String.format(INSERT_EMPTY_DOCUMENT, collectionName);
try (final var statement = connection.prepareStatement(query)) {
statement.setString(1, id);
final Document document = new Document();
document.put("_id", id);
statement.setString(2, document.toJson());
statement.execute();
} catch (SQLException e) {
throw new IllegalStateException("Failed to add empty document to table '" + collectionName + "'", e);
}
}
you can try something like
INSERT INTO "%s" (_id, document) VALUES (?, ?))
unfortuantely looks like neither '%s' nor "%s" works
huh
nope error seems to be around the - as well
- is blacklisted I didn't know _ was as well
mm musta miss clicked
one second let me try wrapping table name with %s again
okay yeah I got it working now
create table "abc-wwww" (
"_id" int,
"name" varchar(255),
"age" int
)
this works for me
i see
morice likely mixed up _ and -
- is blacklisted if you don't wrap it in string tags
true
thats why i thought adding string tags may be the solution
first issue is not using proper sql conventions
bit if it works eh
can do views or stored procedures though
this issue will be ignored I wish there was a nice replacement for SQLite with NoSql for local databases but there isn't outside of android
Realm currently doesn't work on computers
and they don't have plans on adding support either
h2?
Issue is I much prefer mongo when it comes to server databases however there is nothing locally outside of json
which would be a mess to make my own database for instead of just using something that already exists even if I have to abuse it a little
I did not enjoy the time with mongo
i love creating tables and playing around with stored procedures
I worked with mongo in prod so its where I'm most comfortable for one and two the storage format makes more sense to me
gotta love these statements
-- fetch the data from the OLTP database
open cursor for select od.order_id,
od.product_id,
od.price_per_unit,
od.quantity,
od.discount,
o.order_date,
o.shipped_date,
o.freight_cost,
cs.customer_id,
cs.company_name as customer_name,
cs.city as customer_city,
cs.country as customer_country,
pe.personnel_id,
pe.first_name,
pe.last_name,
si.shipper_id,
si.company_name as shipper_name,
p.product,
c.category_id,
c.category_name,
s.supplier_id,
s.company_name,
s.city,
s.country
from oltp.order_details od
join oltp."order" o on o.order_id = od.order_id
join oltp.product p on p.product_id = od.product_id
join oltp.category c on c.category_id = p.category_id
join oltp.supplier s on s.supplier_id = p.supplier_id
join oltp.customer cs on o.customer_id = cs.customer_id
join oltp.personnel pe on pe.personnel_id = o.personnel_id
join oltp.shipper si on o.shipper_id = si.shipper_id;
Java drivers suffice for me :P they are very nice to work with
Beautiful
my longest stored procedure so far is 130 lines xD
how tf you find this so fast
the other day I looked a few hours for nosql alternatives
pretty much everywhere
f
Duck Duck Go moment
bruh
baeldung my beloved
đŠ
those damn mongo queries they are too complex
final Document document = collection.find(new Document("_id", documentId)).first();
bookmarked thank you so much
need to try google after Duck Duck GO next time
Thats quackers
is duckduck in anything better besides dark web?
dark web?
duckduck go doesn't touch the dark web
Lol ye
I can't wait to start using my database API :3
I've never been so genuinely excited to finish something
que es "cosmos"
hmm looks interesting
I'm trying to reimpl what database type of thing we used at my work in an open source project
so essentially had to start from scratch and code this myself with keeping the data model in mind
why ping here
How can I check if a block is a sign
but any kind of sign, i dont wanna list out every wood type
nvm just found it
if (Tag.SIGNS.isTagged(block.getType())) {
}
block instanceof Sign?
state or data
Tags can be modified with datapacks
However datapacks can also make new tags which can be very useful
i dont see the issue
Well
Datapacks might be stupid and add potatoes to the sign tag
Granted no datapack worth using is going to do that
But still
Hey,
I have the following code in 1.17.1 using spigot mappings
PacketPlayOutPosition positionPacket = new PacketPlayOutPosition(
0,0,0,
recoil,
recoil / 2,
Set.of(
PacketPlayOutPosition.EnumPlayerTeleportFlags.a,
PacketPlayOutPosition.EnumPlayerTeleportFlags.b,
PacketPlayOutPosition.EnumPlayerTeleportFlags.c,
PacketPlayOutPosition.EnumPlayerTeleportFlags.d,
PacketPlayOutPosition.EnumPlayerTeleportFlags.e
),
0,
true
);
I want to update to 1.19.4
- Do I keep using spigot mappings so I don't have to change every single line where nms was used? Do I start using mojang-mappings and just deal with changing everything correctly? (It was pretty big)
- I need some tips using screamingsandals or any other tool to find out how the nms was changed
Just convert to nms mappings and use screamingsandals to figure out what goes where
So convert in 1.17.1 to mojang mappings
If you ask me, I'd switch to mojang mappings because it's not obfuscated. As for converting, just go to the version on screaming sandals, select Spigot and type the obfuscated packet name
yes
Wouldn't it also be better at the same time to use protocolLib?
Depends on how good you are with or without it.
I can get around with it enough
Just when updating code that I didn't write it's confusing
Alright i kinda get what I need to do now
Last question
I see people use ProtocolLib + packet wrapper
Why
Packet wrapper is just like
basically a multi-platform wrapper where each packet type gets its own class
auto-generated by scanning nms packet classes and just making a version where every single param is wrapped
So it's usually better to use both together
I'd just use plib
Oh alright
but if you're clueless about a certain packet, the wrapper might help
Gotcha
Alright lastly
If I check that, which is the 1.17.1 version of the PacketPlayOutPosition
Where did
Set.of(
PacketPlayOutPosition.EnumPlayerTeleportFlags.a,
PacketPlayOutPosition.EnumPlayerTeleportFlags.b,
PacketPlayOutPosition.EnumPlayerTeleportFlags.c,
PacketPlayOutPosition.EnumPlayerTeleportFlags.d,
PacketPlayOutPosition.EnumPlayerTeleportFlags.e,
)
come from
Like what even is EnumPlayerTeleportFlags
I know this
But I'm trying to figure out how the packet was made in 1.17.1 so then I can translate it
I'm just confused as in
Where does that even come from
Cause I know in 1.19.4 it no longer exists
In 1.19.4 instead of having flags we just have like 2 or 3 constructors
and variants of the same packet
I assume you mean that
And that's where the Set comes from
I assume now is when I need to seach for how the packet is made using .vg
Is there a method that can calculate the damage on an entity given a certain ItemStack? I can't use attack because it's not a main hand item
You can pull the damage attribute I think? If it doesn't have one it's 0.5 by default isn't it?
I think this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/ItemMeta.html#getAttributeModifiers(org.bukkit.attribute.Attribute) ?
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
If it doesnât have a damage attribute it may have default attributes
If it doesnât have either then the default is 1 damage (0.5 hearts)
But you also have to consider strength buffs, enchantments, etc
error: cannot find symbol
meta.spigot().setUnbreakable(true);
^
symbol: method spigot()
location: variable meta of type ItemMeta
anyone able to help?
?paste full error with code please
Oh wait is this on compile? What are you using as a package manager?
gradle
can't help there
Its undifed but you cant define ti lol
Is there any way to calculate moon's phase / current location?
I'm trying to store some data in a Mongo Database. I can store Strings but I can't get doubles, ints, etc to load.
(when i try to join i get that error)
here's the full class
I haven't used mongo before but I think your issue is that prestige doesn't exist in the database for that player.
getDouble returns a Double instance and when you assign a Double instance to a primitive it unboxes itself but because the instance is null an npe happens
Hey, I need help! I have a Crystal PvP arena in my SMP and basically, it allows explosions and I'm wondering if there are any plugins that can reset the arena!
Please @ me if you have a response!
I can't find way to detect player jump is there no way to see if player is jumping? Do I need to make my own detectors?
I've google and people in the past have made their own detectors
Something like
if ( player.getVelocity().getY() >= 0 && !player.isOnGround() ) {
// Code here
}
Would need to check if player is on ladders, slabs and such
Creating my own event for it and checker so I can just use event for it
Why would you like to create an event?
PlayerJumpEvent. I can make my stuff faster with it
Yeah or just directly call your code when you detect a Jump, instead of launching a bukkit event which is way longer
it takes 30ms to launch an event iirc (at least few years back then)
I'll test how long it takes
Don't hesitate to tell me the answer once you've tested
I need help with my code, so this is my current one, what it does it it spawns mobs in empty spaces, but it does it in every block that is air (so if the space is 2x2 it spawns 4 mobs), i want it to spawn only one mob per empty space but i don't know what i should do
private List<Block> getEmptySpacesInRadius(Block centerBlock, int radius, int emptySpaceSize) {
List<Block> emptySpaces = new ArrayList<>();
for (int x = centerBlock.getX() - radius; x <= centerBlock.getX() + radius; x++) {
for (int y = centerBlock.getY() - radius; y <= centerBlock.getY() + radius; y++) {
for (int z = centerBlock.getZ() - radius; z <= centerBlock.getZ() + radius; z++) {
Block currentBlock = centerBlock.getWorld().getBlockAt(x, y, z);
if (currentBlock.getType() == Material.AIR) {
boolean isSurrounded = true;
for (int dx = -emptySpaceSize; dx <= emptySpaceSize; dx++) {
for (int dy = -emptySpaceSize; dy <= emptySpaceSize; dy++) {
for (int dz = -emptySpaceSize; dz <= emptySpaceSize; dz++) {
Block surroundingBlock = centerBlock.getWorld().getBlockAt(x + dx, y + dy, z + dz);
if (surroundingBlock.getType() != Material.AIR) {
isSurrounded = true;
break;
}
}
if (!isSurrounded) {
break;
}
}
if (!isSurrounded) {
break;
}
}
if (isSurrounded) {
emptySpaces.add(currentBlock);
}
}
}
}
}
return emptySpaces;
}
i just need a suggestion how i would do it
Mark each block where you spawn a mob, and when going to a new block, check if the block isn't near a marked block
Then you can fix a minimum radius for instance, and a probability to it
You can also work with a radius in only some planes
See that as a distance
Then, if you need 1 and only 1 mob in every walled area (and that they could be of any size), you'll probably have to identify them
Idea: use pathfinding (such as A*) to see if there is a way between them, if not, it's a new space
would like if my event would fire
This is using nano time with simple event
Start End Diff
[10:45:01] [Server thread/INFO]: [AstrolPr] 837583716029300 | 837583716061900 | 32600
It's really fast lmao
Using milliseconds
Start End Diff
[10:46:13] [Server thread/INFO]: [AstrolPr] 1683359173625 | 1683359173625 | 0
Iâve got some proof of concept in my head to make players one block tall without a client side mod
- Force player into crawl mode
- Give player big speed boost to counteract crawl speed
- Make player invisible and disguise as baby villager with players head instead
Do yâall think this would actually work
Yeh it's like 0.03ms
I don't know how is the crawl moves different from the normal ones, but you should give it a try!
On different classes
start end diff
[AstrolPr] 837789279700400 | 837789279722500 | 22100
already tried x+2 and z+2
yes
but
it's already declared in JavaPlugin
so you don't need one yourself
okay
đ
what's wrong with it?
If I were him I'd just set a minimum spawn distance
He's never going to get a mob in every single cave
and caves connect
atleast use continue
true, I met my last bf in a cave
no, Leon
what's wrong with my code
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
Warp warp = warps.get(args[0]); // Might cause ArrayIndexOutOfBoundsException
Location location = warp.getLocation(); // Might cause NullPointerException
((Player)sender).teleport(location); // Might cause ClassCastException
return true;
} catch (NullPointerException exception) {
sender.sendMessage("The specified warp does not exist.");
return true;
} catch (ClassCastException exception) {
sender.sendMessage("This command is only available for players.");
return true;
} catch (ArrayIndexOutOfBoundsException exception) {
sender.sendMessage("Please specify a warp.");
return true;
}
}
you could just use a single multi-catch
duuude
1st that wouldn'T allow proper error messages
2nd try/catch for control flow is baaaad
it does allow for proper error messages
you just have to check which exception it is
but then it's the same thing, just in worse
more work to do in a multi
I mean, the current code already is a joke lol
lol
I am not sure if it would be more work, but it would just be contained in a single block, instead of having multiple
dude, send me this smiley again, and I'll be upset
but one block per "situation" makes much more sense
ah I see your error, you used separate return true. you could have done a single
ok that is true
if that is how you want it organized sure
no, I don't lol
it should actually look löike this
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command is only available for players.");
return true;
}
if (args.length == 0) {
sender.sendMessage("Please specify a warp.");
return true;
}
Warp warp = warps.get(args[0]);
if (warp == null) {
sender.sendMessage("The specified warp does not exist.");
return true;
}
((Player) sender).teleport(warp.getLocation());
return true;
}
I like the first one đ
no D:
ok second one is 12 lines, first one is 13 so second must be better
fix those returns though and first winsa
so much boilerplate code
mY CoMmAnD FrAMEwoRk sO mUcH beTTEr!!!
mine looks just like this
and I can work with it so its good
some things dont require insane rewrites to function
does it use functional interfaces?
ACF >
ah turns out the moment you connect windows enterprise to the internet with a expired license, it shuts down
you have to stop it from phoning home
or buy a license
if you can afford it, its a yearly license
or just use debian :3
depends on what you want to do
you can use linux in combination with enterprise
which is actually common to do
but linux can't control windows desktops so you need enterprise for that
idk I dislike windows from the soul of my... erm... stomach
where linux comes in handy is for handling the network booting stuff and holding the images
it does it much better then enterprise does and is easier to setup with linux
its basically both
hm ok
but its purpose is to handle the group policy and settings of the desktops in the network
basically its the domain controller
like LDAP
yes similar in a way
lol
Did it
package com.qntcore.minecraft_server.eventsextendedapi.events.movement;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
/**
* Event used for detecting when player jumps.
* This is not triggered using climbing ladders
* This is not triggered using potion effects (except jump boost)
* @author antritus
* @since 06/07/2023
*/
public class PlayerJumpEvent extends PlayerMoveEvent {
private static final HandlerList HANDLERS = new HandlerList();
public PlayerJumpEvent(@NotNull Player player, @NotNull Location from, @NotNull Location to) {
super(player, from, to);
}
public static @NotNull HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
@NotNull
@Override
public Location getTo() {
return Objects.requireNonNull(super.getTo());
}
}
Fixing problems if you encounter em (If you test it ever)
interesting that you allow the to location to be null
at minimum, the to location should be the same as the from
in this way, it should never be null otherwise it would be interesting to see what happens if a null was in there lol
Fixed "to" location is null it doesn't continue.
Fixed "to" location being nullable to notnull
https://paste.md-5.net/qewohuqufe.cs
why not just check player move event y change
or use jefflib's PlayerJumpEvent: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/events/PlayerJumpEvent.java
paper's listener is in the paper-hacks module
or watch the jump statistic
iirc there's an issue with that
you can set the y velocity to 0 to cancel jumps in teh statisitic increase event
I used that earlier but there was some issue with it, which I cannot recall rn
yeah it isn't quite accurate
it will consider some things as jumps when they really are not
oh wait, I DO use the statistics for that event
If MC considers it a jump is it not?
yeah probably
not always
but for the most part yeah
so it should be fine to use it as long as you catch edge cases
Changed to paste.md-5
Listening to jump statistics would have been easier
oh well
why don't you just do it like this
I saw it
Does scheduleSyncDelayedTask only get executed once?
yes
Tzhanks
only "repeating" tasks are run more than once
Okay tsym
Sadly jumping is impossible to detect with 100% accuracy since itâs client side
Yeah people can always fake their movement
But i mean, after all its mc and not counterstrike
Hi, how can I set item's display name to basecomponent?
You canât
Display names are just text
They dont have any âhover eventâ etc features
Yes, but default item's display name is a translatable component
So there should be a way to change it
Probably through the spigot interface
No, thats just whatâs being used when display name is not present
Iirc
I might be wrong
There's no spigot interface in itemmeta class
Maybe, but I still can set item's display name to a component
Guess go say hi to paper
E.g. using commands
I know that paper has api for this
I doubt the client will translate components in the display name of items
If it works though, @worldly ingot should PR it to spigot:p
But I'm modifying a paid plugin that is on spigotmc, so it needs to support spigot ;/
Yeah but you could also just say âsomeâ features are paper only
It doesnt have to support spigot 100%, its fine to add paper-only features
But as said, i doubt itll work in paper
Okay, so for now, I'll make it paper only
I'll check if it works
It works
are you doing it with the paper api or spigot api?
command
/give @p diamond_sword{display:{Name:'{"translate":"block.minecraft.diamond_block"}'}} 1
lol
Paper allows components in names and lore.
ok
Thought there was a spigot interface đ„Č
Spigot should too
It probably will
have you tried to see if it will translate json?
It won;t in titles
but perhaps in names?
@worldly ingot Didnât you say a bit ago youâd pr it?
Someone would have to PR it
@worldly ingot translatable components for display name when?
hmm isnt it useless to store both a timestamp and a date if the date of the timestamp is the same as the date (sounds weird lol)
date and time in dutch btw
True. Might be easier to get date on demand without converting
dunno what my databases teacher was on
sadly
but 99% is still pretty good though
lets just hold a timestamptz instead
Hello, how can I check if a player fall in water ?
check the block at hsi feet is water
this will always check water
only if he is stood in water
if you have a timestamp, then you have the date
besides, it would be better having the timestamp anyways because then you can convert to whatever calendar you want to use
if that is even necessary
not really, its just a college assignment where i have to implement a database from an erd
oh well if its a DB, then just use Timestamp
the DB should be able to obtain a date automatically using native methods
so don't even really need to create conversion code yourself đ
hmm lets not worry about timezones then
is it necessary to worry about timezones?
as long as you base the time off a timezone like GMT, you can factor timezones in later
might be better to use UTC
im trying to optimize my plugin (minigame)
which makes new void world for instance
I tried unloading all worlds and loading them only on demand, but this resulted in Loading terrain when player tries to access them, even tho I loaded that world before hand.
any ideas why it occurs?
my load world:
https://paste.md-5.net/bopotahuce.java
probably not
no point in using a scheduler. It still runs on the main thread
you could also force load the spawn chunk after the world is loaded
im executing that loadworld in async method
but players are getting joined only after load
not load world
but from where I execute it
hell ye manually resetting sequences in postgres in fun
wdym not the class itself
isnt the value of the entry the class you want
you need the EpicItemHandler and not the class you mean?
are you looking for a functional interface?
.class yes
you want to get an instance of a PoisonHandler?
and you also need the class?
why would you need the class, just use an instance
why dont you store an instance then, look it up and call getClass on it
PoisonHandler
? extends EpicItemHandler
im guessing thats an interfact or an abstract class
Map<String, EpicItemHandler>
are we thinking about a Map<String, Supplier<EpicItemHandler>>
okay, so have an abstract class that is extended on all classes that have enchants then you store the data in the abstract class
issue?
meaning you can put whatever instance that extends epicitemhandler in there
yes
you can call map.put("poison", new PoisonHandler())
^^
well why are you working with entries and not Map#get
define the methods in the abstract class for them to be overriden in the class and your done
didn't help
map#get needs a key
it checks the string
or do you need a map with a class as key?
well im still wondering what you ned the class for, isnt an instance enough
so Map<String, AbstractClass>
you can always call getClass() on the instance
So what is problem with string as key and abstract class as an value?
okay one minute
Map<String, EpicItemHandler> map = [...];
map.put("poison", new PoisonHandler());
map.get("poison") /* returns some kind of EpicItemHandler */ .handle(player);```
does your map stores classes as keys
Get requires whatever is first value inside of <>
public abstract class MyAbstractClass {
final String infoExample;
public MyAbstractClass(String info) {
this.infoExample = info;
}
public abstract String getData();
}
public class Manager {
private final Map<String, MyAbstractClass> map = new HashMap<>();
public MyAbstractClass getInstance(String name) {
return map.get(name);
}
}
public class ExampleAbstractUsage extends MyAbstractClass {
public ExampleAbstractUsage(String firstInfo) {
super(firstInfo);
}
@Override
public String getData() {
return infoExample.toUpperCase();
}
}
records :)
wait no
stupid java with their "records cannot extend classes" policy
atleast give us record classes then
Well records are meant to have a special memory layout
in the sense that they are readonly and thereby can be optimized?
I think it was regarding their hashcode or something
im thinking too much in c++ ways lol
The fields can be written to if that is your question
I think idk
I don't use records that often anymore
i just use them for avoiding the boilerplate code
Unfortunately Java 9+ ended up proving itself to be unviable with what I mainly do, so there is rarely a circumstance where I can even use records.
Well the JLS doesn't allow that since Java 1.7 (or something along the lines thereof)
The JVMS does allow that though
jvms = jvm?
anyone know why gradle is building fucking .jar.jar files? its fucking with my maven publications
JVMS = Java virtual machine specification - i.e. the class file format
ah ye it allows some things that the compiler doesnt đ„Č
What is your build.gradle?
ah thats what they mean with those object headers
also contains identity hashcode (https://www.beyondjava.net/records-vs-value-types#primitive_classes)
Primitive classes != Records
uh its kinda complex im including a general purpose build script i wrote so a lot of shit is provided by that
plugins {
// java
id 'java'
id 'java-library'
// package publishing
id 'maven-publish'
id 'signing'
// for shading in dependencies
id "com.github.johnrengelman.shadow" version "7.1.2"
}
version '1.0.4'
ext {
hasPaper = false
hasTesting = true
desc = "General purpose static utility library"
}
apply from: '../buildsrc/module.gradle', to: project
dependencies {
}
``` this is the build.gradle
<https://github.com/cold-src/buildsrc/blob/master/module.gradle> this is the module.gradle included
if I had to guess setOutputFile should not include the file extension
ah ill try
Ah no - https://github.com/cold-src/buildsrc/blob/master/module.gradle#L383 is the issue
oh that the shadowjar doesnt have a classifier
oh nvm
the filename includes .jar ofc
shit
Yep
How can I sink players into the ground like quicksand?
smth like this? #help-development message
why cant i cast this bruh fucking generics stop crying
perfect !
I'll place a cobweb inside
its probably with packets, i dunno the context in which that video was sent i only saw it
They are different type perspectively
its like List<T> vs List<Object>
cast it to ReceivedPacket<?>?
Worst case
nah
mind that its Callback<ReceivedPacket> -> Callback<ReceivedPacket<T>> so its like deeper
oh yeah
holy moly what is this
Since java type erasure đ€Ą
lol
works
if type erasure wasnt a thing and generics was enforced at runtime id quit java rn
Casting to object and back is quite frequent
Well its not that frequent to do explicitly, but ye it happens alot when compiling etc
Guys, hello everyone. I have 2 plugins and they are in conflict. If you hover over a block, a title should appear. But after adding the plugin - it stops working.
Well I've done it frequently enough that I won't bat an eye if I do it
Well I guess if youâre on a bytecode level like with mixins or similar stuff it may be more common to work with
But most applications should not have to deal with it on an infrastructure level
that looks like a lot of map lookups
but "it stops", are you using a scheduler or an event or smth?
bruh this a thing in sql too
Hello, how can I make a block invisible for a player ?
player#sendBlockChange
I've got this but this doesn't change the block :java event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData());
yes
@EventHandler
public void onPlace(BlockPlaceEvent event) {
Material material = event.getItemInHand().getType();
Block block = event.getBlock();
Location loc = block.getLocation();
block.setType(Material.COBWEB);
block.getWorld().spawn(loc, BlockDisplay.class, b -> {
b.setBlock(material.createBlockData());
});
event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData());
}```
all is working except event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData());
Delay by 1 tick
okay thanks
it always works
scheduler
I made thisjava @EventHandler public void onPlace(BlockPlaceEvent event) { Material material = event.getItemInHand().getType(); Block block = event.getBlock(); Location loc = block.getLocation(); block.setType(Material.COBWEB); block.getWorld().spawn(loc, BlockDisplay.class, b -> { b.setBlock(material.createBlockData()); }); new BukkitRunnable() { @Override public void run() { event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData()); } }.runTask(this); }And it's the same result
Are you sure you're not seeing the block display
I made 20L delay
and now, it replaces the block
@chrome beacon
you can use reflections library by idk their name
Yeah you can use reflection
this is no longer a cobweb block
I want it to be a cobweb
Then don't make it a barrier
normally, it fakes
The client controls the movement
probably need to open the JAR file and list all files under the directory
otherwise it only works for loaded classes i think
If it doesn't know there's a cobweb there it won't be able to walk in to it
so, how can I make the block invisible ?
You can't
okay thanks...
Get a display entity that covers the cobweb I guess
does anybody knows why this wont stop obsidian from generating?
also tried:
- BlockFormEvent
- BlockPhysicsEvent
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
//blocks.add(event.getBlock());
//startLiquidDelete(event.getBlock());
Block block = event.getBlock();
if (block.getType() == Material.STATIONARY_LAVA || block.getType() == Material.LAVA) {
Block toBlock = event.getToBlock();
if (toBlock.getType() == Material.WATER || toBlock.getType() == Material.STATIONARY_WATER) {
event.setCancelled(true);
}
}
}```
already what I made
but inside it's a cobweb
No not right now
you cant do it with reflection
the jvm doesnt organize classes under packages
i think
you can only loop through all loaded classes
damn chatgpt is very original
or open the JAR file and list the class files
not all classes are loaded
only when u use them they get loaded from the jar
just dont
Yea, tried that but obsidian and cobblestone generation doesnt seem to get catched by this
(I mean by the event)
Tried that in GrowEvent too, so idk im clueless tbh
It's the BlockFormEvent. Show your code for that
oh bruh
give me a sec
no its FromTo
nvm
FormEvent didnt work too for me and it didnt catch that too
maybe could be that im coding in 1.8.8 and it wasnt implemented there or smth
1.8 đ
1.8 pvp is better change my mind
Make sure your fork of fork of fork of fork of fork of fork of fork of fork isn't breaking anything
i understand that people like the new one
but i like 1.8 more so i code things i like there yk
1.8 game features might be nice, but the code base is so dog water
that is true
what data u want from it
and if someone recommends me to remove cooldown im going to be mad bc it doesnt feel the ssame even without the cooldown
try {
final String pk = "my.package";
List<Class<?>> classes = new ArrayList<>();
Class<?> kl = getClass();
CodeSource source = kl.getProtectionDomain().getCodeSource();
URL jar = source.getLocation();
File jarFile = new File(jar.getFile());
JarInputStream stream = new JarInputStream(new FileInputStream(jarFile));
ZipEntry entry;
while ((entry = stream.getNextEntry()) != null) {
if (entry.getName().startsWith(pk) && entry.getName().endsWith(".class")) {
String className = entry.getName()
.replace(".class", "")
.replace("/", ".");
classes.add(Class.forName(className));
}
stream.closeEntry();
}
} catch (Exception e) {
e.printStackTrace();
}
``` this is like ultra stupid but i think smth like this might work
yes this
so i see in the docs that BlockFormEvent doesnt cover obsidian and cobblestone generation, so anybody have some other recommandations (1.8.8 it does cover it in the newer versions)
try with resources đ
Examples:
Snow forming due to a snow storm. Ice forming in a snowy Biome like Taiga or Tundra. **Obsidian / Cobblestone forming due to contact with water. **
Java 7?
lmao bro u using java 7?
Benchmarks?
1.8.8 docs doesnt say that it covers that
and as I said, i code in 1.8.8
what server version are you developing for
i know it does cover it in the newer versions
1.8 uses an older netty version and older lwgjl @quaint mantle which both are less performant
I could try that
Do you have benchmarks?
Sure
Yes
A lot of bugs
đ
Na thatâs beneath their dignity
Itâs improved significantly tho
Idk
Its pretty decent most of the times
mye perhaps
I mean
Thatâs what paper was doing in 1.8
Poeple dont fork to do nothing
^
Like sometimes fixing bug A introduces a new bug B
Generally yes
Always have zero day vulnerabilities
Because they fix those issues in the core server implementation
How can I give a player a custom permission?
Also FYI, anything below 1.19.4 pretty much has 0 support from spigot, paper and co
True
?
They won't fix bugs retroactively
PermissionAttachment
@quaint mantle
this works if ur loading from a jar file
try {
final String pk = "the.package";
List<Class<?>> classes = new ArrayList<>();
Class<?> kl = getClass();
CodeSource source = kl.getProtectionDomain().getCodeSource();
URL jar = source.getLocation();
File jarFile = new File(jar.getFile());
JarInputStream stream = new JarInputStream(new FileInputStream(jarFile));
ZipEntry entry;
while ((entry = stream.getNextEntry()) != null) {
if (entry.getName().startsWith(pk) && entry.getName().endsWith(".class")) {
String className = entry.getName()
.replace(".class", "")
.replace("/", ".");
classes.add(Class.forName(className));
}
stream.closeEntry();
}
System.out.println(classes);
} catch (Exception e) {
e.printStackTrace();
}
Can you explain in detail
try with resources đł
Also that while loop could be a for loop
i.e. for (JarEntry entry = stream.getNextEntry(); entry != null; entry = stream.getNextEntry())
nah i dont think so
hmm i see so much bad code on daily base it doesnt even surprise me đ€Ą
because the condition is evaluated after the first iteration right
before?
no, it's always executed
That is why you initialize entry once you define it
stream.getNextEntry()
stream.getNextEntry()?
oh
works like an iterator
while looks cleaner tho
yea ... and then you proceed to do an assignment within a boolean expression
what the fuck is this?
so
A for loop?
there is a reason while loops exist
better than writing entry = stream.getNextEntry twice
thats 2 extra lines with a while
I generally try to avoid (X = Z)
but it doesn't look scuffed
yeah
at that point you can just use while loops for everything
assembly looks scuffed too, will you also tell them?
yeah
Especially because you define your var outside the loop
Which is honestly a no-go since it won't be used after the loop
if it were to be used outside the loop it would be okay to have it be a while loop, but not like this
aha they used while loop before
wait does zip store entries like this
dir a | file a/b | file a/c | file a/d | close dir a
because then once youve found the package you can just break
instead of going throuhh the whle jar
fuck why didnt i do that initially
no.
unless you have reproducible file order that is - but chances are you do not
java.util.Vector is not thread-safe
Unless you never want to iterate over it as well as adding and removing elements that is
Vector is synchronized. If a thread-safe implementation is not needed, it is recommended to use ArrayList in place of Vector.
javadocs
But chances are you will either iterate, add or remove some element of it
Vector is thread safe
The javadocs are only partially correct
personally never used that class
You can sync arraylist too.
It's thread safe, but cannot be read in a concurrent environment
Unless you are very sure that an index exists
what should I do to make RPM / rate of fire
wdym with cannot be read concurrently?
If you do something like vector.get(vector.size() - 1); and another thread removes an element after size() but before .get() you have an issue
And the iterator will straight up fail if any concurrent modification is performed
The only real concurrent list impl is CopyOnWriteArrayList
hmm ye copying elements đ„Č
i once had to work with a copyonwrite arrayset and i had to add 1800 elems :(
I think you do .addAll in that case
i measured it and addAll was even slower due to the toArray call đ
decided to not care about it
If you know the size of the array at init time you can use AtomicReferenceArray
never heard of that tbh
Or just straight up use arrays but beware of store fences and other bullshit that arises from highly concurrent environments
just smth like an atomicref<T>[]?
if the compression method for the zip archive is store, which is no compression, then all you need is to pull the central directory file to know where all the files are at in the zip and just find the one you are wanting
More like atomicref<T[]>
does that guarantee threadsafe writes?
jar files don't have compression at least not that I recall
Yes. You just only have #set and #get (as well as CAS). #add and #remove does not exist
ahh hmm i saw minestom doing smth similar
Hello, how can I make an entity emit light ?
but i thought it was a volatile write with a varhandle which backs an array
im ooc mad
that is basically it to be honest
ah private static final VarHandle ITEM_UPDATER = MethodHandles.arrayElementVarHandle(ItemStack[].class);
setting an element seems to use a synchronized block đ
most likely due to indexing constraints
Hello, how can I make a block emit light ?
If you use an AtomicInteger and use CAS for incrementing/decrementing that integer you can avoid the sychronized block
ye
However that only allows appending after the last element or removing the last element.
Having a truely thread-safe and fully implemented list is impossible without the usage of synchronized
wait and notify?
sounds unsafe
that does use the waitset instead of the lockset but has the same principle ig
i wouldnt really know what to do with the interruptedexception that it can throw but whatever
What can I do to have unique hashCode or some kind of ID for every new instance of object?
let it use some combination of the fields hashcodes
In case all fields have null value, the hashcode will be excatly the same, right?
int hashcode() {
return [...] ^ System.identitiyHashcode(this);
}
Thatâs not how hashcode is supposed to work for the record
System.identitiyHashcode(this) will be the same for every instance right?
Different for every instance
but you can make it work that way if you override it
ahh
But uh, at that point you wouldn't want to override the hashcode method
Like, XOR'ing the identity hashcode with what is basically just a salt makes no sense
hashcode is basically some number
What it means is irrelevant in most cases. It should be the same number for equal objects though
ah now i understand why youre using System.identitiyHashcode(this)
thanks, this seems to works
however it's usage is noteworthy: It is used to improve the performance of maps such as the HashMap or other various Hashtable-derived structures
Why do you need that though?
its mostly used for sets and hashmap stuff
its how the buckets are formed
System.identityHashCode returns basically the object ID i think
im pretty sure its unique to every instance tho
Not really unique