#help-development
1 messages · Page 325 of 1
and use stmt.setString("mass")
not really rocket science, but perhaps the missing piece is that you use setString and getString for mysql enums in the JDBC
ah nah
lol
only for the self ofc
or initial values
to much brain stuff going on whoaw
frost can u write the DEFAULT for hugged_at if it's stored as a BIGINT
DEFAULT 0?
well you could set the default as some other time of your choosing
just write the number that corresponds to it
preferably the current time lol
default (whatever number)
well you can't default it to the current time without creating some kind of function
What if it's null?
also a useless default
typically you want to avoid null when possible
Couldn't you leverage that? Like, in your code, check if it's null and if it is, use it as an indication. Or use it to show None or smth.
anyone happen to know if worldedit has an easy way to convert block data in a schematic file into something I can cache as blocks relatively easily?
I want to read schematic formats but I want to do the pasting myself
but we are talking about the timestamp
why would you ever want to have a null timestamp
or a timestamp that doesnt actually reflect insert time
for hugged it makes sense because there is a case when that should be null, when the type is "self" or "mass"
but for timestamp, it makes no sense
null can be used to mean no value
if there's no set value then just make it null?
simple enough
so read the schematic files yourself
Ohhh. Well, do I have to define a default then? I'm used to passing in a lot of things anyways. What would happen if it is marked as not null, has no default, and nothing was passed in?
the code for it is super easy
it would error
or there would be no insert
don't know how the jdbc handles it
oh nonono
you can't trick me like that
I've seen what that file format looks like
its like 10 or so lines of code o.O
ok but what if the block is backflipping on a sunday and has a tattoo of an eagle in chinese characters and also it is in the extended position
But, so long as it's passed in, it should be fine? It's not as if I couldn't just do that for every insert that involves a timestamp. I'd likely include one anyways.
if it is marked as not null, and it has no value it would be null
Huh?
its weird but this only happens for data that was present already and you marked it as not null with empty columns
We're talking about new data.
for new data it would require a value
frostalf we aren't talking abt if you ALTER TABLE lol
https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html it would seem you can use a function value as a DEFAULT
lol I was explaining how you could have a null value in a non null column, but yes it happens on a alter table typically
so I can try and write a function to make a DEFAULT for the timestamp column
or frostalf could if he's up to it, because frankly I dont know many functions in mysql at all
didn't I state this?
no you said specifically you couldnt
refer
Yeah without creating some kind of function
I mean u said you could, but u wouldnt need to create a function
u would need to use one of the built in ones
;C
well
then use CURRENT_DATE function
but I think you would need to do some math however to turn it into an int
so you would need to do CAST(CURRENT_DATE) AS unsigned
mm I searched
you can use UNIX_TIMESTAMP()
that'll give seconds since unix epoch
CREATE TABLE `hugs` (
`interaction_id` INTEGER NOT NULL AUTOINCREMENT UNIQUE,
`hugged_by` VARCHAR(36) NOT NULL,
`hugged` VARCHAR(36),
`type` ENUM("normal", "self", "mass") DEFAULT "self",
`hugged_at` INT NOT NULL DEFAULT ( UNIX_TIMESTAMP() ),
FOREIGN KEY(`hugged_by`) REFERENCES `player_data`(`uuid`),
PRIMARY KEY(`interaction_id`),
FOREIGN KEY(`hugged`) REFERENCES `player_data`(`uuid`)
);
we're not going to make it a BIGINT and * 1000 simply because that'd be pointless
and waste storage, given that the function gives only second precision
on the code side, simply Instant.ofEpochSecond(rs.getInt("hugged_at"))
@kind hatch xd
Is this going to let me store System.currentTimeMillis()? I thought a long was bigger than an int.
no need to pass in hugged_at
no u wouldn't store System.currentTimeMillis()
the default gives second precision, so if you use the default just pass in unix seconds
(System.currentTimeMillis() / 1000)
but you won't need to pass it in anyways
??
what are u confused about
now you just need to do INSERT INTO hugs (hugged) VALUES (?);
for a self hug
arent you happy
yeah itzdlg found you a default for your column
u should be through the roof
🙂
interesting
its 4:36 am
I didn't realize mysql had a to base64 function
I need to go through this list now
to see what other cool stuff has been added
I don't mind passing in more than one value. All of my interface methods use longs. I pass in System.currentTimeMillis() because it's easy to read. I don't want to pass in a math expression. I'd rather have a slightly longer query.
pass in a math expression?
there is no slightly longer query
mate what
the query is smaller
😮
it knows UUID's
it has a UUID() function lmao
That's Maria
SELECT hugged_at FROM hugs WHERE hugged=?; for example
no theres a UUID in mysql
its not maria
there is link above to the built in functions list
that is the list I am looking at
PreparedStatement stmt = conn.prepareStatement("SELECT hugged_at FROM hugs WHERE hugged=?;");
ResultSet set = stmt.executeQuery();
set.first();
Instant huggedAt = Instant.ofEpochSecond(rs.getInt("hugged_at"));
lol, you can compress strings in mysql
like I should not need to give u all of this code, u need to read the things I've been giving u so far
the manual typically tells you how as well
well I think most of the issues should be resolved
If I get an item and change its meta, then copy it to another slot, and programatically check if their meta is the same, will it return true?
should play around with some of these built in functions
if its an exact copy yeah it should be true
No no no, not getting info. Setting the timestamp info. I thought we were trying to store the unix epoch, or System.currentTimeMillis() so why switch it to an int? We were going for millisecond precision in the first place. Or what was wrong with just passing in an extra parameter? INSERT INTO hugs (hugged, hugged_at) VALUES (?, ?) Does it make that much of a difference?
Alright thanks
you have no need for millisecond precision
there is no difference, the goal is to default whatever can be defaulted. otherwise, I'd hand you a create statement without foreign keys, no primary key, and just a name and type for the 5 columns
dropping millisecond precision, since you dont need it, will net you 4 bytes on every inserted row
not that that's a lot, but why not take the extra penny when you can?
not to mention it's saving you effort. there's nothing extra for you to do
merely renaming ofEpochMillisecond to ofEpochSecond if you want to use the Instant class throughout the code
I'm gonna have to re-evaluate this once I get some sleep. I'm pretty sure I'm gonna have to redo my entire interface to support this redesign of the database and that's gonna be a pain in the ass.
how is your interface coded
are you literally passing around fucking longs????
for time????
Yes
because if so, it should be redone
okay. It should be redone
no one passes fucking longs
you use Instant as the type in your data classes
I mean passing longs are okay
If you don't need to display anything to the user it actually makes sense
Otherwise, use LocalDateTime or somethin like that
in the DataManager classes it's fine
in fact in my data managers everything is as close to the storage representation itself it can be
once it gets into some
Interaction class though
needs to be an Instant, not a long
anyways if you severely want a long
Instant is just strange in UX world
PreparedStatement stmt = conn.prepareStatement("SELECT hugged_at FROM hugs WHERE hugged=?;");
ResultSet set = stmt.executeQuery();
set.first();
long huggedAt = (long) (rs.getInt("hugged_at") * 1000);
you'd be using a SimpleDateFormatter at that point anyways
Which breaks on instants
I've used it many times with an original Instant
I mean I mightve had to make it a Date first
but that's like a single method
Ffs, it's not about getting the data. It's about setting it. The int data type isn't large enough to store a long. So why am I setting the table to use an INT instead of something that can actually hold it?
holy fucking shit shadow
I guess it works with date, but date is very imprecise
Did I miss something?
Only a few years until a rollover
CREATE TABLE `hugs` (
`interaction_id` INTEGER NOT NULL AUTOINCREMENT UNIQUE,
`hugged_by` VARCHAR(36) NOT NULL,
`hugged` VARCHAR(36),
`type` ENUM("normal", "self", "mass") DEFAULT "self",
`hugged_at` INT NOT NULL DEFAULT ( UNIX_TIMESTAMP() ),
FOREIGN KEY(`hugged_by`) REFERENCES `player_data`(`uuid`),
PRIMARY KEY(`interaction_id`),
FOREIGN KEY(`hugged`) REFERENCES `player_data`(`uuid`)
);
PreparedStatement stmt = conn.prepareStatement("SELECT hugged_at FROM hugs WHERE hugged=?;");
ResultSet set = stmt.executeQuery();
set.first();
long huggedAt = (long) (rs.getInt("hugged_at") * 1000);
PreparedStatement stmt = conn.prepareStatement("INSERT INTO hugs (hugged, hugged_by, type) VALUES (?, ?, ?);");
stmt.setString(1, hugged.getUniqueId().toString());
stmt.setString(2, huggedBy.getUniqueId().toString());
stmt.setString(3, "normal");
stmt.executeUpdate();
and if you, for whatever reason, want to add a time (which you dont need to!!!!!!!!)
PreparedStatement stmt = conn.prepareStatement("INSERT INTO hugs (hugged, hugged_by, type, hugged_at) VALUES (?, ?, ?, ?);");
stmt.setString(1, hugged.getUniqueId().toString());
stmt.setString(2, huggedBy.getUniqueId().toString());
stmt.setString(3, "normal");
stmt.setInt(4, (int) (System.currentTimeMillis() / 1000));
stmt.executeUpdate();
That long will still be limited to the int size
you missed the fact that nothing changed minus I added a DEFAULT to hugged_at which is the current time
Im well aware
it's 5am and I'm pissed so Ill be frank
please dont comment if you havent read the past few hours of convo
An int suffices if you want to only store for the next 83 years, which should suffice
Sounds like you should get some sleep
He doesn't need the accuracy of a long, only down to seconds. So an Int is fine.
It sounds wrong, but I can't find the error in my maths so shrug
int for seconds will break in year 2038
if he manages to keep this code for the next 14 years, and wants to continue working on this project, I will personally write the changes he needs to make
Nah, it breaks in the year 2106
no, that's for milliseconds, as a long
I'm gonna hold you to that. lol
ah right, signed integers
2106 is unsigned int
we were both wrong
milliseconds as a long will break in over 292 million years
If we are using unsigned ones it breaks in the year 2038 - which sounds about right but might be a bit problematic now - it's just in 15 years
yeah idk how we're going to fix that
since a change would require the systems written by banks when fortran was invented to be updated
and heaven forbid
Well can't complain - I'll get big money soon
lmao
If anything else fails, just move the epoch time to 2038
You can just invert them
Remember, signed integer
technically the solution is to move it to 2038 since it's already expecting signed
yeah
but ehm
honestly solution is ot make epoch milliseconds, and then a signed 8 byte type
that'll solve the problem for as long as humans exist, probably
well shouldnt say that, idk if there'll be world wide destruction within 292 million years
Integer.MaxValue on potion effects gives me this instead of the nice infinite looking thing. Any way have it display xx:xx instead of numbers or is it a 1.19 thing?
not possible
Recently
damn that sucks
wtf why has it been removed
1.19.X defo, I'd guess 1.19.3
thats incredibly disappointing
Look, I'm tired. I'm sure you're tired too. I apologize for aggravating you. It was not my intent. I do appreciate the help. I'll re-read the convo in the morning and I'm sure I'll catch what I missed. I'll re-evaluate and keep trucking on. Again, I appreciate the help and advice.
I'm going to bed. Gn
looks ugly as shit
Probably to make aware that they don't actually stay forever
there are a few effects in vanilla which apply there
like bad omen
@kind hatch refer to the replied message when u wake up
it has the sql, how ot insert with or without timestamp, and how to get the long from a query with hugged_at
gn mate
never mind bad omen says 2 hours now
and no need to apologize
honestly Integer.MAX_VALUE is pretty similar to forever
like I'd rather see an infinity symbol instead of that xd
I calculated it its 3.4 years
wow, I have lived ~6.5x "forevers"
if I was still in the same world 3.4 years later and the potion effect magically disappeared
I would not be blaming the infinity symbol lol
Does someone know why this returns ServerLevel and not WorldServer: ((CraftWorld) player.getWorld()).getHandle(); and what method I should use to get WorldServer?
aren't those the same thing?
Level, Dimension and World are more or less synonyms if my mind doesn't fail me
am pretty sure they are different classes though
mojang moment
nvm it would seem, unless it’s changed since 1 7 10, WorldServer is the same
but uh
@quaint mantle where’d you get ServerLevel from
although I could’ve sworn that existed
I'm trying to create NPC in 1.18.2
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) player.getWorld()).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), npcName);
EntityPlayer npc = new EntityPlayer(server, world, gameProfile);
Does ServerLevel exist if u cast to it
yes
can you
I've done it like this now: WorldServer world = ((WorldServer) player.getWorld());
but this shouldn't work right?
no
because I am not getting the NMS representation of the world
that shouldn’t work xd
It's ServerLevel in Mojmaps
Ah that’s what it is
If you're using unmapped you're in for a bad time
I used BuildTools to remap
but its my first time with NMS
So I don't know if that was the right thing to do
When you're working with nms you need to use already existing code as a reference
So you can look at Mojangs code to see how things work
No worries
Ok thanks I will see what I find
If you don't have enough experience with Java this will be hard
I think I'm ok hahahahah
You never know in this discord
But I guess we'll see
Some people are making plugins on their first day programming
Which usually ends quite bad
I can imagine
I already found the solution
apparently this is the way to go (for future users):
CraftPlayer craftPlayer = (CraftPlayer) player;
ServerPlayer serverPlayer = craftPlayer.getHandle();
MinecraftServer server = serverPlayer.getServer();
ServerLevel level = serverPlayer.getLevel();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), npcName);
ServerPlayer npc = new ServerPlayer(server, level, gameProfile);
I highly recommend using the Citizens API when working with NMS
It already takes care of everything you need
ok thanks for the hint
Citizens has an extensive API for working with NPCs. Make sure you always are using an up-to-date build of the CitizensAPI to ensure that your plugin works with the latest release of Citizens.
on it
it looks very straight forward
I'm guessing skin changing is also included
ok nice
@quaint mantle what plugin are you making?
just playing around with NMS as I've never used it before
not creating anything interesting hahhaha
okk
If you want to learn a lot about NMS you should join one of the modding communities such as Forge or Fabric
ServerLevel is part of the worldgen
not quite the same as World
declaration: package: net.minecraft.server.level, class: ServerLevel
hm? Why are you using nms for that
You can just port it to the api
I mean if you really need to use NMS use FallingBlockEntity.fall(Level world, BlockPos blockposition, BlockState iblockdata)
but I do recommend using the api, it should be able to everything you need it to
throw on some metal music and make a speedrun of it
I have unironically been listening to gothic playlists for the past few weeks while working
just hundreds of hours of gothic breakcore as my background work music
worst part is when 10h playlist ends and you still have work to do
that's why there's a queue of 50 hours behind it
51h 10min playlist I have contains 783 songs 🙂
smh i got only 22 hours
Well, at least for 1.19.3, I can say that you can easily extend FallingBlockEntity and use the constructor for Level, x, y, z and BlockState
I don't make playlists, I'd go crazy
I'm listening to something in the background >14h a day
also I just realized I forgot to eat
man
what a day this has been
I usually have a 5 - 15 minute long piece on loop for a few hours to days
No need for long playlists at that point
I am just at the whim of youtube music recommendations
where are vannila boss bars stored?
am I doing something wrong when deserializing my list of configserializable objects? it works fine with single objects but it cant seem to find a getList() even though I have stored it as a list
wdym with "it cant find getList()"?
well I try to use config.getList(listname)
but it returns null
but when I try get(listname).toString() it does print some list type
namely teh list type of my object
Caused by: java.lang.ClassCastException: class [Lio.github.steaf23.bingoreloaded.item.tasks.BingoTask; cannot be cast to class java.util.List ([Lio.github.steaf23.bingoreloaded.item.tasks.BingoTask; is in unnamed module of loader 'BingoReloaded-1.0-SNAPSHOT.jar' @1cec6052; java.util.List is in module java.base of loader 'bootstrap')
hm can you show an example of how your config looks like?
- ==: io.github.steaf23.bingoreloaded.item.tasks.BingoTask
data:
==: io.github.steaf23.bingoreloaded.item.tasks.ItemTaskRec
item: BEACON
count: 2
type: ITEM
- ==: io.github.steaf23.bingoreloaded.item.tasks.BingoTask
data:
==: io.github.steaf23.bingoreloaded.item.tasks.ItemTaskRec
item: DIAMOND_HOE
count: 1
type: ITEM
hm that looks good
yeah and like I said it works fine when saving a single item
@SerializableAs 🥲
what does that do
usually getList() and casting it would work fien
List<MySerializableObject> myList = (List<MySerializableObject>) getConfig().getList("my-list");
In your error messag,e it looks like there's actually only one object and not a list
oh that's nice
are you sure you're actually reading the config that you just sent? try to use getAsString() on your config object and see whether it actually prints the correct file contents
yes its the correct file
(1.19) Hello, I hope you're doing well.
(Using NMS) I want to change skeleton's shotting speed and I found some threads, but that didn't work in code. anyone have an idea?
can you show the full stacktrace pls
okay
skeleton shooting speed is a bit tricky
since it's tracked by a cooldown field in one of its pathfinder goals
?paste
I've done that before by using reflections
or you can just override the goal with your own
what's TaskListsData line 32?
yes so i tried changing vars with overriding but cuz of private, i couldn't (https://www.spigotmc.org/threads/nms-skeleton-attack-speed.519883/)
Message.log(((List<BingoTask>) data.getConfig().get(listName)).toString());
set it to 1 instead of 0
using getList makes it fail at actually getting the list
also setAccessible
you could try to do ```java
List<MyClass> mapList = ((Map<List<String,Object>>) getConfig().getMapList("LIST").stream().map(MyClass::deserialize).collect(Collectors.toList());
I assume you mean List of maps and not a map of lists?
erm yes
sorry I directly typed it into discord
i typed Map<List because the method is called getMapList lol
I think im supposed to say its a a map of string.object somewhere
🤷♀️
ofc it's a list of maps
this is a list of maps
the first entry is a map [data: ..., type: "ITEM"] for example
data itself is a map
what u on about
I mean I would expect it to be a lis of serializable yeah
since both bingotask and the data are configserializable
yes but somehow it doesnt do that for lists, as it seems, idk
It should
anyway, anything in yaml that's "key <> value" is a map
true
well in any case... Inconvertible types; cannot cast 'java.util.List<java.util.Map<?,?>>' to 'java.util.List<java.util.Map<java.lang.String,java.lang.Object>>'
List<MyClass> mapList = getConfig().getMapList("LIST")
.stream()
.map(map -> MyClass.deserialize((Map<String,Object>) map))
.collect(Collectors.toList());
try this alternatively
i stopped using ConfigurationSeriazable completely and instead always just write my own methods using ConfigurationSections since idk it always caused troubles somehow for me
yeah it should lol
I mean now it says the map is empty
please actually do System.out.println(myConfig.saveToString())
it can't be that it's empty when it's not
something must be wrong with the path or the file in general or anything
no thats fine
{
Message.log(data.getConfig().saveToString());
List<BingoTask> tasks = data.getConfig().getMapList(listName)
.stream()
.map(map -> BingoTask.deserialize((Map<String,Object>) map))
.collect(Collectors.toList());
return tasks;
}```
java.lang.IllegalAccessException: class xyz.sodiumdev.pocket.event.PacketManager cannot access a member of class xyz.sodiumdev.pocket.Pocket$1 with modifiers "public"
I'm not trying to access any members of xyz.sodiumdev.pocket.Pocket. What's happening here?
Hi guys, can I give to player permission for 1 second?
like player.setPermission(); player.unsetPermission();
yes, you need a custom permission attachment
1 sec
PermissionAttachment attachment = player.addAttachment(this, "myplugin.mypermission", true);
Bukkit.getScheduler().runTaskLater(this, () -> player.removeAttachment(attachment), 20L);
oh wait
there's also addAttachment(Plugin, String, boolean int)
where int is the amount of ticks
so you don't even need to remove it yourself
player.addAttachment(myPlugin, "my.permission", true, 20);
```for one second ^
hm I see that you're now calling it CHEESE, earlier you sent a config where it was called LIST
and not CHEESE
Any help?
dw, I changed it
my actual list name is CHEESE because I recreate it right before getting it just to test my serialization
thanks
well yeah I can make it return a map list but its empty for me
show the full stacktrace pls
anyways thanks for the help
Reflection?
But yeah, show full stacktrace
Full Log: https://paste.ee/p/7FbSz
Also some code if it helps:
https://paste.ee/p/nrRIc
https://paste.ee/p/ejGiu
https://paste.ee/p/dbvAD
dont dare
I'd reverify https://paste.ee/p/nrRIc#s=0&l=26
Also, it might be possible that it is not possible to make static package-private method public
Or well accessible through reflection
Ah yes, more regex fun... Here's my current string:
Items[0].tag.StoredEnchantments[0].lvl[0].id
And I want that last 0 to be replaced with ..
I'm trying smth with positive lookahead like this:
0(?=]) which does give me only the 0, but all of them and not just the last one. Might someone have some insight or tips?
fyi i fixed it by cheating a bit, I now store it as a map of hashcodes and tasks, meaning I get get then values without using a dumb list
and its useful since I can use the codes as checking for duplicates which I dont want anyways
Yep, it's correct
Add a try-catch there
And always use e.printStacktrace
not System.out.println(e) or similar
Yeah I know
Nvm, I have a different, fundamental issue, I just noticed
Did you ever make that method accessible?
Wdym?
okay then you did not
does anyone knows if theres a method in the File class to return the name without extension? ig i can just replace it myself
i mean, what do you consider an extension?
myarchive.tar.gz
should that now return myarchive or myarchive.tar?
what about .files
like .ssh
i doubt there's a builtin way to get rid of "extensions" since the extension is basically just part of the name
The extension is generally everything past the first dot
in the case of lang.yml i was thinking of the .yml
ig i can use some regex to replace everything past the dot
I'd just remove everything after the last .
replaceLast("\\.*", "")?
(.+)\..+$
the first group would be everything before the last .
ugh
not much better than storing the name without the extension as im currently doing XD
Actually it's x.substring(0, x.lastIndexOf('.') == -1 ? x.length() : x.lastIndexOf('.'))
parsnip
Alternatively, just strip the last 4 chars
Though for that you'd need to make sure that the user uses FAT-12 or similar
lol
ig JavaPlugin#getResource also works with the extension
just refactoring some old code
it requires the extension actually
Unless you seriously want to sell that java's URLClassloader is seriously broken
Should I use PotionEffect.apply(entity) or entity.addPotionEffect(PotionEffect)?
lemme guess the first one is deprecated?
its the same
Nope...
It's exactly the same
But both exist, and one must be better than the other, right?
Either that or it's just a convenience for use cases
just choose one
How can I listen for player input without any visual lag?
I'm thinking of seating the player on top of a vehicle and then listening to some packets to get the input
player input? you mean like playermove event?
Yes, but listening to playermove event and canceling it creates visual lag
Can you even do that?
Because the client tries moving the server gets the move packet and says no essentialy
Okay so there is the ServerboundPlayerInputPacket
Which basically gets player input from a player in a vehicle
It is send for all kind of vechicles or just boats?
All kind of vehicles
even when player sit on zombie?
I think so
sitting on a zombie 🤔
Is there a way to exclude certain packages from a dependency with maven
since 1.19.4 it is possible to set passage with just a command
oh
/ride
acf crazy
even when running spigot 💀
yes
doesnt it use paper specific stuff?
im using paper anyways so ig i can change it
Anyone know why I would be getting this? https://pastebin.com/xpFXwEav
public class MainListener implements PacketListener {
@PacketHandler
public void onSteerVehicle(Player p, ServerboundPlayerInputPacket e) {
float sideways = e.getXxa();
float forward = e.getZza();
boolean isJumping = e.isJumping();
p.sendTitle("", String.format("Sideways: %s ; Forward: %s ; Jumping: %b", sideways, forward, isJumping), 10, 15, 10);
}
}
``` What do y'all think about this packet listening thing I made?
Is using base 64 to serialize and deserialize itemstacks bad especially for player vaults
It's okay
even if im storing it all in a db?
Yes is okay
Atleast most people use it like that for item serializatiom/serializatiom
?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!
[16:36:08 WARN]: [Skills] Task #566822 for Skills vSkills generated an exception java.lang.NullPointerException: null
how can i figure out where and why this is happening
?paste the whole stacktrace
bruh thats it
thats why im asking how to show it
there must be more than that
thats it
and if i add a try-catch for a NullPointerException i just get java.lang.NullPointerException
that skills plugins is yours right
yes
thats nothing with my plugin that caused it
is it just throwing even if you arent doing a command?
public static void run() {
final JavaPlugin plugin = Main.getInstance();
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
try (ResultSet rs = Main.database.query("SELECT * FROM auctionitems;")) {
while (rs.next()) {
try {
long time = rs.getLong("time");
String winnerid = rs.getString("winner");
if (System.currentTimeMillis()>=time && winnerid == null) {
String ownerid = rs.getString("ownerid");
int id = rs.getInt("id");
String bidderid = rs.getString("bidder");
int bidprice = rs.getInt("bidprice");
OfflinePlayer bidder = Bukkit.getOfflinePlayer(UUID.fromString(bidderid));
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(ownerid));
if (bidder != null) {
Economy.addBalanace(owner, bidprice);
updateId(id,"winner",bidderid);
} else {
updateId(id,"winner",ownerid);
}
}
} catch (NullPointerException ex) {
ex.printStackTrace();
}
}
} catch (SQLException ex) {
}
}
}, 0L, 20L); //0 Tick initial delay, 20 Tick (1 Second) between repeats
}
a lot can be null lol
time= NOT NULL
winner = NULLABLE
ownerid = NOT NULL
id = NOT NULL
bidprice = NULLABLE
thats the table columns
it would return null always if no data
docs say 0
hmm
well that shouldnt matter though
because time and id will NEVER be null
and bidprice will be 0 if bidder is null
bidderid or ownerid null?
ownerid will never be null
i'd say put a few breakpoints and let the debugger find the null
put a few sysouts
it could always be a simple mistake like a mistake while typing.
like how you have the add balanace, if that happened in the database, it might have issues finding a column and have default null and by that also causing your error
[16:51:17 WARN]: java.lang.NullPointerException
[16:51:18 INFO]: [Skills] [STDOUT] time: 1674404828116
time: 1674404828116
bidprice: 0
id: 1
ownerid: 5ba49baf-a49e-4130-aea2-002bea5ed8e8
winnerid: null
uhh idk what is null now
remove that catch nullptr
why are you doing that sync too
AuctionHouse
heres my table reference
Main.database.update("CREATE TABLE IF NOT EXISTS auctionitems (id NUMERIC NOT NULL, "
+ "itemstring BLOB NOT NULL, "
+ "ownerid TEXT NOT NULL, "
+ "orginalprice NUMERIC NOT NULL, "
+ "winner TEXT, "
+ "time NUMERIC NOT NULL, "
+ "bidder TEXT, "
+ "bidprice NUMERIC"
+ ");");
it says winnerid here but in the table it looks like winner is the field name
idk if thats the problem
?
String winnerid = rs.getString("winner");
are itemstring or original price null?
cant be
also why are you selecting that every second lol
db is something you load from once and store to when needed
y'all are missing the obvious part that he's running it on the main thread
how do I create a new location?
Currently, I'm stuck on getting the world.
new Location(World world,32.0, 167.0, 85.0))
How do I set the world?
Bukkit#getWorld()
get the world from an existing player / entity etc, or through Bukkit.getWorld
ty
sighs
hahahahahaha
who i found here
You all said that because You havent seen one of My client which was calling me bot all time whenever he dm me
Hello, i need help please.
I have this code: https://paste.gg/p/anonymous/58b5972d03c44f1abc08a27fc5f11553
And the plugin works, and it start well. The problem is that it does not stop dropping objects
i think that’s called a class..
actually its called a Map<Map<Map<Map, Map>, Map>, Map>
ah no, i solved it, sorry
why is this taking name not UUID OfflinePlayer bidder = Bukkit.getOfflinePlayer(UUID)
what version
where are you trying to get name
exactly
because getOfflinePlayer(UUID) exists
ik
..
whats line 117 of ah.java
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(ownerid));
whats ownerId
what is in the db?
well yeah, sysout the uuid before doing UUID.fromString
this is the table
already did that
and?
time: 1674404828116
bidprice: 0
id: 1
ownerid: 5ba49baf-a49e-4130-aea2-002bea5ed8e8
winnerid: null
how your managing to npe on a valid uuid is confusing
i agree
Print everything
Which line is null?
117
l
What's line 117
.
that is the line
ye
Print owner id
i did
..
And did it error when you did?
no after on line 117
So you printed it, it printed a uuid and then it still errored?
ye
Based off what you told me
It sounds like java isn't working
Which I very much doubt
sometimes i just get [18:17:56 WARN]: [Skills] Task #45756 for Skills vSkills generated an exception java.lang.NullPointerException: null
version Skills be like
yep and the jar is Skills-0.0.1-SNAPSHOT and i have 3 classes with the same name
so gg
Oh btw the reason it says name is null is that UUID.fromString takes a String called name
And that is null
and still makes no sense
public static void addItem(ItemStack item, Player player, int price,long time, OfflinePlayer winner) {
System.out.println("\n"+(getItemCount()+1)+"\n"+ItemStackSerializer.toComplexString(item)
+"\n"+player.getUniqueId()+"\n"+(winner!=null ? winner.getUniqueId() : null)+"\n"+time+"\n"+null+"\n"+null);
Main.database.update("INSERT INTO auctionitems VALUES (?,?,?,?,?,?,?,?)",
(getItemCount()+1),
ItemStackSerializer.toComplexString(item),
player.getUniqueId(),
price,
(winner!=null ? winner.getUniqueId() : null),
time,
null,
null);
}
why
in my command info.sokobot.skills.ah.Ah.addItem(player.getEquipment().getItemInMainHand(), player, Integer.valueOf(args[1]),duration.plusHours(time).toMillis(), null);
why not
it looks like you dont know how to code
i do
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
yes
public void update(String sql, Object... preparedParameters) {
try (PreparedStatement ps = con.prepareStatement(sql)) {
int id = 1;
for (Object preparedParameter : preparedParameters) {
ps.setObject(id, preparedParameter);
id++;
}
ps.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
Hey there! I'm doing this...
String effects = itemEffects.get(PluginConstants.EFFECTS_KEY, PersistentDataType.STRING);
if (effects == null) effects = "";
// Adds the new effect to the string, and sets the item's pdc.
effects += effect.getType().getName() + ":" + effect.getAmplifier() + ":" + applierType.name()
itemEffects.set(PluginConstants.EFFECTS_KEY, PersistentDataType.STRING, effects);
And for some reason my item's PDC isn't getting updated. Thoughts?
u use this so you dont return a RS
It doesn't even seem to have the key in the pdc after that.
And then see if it works
well let me change me ah to 1 min
Idk if uuid is inserted as a string if you use setObject
it should im uploading rn
Re set meta
U setting the meta back to item?
[18:34:06 WARN]: [Skills] Task #110618 for Skills vSkills generated an exception
java.lang.NullPointerException: null
[18:34:07 INFO]: [Skills] [STDOUT] time: 1674412409819
time: 1674412409819
bidprice: 0
id: 1
ownerid: 5ba49baf-a49e-4130-aea2-002bea5ed8e8
winnerid: null
Any good scoreboard apis for 1.19+?
You didn't debug properly
lol
So much for printing everything
lol
You even showed the wrong line
i didnt
You did
i did lol
i added a line
better?
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(ownerid));
if (bidderid != null) {
OfflinePlayer bidder = Bukkit.getOfflinePlayer(UUID.fromString(bidderid));
Economy.addBalanace(owner, bidprice);
updateId(id,"winner",bidderid);
} else {
updateId(id,"winner",ownerid);
}
Learn to read stacktraces
That is basic Java
This should've been easy to solve but you showed us the wrong line
You mustnt be coding without knowing to read stracktraces
BRO READ THE CONVO
Tbf
.
Lmao
i got nothing the first time
LMAO
and every time i did it i got no stacktrace
When you add a line before the error ofc the old stacktrace is no longer valid
time to fix db issues
To conclude please don't code of You won't learn basic Java
😂😂
That is My final recoemdnatiom
i know basic java
ngl kinda funny almost every time i ask here someone says something like "do you know java"
Is this minecraft or is something cuasing the items to be added to my invenventory and is there a way to prevent it?https://imgur.com/a/8ognN38
The uri is blocked in My country
tbh, that prolly means you dont REALLY know java
i said the same thing when i was first learning and they were right
nah 1 time it was bc i was using Integer instead of int
It says you're umable to drop items in kit editor
So it adds the dropped items to your inv
Yeah that why we don't Say You that because it came out from our ass we Say it with arguments. You shouldn't substimate develoeprs who have years of experiences
Thats not what the code does unfortunely
??
Um wat?
What does the code do?
event.getPlayer().sendMessage(ChatColor.RED + "You're unable to drop items whilst in the kit editor...");
event.setCancelled(true);
PlayerDropItemEvent?
@EventHandler(ignoreCancelled = true)
public void onDrop(PlayerDropItemEvent event) {
if (kitEditing.containsKey(event.getPlayer().getUniqueId())) {
event.getPlayer().sendMessage(ChatColor.RED + "You're unable to drop items whilst in the kit editor...");
event.setCancelled(true);
}
}
i agree, but i also think its important to have a idea for a project and build on that when learning. As long as you are asking enough questions when you're using the api, i think its fine
but definitely frustrating when people ask for help and dont know the basics i agree
I was thinking about that but idk how to check if its outside the inventory
If they click outside, clicked inventory is null
Yeah also not because we are sshole, it's because devs Will explain You really technnical things which id You don't know them You won't understand
Check if clicked slot is < 0
exactly, devs are not teachers. I really like to observe the way my current teacher teaches her java course because it lets me understand how to work with people who dont understand as well
@EventHandler(ignoreCancelled = true)
public void onMenuDrop(InventoryClickEvent event) {
if (event.getClickedInventory() == null && kitEditing.containsKey(event.getWhoClicked().getUniqueId())) {
((Player) event.getWhoClicked()).sendMessage(ChatColor.RED + "You're unable to drop items whilst in the kit editor...");
event.setCancelled(true);
}
}
That good?
this is 1.8 ()
Shush
im aware
ah yeah thanks
?1.8
Too old! (Click the link to get the exact time)
If You are om legacy versioms You cannot expect yo get support please move to 1.19
Maybe some.ppl help but it's really oddy to code on legacy versioms
keep using obuscated code 🥱
He? I don't obfusctae code what make You think
nms ☠️
?paste
Yes
is there a way to unregister listeners or would i just have to use a boolean flag with an early return inside each event i use
?jd-s
is there any event for when snowball moving on top of water (when soulsand is on the bottom)
How is it odd? Theres some popular servers still running 1.8
doesnt hypixel use 1.6
still
No clue but minecadia and mineman club are 2 big servers that come to mind straight away for 1.8
someone said that they are using 1.16.5 with old combat mechanics or something like that
HandlerList.unregisterAll(listener)
because
kisses
POV: all hcf servers
jaja
Or u can unregister specific events by getting the handlerlist
but yeah
/glow command is not available in 1.6 its impossible
nope, no event.
they still play a shit ton
sooo what do i do to block them? someone literally spawned 16k snowballs to crash my server :D
lmao
There's ProjectileLaunchEvent
yeah but i dont want to cancel every snowball thrown
You can track them after launch
how?
Get location and block
and check if its water?
Yup
Like you'd usually do. Save them somewhere or similar and then check every once in a while if it is in water or whatever.
Well, just split it up in batches
What happens when snowballs are in water with spuld sand under?
^
they are moving on top
and lagging the server
tps was 9 last time i checked
Wdym "moving on top"
Use that event, check if snowball, then check location of snowball and get the block below it or where it lands if its water check if soul sand below and then cancel
"check location of snowball"
wouldnt it give me a thrower's location?
Ive done this same method but for sugarcane so you cant break bottom sugarcane
if im doing it on projectile event?
No
why
Projectile is the snowball
how does that work
Or give snowballs a "lifetime"
yeah thats a good idea
When a snowball is spawed add to a map snowball, long
Yh thats a good idea
why not just doing it with scheduled executor?
ok ill use it
Hey there! I'm doing this to remove specific effects from a player... java effects.forEach(x -> event.getPlayer().removePotionEffect(x.getType()));
Cme?
However it doesn't seem to work. The effect doesn't disappear.
I should mention that it's an infinite effect in duration
Is there an error?
nope
Sure?
it just doesn't get removed
sure as me being a human
Gotta send a captcha
What is effects btw?
Haste
No i mean
What is effects that you're doing foreach om
oh
From where?
It's from a list with objects called EffectAmplifierMap. Each then returns the type with .getType, which calls meta.getCustomEffects().get(0).getType();
it's all in order, and everything should work, but it just does not
Proof that getType returns correctly
Sort of
And here's it getting called with no errors
Yeah right? It's really weird
print player effects,print all the effects
player.getActivePotionEffects and the effects list you're iterating
ah wait
it was my mistake
on the custom events
pain
my bad xD
yeah works now
I made an OnItemHeld and OnItemUnheld, and sometime ago I rewrote them and copypasted the stuff from held to unheld, since they're similar
but forgot to modify them
i only modified the remove/add effect part
not the checks for items actually being held or unheld
so it was doing held logic on unheld
how to compile a system scoped dependency with maven?
like normal?
yeah
:C
how i can add a jar into maven with a normal scope?
system scope within the project path is deprecated and will be removed in maven 4
read the blog post send above
by mvn installing, then setting the scope to provided or compile, whatever you need. https://blog.jeff-media.com/manually-installing-jar-files-to-your-local-maven-repository/
Or use file://-repos
but then you also need all the pom files and stuff
Although I never used that hack in maven yet
not necessarily
hm anyway, mvn install is the only proper way
I'd argue that file:// repos are the proper way, but you do you
(although both are equally cursed solutions)
how is mvn install cursed?
It isn't present in a maven repository that is (easily) accessible to 3rd party crawlers
heh?
why would you care about mvn installing something to your maven local
if its not gonna have anyone else see it
yeah but how else would you depend on other people's stuff if they don't put it into some public reo
For closed source software your IDE's build system might be easier
what's easier than mvn install though
have your own repo - but it's harder
Its possible to create a maven repository on a web hosting? or i need a vps or something?
file:// repos. Requires a bit of knowledge about the layout of maven2 repos, but isn't witchcraft
If you have ftp access it is rather easy
hello, I want to instantly respawn when dying. This method works, but there's still the respawn button screen thing, even though I respawned. I can press it and it just closes the death screen since I already respawned, how remove?
and how would that now be public to others?
idk try waiting a tick
i think we are talking about different things
Crawlers would need to be smart, but it requires no additional setup cost for contributors
the situation for which I recommended mvn install was that someone had some .jar, e.g. spartin-api.jar that they now ant to use in their pom.xml
I'm not sure but try cancel this event
yes, that works
Yoi can't cancel pde
waiting a tick almost always works haha
thanks! works now
exactly lmao
oh I know what you are talking about
even procrastinating in minecraft
And if they're dead, tp, reset health etc
you'd also need to call the PlayerDeathEvent
also you'd have to manually drop their items
drop their XP and calculate the amount they would dro
sounds like way too much pain. rather I'd just stop the "you are dead" packet from reaching that player
or just live with the fact that the button is visible for 1/20th second
or wait a tick
funny, I change worlds when I respawn, before I implemented the auto respawn it would take 2 seconds to load, now it's instant
is there a way to do that when changing worlds without dying?
i.e. something like that works great
Lmao i'm exausted my IDE it's telling me that cannot access to an interface
what are you doing again
But everythimg is okay, the modules are loaded by maven, the paxkage is okay
new List<>();
if it's that I'm jumping ship
It's probably right
Although I think it's new Zombie() or similar
Alternatively, attempting to implement a package-private interface in another package
I have a core module which contains an interface called CommandHandler, then another module called Spigot which implements the interface i having issues. Finally when requering spigot module from a
CommandAPI command = new CommandAPI(plugin);
command.register();
So in that case i cannot access to any method and the IDE just tell cannot access to CommandHandler
It doesnt make sense what happening, because if the modules dependencies are okay, the package id is correct, imports, etc
What?
I described what im doing
Does that CommandAPI class implement register?
Yes, implements everything
And i checked the imports, mainly everything that may be causing that
Okay, and is the CommandHandler class on the build classpath?
Im using maven multi module
then make sure that you depend on the right modules
i checked that, but i will check again
And make EXTRA sure that you don't end up with recursive dependencies
i.e. core depends on api and spigot depends on core.
But api does not depend on core while core depends on api. That will be very nasty
And core's pom.xml?
As a sanity check, assuming 60 players and 24 gb is this patern of ram usage normal?
Core module
Got one plugin im a bit suspicious of and might need to do some recoding
looks normal, you can run spark to check if theres anything weird
?flags mgiht also help
Aikar's garbage collection flags: https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
?
Api -> Depends on bungeecord-api
Core -> Depends on api module
Spigot -> Depends on core module and spigot api
Example -> Depends on spigot (where im having issues)
So i dont understand the problem
the pattern is normal but judging from the frequency of peaks you may have a small issue
And what does your IDE say about it?
Hey
also im getting null point exceptions from structure growth events with pwns plnt growth plug
What does it think the classpath is?
How can I make my plugin load before everything
Could not set generator for default world 'lobby': Plugin 'BorderRealm v1.0-SNAPSHOT' is not enabled yet (is it load:STARTUP?)
I need to use it as a default world generator
Just the error said "cannot access to dev.alex.net.command.core.CommandHandler"
When i call any CommandAPi method from spigot module
What does it say about the build classpath
He? Im confused
Your IDE should tell you what jars are available. I want that list
it would be load: STARTUP
Oh when compiling?
What do you mean
in plugin.yml
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
This?
IJ's equivalent of this thing
oh ok i catch it
who knows, try and see
Its multi module that doesnt appear with modules
Because its tell you only the global dependencies, not the modules one
IJ moment
What are you needing let say? Do you want to get build output?
I'll tell you that much: I wouldn't be seeing that type of issues on eclipse
I want to see what jars are available, but since IJ doesn't expose them the only alternative would be mvn dependency:tree
Wait
Now when i compiled atleast i get an error, which i wasnt getting yesterday
Okay im really confuse, worked with more than 1y with multi modules
And now i have this shity issues 😡 😡 😡
Open these? They should have a library section
small questions Class.forName("com.mysql.cj.jdbc.Driver") this is not working for some users that use my plugin it say classNotFound etc etc
i tried to add the mysql to pom , but the plugin size will increase .
how i can fix it?
without increaseing the size of the plugin ,-,?
how can i solve this?
Why are you afraid of plugin size increase
i dont know what happens
whats main.java line 56
what is that artifact id
