#help-development
1 messages · Page 1535 of 1
set the velocity of a new entity to the velocity of the arrow
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
then remove the arrow
does the blockexplodeevent fire when say tnt destroys a block?
I'd bet it's more likely that it detects when a block causes an explosion - so like tnt
I haven't used it though and it doesn't specify on the docs
Yeah, i tested it and it, it gives a list of blocks tnt blew up.
Huh cool, nevermind
If I wanted to store how many times a specific player preformed an action, what would the best way to do that be?
PDC
Sorry, what does that stand for?
?pdc
Thanks
if you don't need it to be persistent, you can just use a player -> value map
a weak hash map ideally
youre weak
weakness is strength
I don't really need it to be persistent tbh, it can go poof once the server restarts
then yea, just use a map
Yeah hash maps should work well for this
Hey guys ! I have a new problem.
I'm using Gson with my Multimap that I have to turn into a Map<UUID,Collection> to paste it in json when server shut down. Then once server start up it does the reverse, json => Map=>Multimap.
The problem is that when server is online each value is added to the Multimap at the player's UUID entry, but when I restart, it doesnt recognize the UUID anymore and create a NEW UUID entry at the event. So I have a duplicate key in the Json, and once it return into a map it creates an error.
So I suspect the conversion of Json=>map=>multimap to not work, since it's impossible to have a duplicate key in a Map, right ?
It's really weird because when I have duplicate key in Json after 2nd shut down, the whole plugin gets a Error because it CANNOT creaate a map with duplicate key
so wtf
What type parameter did u pass in Collection?
Pretty sure Vector doesn't have a default TypeAdapter
hmmm no idea what is it, is this a functioning of the multimap ?
yes but I need them to be linked to users tho
ah type adapter is from Gson !
you can actually provide Gson a generated type adapter of vector
1 sec let me look up
static final Gson GSON;
static {
Gson gson = new Gson();
GSON = new GsonBuilder()
.registerTypeAdapter(Vector.class,gson.getTypeAdapter(Vector.class))
.yourConfigurations()
.create();
}
That might work (idr but it may actually scan the class and create an adapter from its scan) else you'll have to create a custom one.
Okay will try, thanks
Doesn't exist don't forget im on 1.8.8
no
then you don't get support.
eat my dust
very simple logic, we've told you this many times
don't be rude
Lmao
What to switch versions
i will be rude
do it anthony
Rack I see no about me 😮
there is no reason not to be rude
I'll
do not use sunrisenode the owner is rude and uses 1.8
Wat
i mean what
On mobile
Not a thing get
On vacation so don't got a pc with discord installed
i guess electron can't do everything after all
NNY
imagine lacking features on a specific platform despite using electron
🥲
8 is less than half of 17
👏
🤣
Math.floor(17/8d) right
Patched in v1.01.2231.32
Haha
Math.floor(13/52)
14/56*
Hmm, anyone have experience with voice servers with java?
is there a way to get the entity that caused the BlockExplodeEvent?
Basically i want to check if the tnt that caused a block to explode has a specific key in its pdc
wouldnt that be EntityExplodeEvent
that doesnt tell me what blocks it breaks tho
wtf, im blind. thanks
how would i go about always displaying a hotbar menu without using bukkit scheduler?
By using the BukkitScheduler
Only real way I think you can
By hotbar menu I presume you mean action bar
yea
so i'd just be looping this like every two ticks? player.sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
cant you define how long it stays? or is that for titles
im trying to display how many lives a person has
since im making a minigame
and not minecraft hearts
my own "lives" system
i could send you my class
if i set pdc keys on the tnt item, do they not transfer over to the entity when its placed? cause its saying theres no pdc keys now
nope
is there a way to skip a cycle in a runnable
you can't spawn the entity directly afaik
learn java
uhhh
confine = false
lol
hmmm
so how should I go about differentiating a regular tnt from a custom one?
A lazy way that I used to keep track of custom entities was using scoreboard tags
crying is a good way
a block is not an entity
you can't assign a tag to it
a tnt block is not a tile entity either, so it can't store any additional data
I thought he was talking about tnt in entity form for some reason, my bad
basically you are fucked
Yeah I’m aware I just thought of the entity immediately lol
Its been done before...
you'll need to store the data externally
which is ass
you'll need to listen to all kinds of block breaks, moves, and places
Another lazy solution specifically for tnt: use the unstable variant and check for that
ree, thats what i was trying to avoid
including withers, pistons, other explosions, players, physics, other plugins
that wont really work for what i want, cause i would have like 7 different types of custom tnt
I’m aware, I’m getting to that
Make all of your custom tnt the unstable variant, then in your events check if the tnt is unstable, then check a hashmap or something to see what type it is
That’s how I’d do it, but if you’re using different blocks for each custom tnt it will be more difficult
int counting = 0;
if(cmd.getName().equalsIgnoreCase("add1")) { counting++; }
if(cmd.getName().equalsIgnoreCase("countingtotal")) { p.sendMessage("The counting total is" + counting); }
why doesn't that code work
(i didn't copy the oncommand part etc.)

hmm, alright. thank you
use actual code blocks, three ` on each side
the number will always be zero as it's a variable and you're incrementing it only when the command is add1. Therefore, when the command is countingtotal, the number is zero
Do you have an idea how i could fix this?
What do you mean by doesn't work?
learn java
It doesn’t give an answer in chat
Im learning it
Have you registered the command?
In the plugin.yml , yess
yo so i made a class that broadcasts custom welcome messages whenever a PlayerJoinEvent occurs but the vanilla message still gets broadcasted. i put @EventHandler before the onJoin() method, but do i need to put anything else?
So long as you've (a) put a PlayerJoinEvent in the method args and (b) registered it
yeah i put PlayerJoinEvent e as a param and used .registerEvents() in the class' constructor, but it still broadcasts my custom welcome as well as the vanilla one. am i missing something to block the vanilla message like an @Override or something?
if i were to want to give a player a potion but like the potion effect itself and not the effect how would i do so?
what
ok
but
how would i actually get the potion itself but not with like the atributes
straight up had no clue this method existed. thanks g
you want the effect, not the potion item?
This changes the potion item meta
so yea what @sage swift sent is right
java -jar BuildTools.jar
Basically when I type a command it shoots a laser stopping at an entiy or block
but the problem is that it doesnt consider 1.17 blocks for some reason, it considers them as air I suppose?
anyone know another method to detect if a block is/isnt air that accounts for 1.17 blocks
did you define api-version in plugin.yml
Gizmos are rare around here
if you dont have git-bash it will download a portable version of it lol
Why does setBaby(true) when extending EntityCreature not work?
so uh, i appear to not be able to dev craftbukkit stuff
so i ran java -jar BuildTools.jar, then ./applyPatches.sh
but some minecraft classes are missing
buildtools should apply patches and everything for you?
well
if i dont run the command
src/main/java doesnt have net/minecraft stuff
im using the latest commit before 1.17
sooo
@granite stirrup ^
¯_(ツ)_/¯
welp someone knows how to build it
here is exactly what i did
git checkout <hash>
java -jar BuildTools.jar
./applyPatches.sh
nothing else
literally all you do is java -jar BuildTools.jar, you shouldnt need to fuck with anything else
buildtools builds it right
but i want to open it in intellij
like a normal person
@quaint mantle
and i also want to use srg2source to remap some stuff
yeah i have no clue, the instructions say that you can just open it in intellij, are you trying to do craftbukkit or spigot?
yeah
and it should work w/ craftbukkit
here lemme delete everyfile, re-checkout and rerun builttools
heyooo! (when ur done helping the other person xD) can someone explain to me how to change a villager type? Right now I'm trying to use setVillagerata but I am really confused how to use it :/
public class Sick_S extends EntityVillager
{
public Sick_S(Location loc)
{
super(EntityTypes.VILLAGER, ((CraftWorld) loc.getWorld()).getHandle());
this.setPosition(loc.getX(), loc.getY(), loc.getZ());
// change the villager types and profession
/*
this.(VillagerType.PLAINS, VillagerProfession.NONE, 1); // awk
this.setVillagerData(getVillagerData());
*/
// set the custom name
this.setCustomName(new ChatComponentText(ChatColor.RED + "" + ChatColor.BOLD + "Sick (S)"));
this.setCustomNameVisible(true);
}
}
would i open the root pom.xml or the pom.xml in the CraftBukkit dir
after i run buildtools
no clue but i assume crafbukkit
I need help with code design for custom currency with mysql database, so I want to cached the player's balance but want to sync the balance with the database also, how can I do that?
basically want to load onEnable/onJoin and store onDisconnect/onDisable
if you want syncs between that use stores like redis
And the players can buy the balance from a webstore too.
And I cannot think of any way, what happens when the plugin try to sync the balance and at the same time the player buy something from the in-game shop.
Alright, so I have to use redis?
yeah no
just running BuildTools, none of the imports work
hmm, I got no clue. sorry
you have pom in the root? cause i dont
i git it in CraftBukkit
i was running buildtools in a already pulled craftbukkit like an idiot
but still
opening CraftBukkit/pom.xml doesnt work
oh, wait a sec
is your artifactId spigot-api
oh mb
actually i just want to map craftbukkit into mcp
i think you need to use buildtools with extra parameters to install the dependencies
either way i need to source to be able to be built because yay Srg2Source
i have got all the deps libs, its just some of the decompiled mc files are not copied over
can you copy them over?
is this minecraft code or craftbukkit? minecraft code is fucked in general usually
I've never seen a plugin use redis before, although I might actually use it in one :P
decompiling minecrafts code back to runnable code is a real pain in the ass
I tried it, and theres so many damn errors from the decompiler
Forge's fernflower works
i tried it also, same problem
I wanted to decompile the code and get a runnable client so i could modify the client without any frameworks, but that died sadly cause i cant figure out how
like, i tried so many decompilers, and shit, and nothing worked correctly /s
argh
srg2source wont work with broken mc
and i cant just use mapping mc jar
because yes
actually because patches
then classes wont exist
then i die
:(
how tf does md5 recompile the files tho
I'll try again just for the hell of it /s
He doesnt decompile it back to a runnable client/server afaik
then how
i guess ill have to use my janky source remapping tool
that doesnt care about the context of the file
yay for static analysis
ok extremely beginner question but
what are the biggest changes in the spigot api between 1.16.5 andd 1.17? i want to port my plugin as soon as possible but after seeing everyone else having a lot of difficulties i feel i need to ask
Redis is very good for plugins. And what version are you trying to decompile?
1.16.5/1.17
There are mappings btw to remap the code
yeah, ive done that
the problem is decompiling breaks the code
and yeah, I'm gonna try redis out, just had a situation were ill need it
https://www.spigotmc.org/resources/mcdeob.77792/ see what this does I’ve never tried it. And really there’s decompiler errors?
I tried that program, still generated broken code
Can I call method inside the method itself?
public void someMethod(){
if(something happens){
someMethod();
}
}
yes it is called recursion
I open the code in intellij and theres tons of bs casts and other broken shit
alright thanks, never knew that
Ah there probably is a fair amount of fixing needed
I tried fixing the problems but theres just so many. theres also a few i dont even know how to fix
You just don’t want to be creating an infinite loop lol so use it smartly
Yeah, I'll make sure it won't cause infinite loop.
I'm basically creating a shop that choose random items by chance, and I don't want the shop to be empty.
guys, is there a rule whereby you shouldn't be running any ides or editors with code that depends on spigot when running buildtools
not that i know of
How would you guys go about to make a square zone. I'm able to do a circle but not sure how I could do a square
zone?
search recursion on google
why?
oh that didn't happen to me lmao
no pvp zone
create 3 for loops, all nested in eachother, the top x, the next y, then the last z (though order really doesnt matter), then make the min the player's location - 1/2 radius, the max the players location + 1/2 radius
also in some programming languages recursion is actually worse than looping XD
f
did you know in some programming languages recursion is actually worse than looping XD
no way
dun mind my font
i think so
thats actually hilarious
its recursion
how is recursion worse than infinite loop
I bet those methods are like exponential space complexity
prob what they meant
i didnt say that i said some languages its worse
some how looping in same langs are better
yea but how are they worse in any langugage lol
than recursion
they just are in some langs
probs
it says this
but in some langs its actually faster
but most of the time it isnt
maybe I had a different understanding of the word recursion, as in recursion just means calling itself, cuz if you have
method(int i){
return method(i-1);
}
then it is a recursion that is pretty iterative.
¯_(ツ)_/¯
by 1/2 do you mean radius / 2?
well no im just retarded
it would be 1/2 diameter, but you should be using radius
ill give an example
lmao
why is iterating y then x better than iterating x then y?
cuz thats what i heard some where
method List<Block> squareRadius(Location loc, int radius) {
val blocks = new list of Block
val bx = loc.getX();
val by = loc.getY();
val bz = loc.getZ();
for (int x = bx - radius; x <= bx + radius; x++) {
for (int y = by - radius; y <= by + radius; y++) {
for (int z = ...) {
blocks.add(loc.getWorld().getBlockAt(x, y, z));
}
}
}
}
its like that
just with actual code and not something i wrote in a java/kotlin/pseudo blend
its not
wherever u heard that from is an idiot
bool == true ? bool : !bool
thats always true
scam
scam scam scam
had to take a second to parse that in my head xd
@proud basin looks like this
is Location loc representing the spawn location?
its the center location
so like player.getLocation() if you want it around the player
oh i think it was something to draw to screen like a image or something so maybe thats why they needed to use y then x cuz it wouldnt be correct if it wasnt
Ima have to change this a bit doing it in a event
you dont need to change it at all
¯_(ツ)_/¯
just declare that as a static method in a utility class
or a private method in your event class
well I used val since I'm currently coding kotlin for my project
but its also a thing in like java 11
or smth
its just a regular variable
ah ok
in kotlin its a final variable but same difference
i dont know i swear i heard someone say that iterating y then x has more performance than iterating x then y Idk where i heard it from just from utube idk
that makes no sense
they are both int's
y and x and just int's to the computer
it has no affect
The only way that would possible have a difference in performance is if you were accessing blocks and iterating X first may cause a chunk load. However no matter what is first at some point the chunk is going to load.
how do you make a plugin compatible for multiple versions
delete api-version in plugin yml?
using nms or not?
api-version: 1.13
@compact haven why didn't you just do ```java
public void UrMomIsSad(Location loc, int radius) {
List<Block> squareRadius = new ArrayList<>();
final double bx = loc.getX();
final double by = loc.getY();
final double bz = loc.getZ();
for (int x = (int) (bx - radius); x <= bx + radius; x++) {
for (int y = (int) (by - radius); y <= by + radius; y++) {
for (int z = (int) (bz - radius); z <= bz + radius; z++) {
squareRadius.add(loc.getWorld().getBlockAt(x, y, z));
}
}
}
}
nice method name lmfao
Thank you
use getBlockX() instead of getX()
use camelCase for method names
:)
and the same for the other 2
and discard the casting
and the reason I didnt is because
- im lazy
- u can do it urself
I gave u enough of a hint with the pseudo code xd
I believe getBlockAt requires integers
getBlockX returns an int
use getBlockX
and make the type int instead of double
Yea
then discard the casting in the for loops
I saw that
no thank you ❤️
How exactly should I go about determining the type of TNT? That's kind of the main thing im not sure how to do. I am going to use the same block (TNT) also. I was testing using locations but that didnt work because if a play launches the tnt, the location would be incorrect.
camelCase is best
UrMomIsSad is best
jtxPleaseUseCamelCase
NoSir
whyJtxWhy
BecauseUrMomIsSad
fuckYou
I need a test dummy
for what
idkidk volunteers as tribute
to test square
no
why can't i get buildtools on one drive?
because
it isnt supported
idk
just drag it into one drive when your done
then how do i do it on windoes
wtf do you want it on onedrive?
so do you volunteer idkidk123123
no
aw well your lost
thanks
wait hold up what was the point of the method @compact haven
uh, not at all close to what i meant to do, but sure
lmao
So then all I gotta do is ```java
if (squareRadius.contains(radius)) {
e.setCancelled(true);
}
¯_(ツ)_/¯
oh wait
What exactly are you trying to do?
then use a BoundingBox
What's that?
declaration: package: org.bukkit.util, class: BoundingBox
create a BoundingBox from the location of two corners that cover the area
If you need to test a location is inside teh area you simply use box.contains(Location.toVector())
api-version was added in 1.13, its not recognized in any version below 1.13
if you run a 1.13-1.16 server and set the api-version to 1.17, the plugin will only run on 1.17 servers
can i still use it on 1.12
should
yea ik
api-version was introduced in 1.13, it wouldn't make a difference
okay nice
you can set it to 1.17 and still use it on anything below 1.13 afaik
yeah
okay
yes
Is this even available to 1.8.8?
no
well that doesn't help
api-version means nothing to versions under 1.13
im not talking about that
oh
Talking about BoundingBox
what are you talking auot
If you are on 1.8 implement your own BoundingBox. Its not hard and there are plenty of examples out there.
there we go, took a few tried 😂
what is that
XD
@quaint mantle someone on here said to me i cant use add on a list?
yes you can..
are they talking about like String[], or List<String>?
I'm 19, I like cats and technology, especially coding, Server Administration and robotics. I also have 7 Microsoft MTA Certifications
I use ubuntu btw```
idk
congrats, you can copy and paste
i used that all the time
whoever told you that is full of shit
yeah lol
List<String> isn't an String list, it's an array of Strings
you can't even add an additional string to a string list though
what are they on
Yes you can, unless you created an immutable List
should I Do spawnLoc.getBlock().getLocation() or spawnLoc.getBlock()
location
then getLocation
spawnLoc IS a Location
im starting to use
List<Object> something = new ArrayList<Object>();
since someone said to use that
this shit doesn't work
@EventHandler
public void onEntityDamage(EntityDamageEvent e) {
List<Block> squareRadius = new ArrayList<>();
int radius = 30;
Location spawnLoc = new Location(Bukkit.getWorld("world"), 118.500, 86, -108.322);
//Location loc = e.getEntity().getLocation();
final int bx = spawnLoc.getBlockX();
final int by = spawnLoc.getBlockY();
final int bz = spawnLoc.getBlockZ();
for (int x = (bx - radius); x <= bx + radius; x++) {
for (int y = (by - radius); y <= by + radius; y++) {
for (int z = (bz - radius); z <= bz + radius; z++) {
squareRadius.add(spawnLoc.getWorld().getBlockAt(x,y,z));
}
}
}
if (squareRadius.contains(spawnLoc.getBlock())) {
e.setCancelled(true);
}
}
yeah someone said its better practice than doing
ArrayList<Object> something = new ArrayList<Object>();
There is no point in building a list of blocks
Why not
That's what I use anyways wrong message, the other one
all you want to know is if a location is inside an area. you literally need to compare x,y,z
no loops nothing
trying to prevent pvp within an area?
yea''
i think someone named Charlie said that its better to use
List<Object> something = new ArrayList<Object>();
one sec I'll write you a method
bruh they said to use List<String> and not ArrayList<String>
😂
I don't know though, it seems counter-productive to make an Object list when you are going to only store strings in it
yeah i know i said i use it now
true, that's better. List<Object> something = new ArrayList<>();
also this is the guy who said this
but hes saying not use .add on a list?
and idk why
but that was ages ago
i know but i used Object list as a example
i made two custom events :)
private boolean cancelPVP(Location area, int radius, Location target) {
if (!area.getWorld().equals(target.getWorld())) return false;
int areaXMin = area.getBlockX() - radius;
int areaXMax = area.getBlockX() + radius;
int areaYMin = area.getBlockY() - radius;
int areaYMax = area.getBlockY() + radius;
int areaZMin = area.getBlockZ() - radius;
int areaZMax = area.getBlockZ() + radius;
if (target.getBlockX() < areaXMin || target.getBlockX() > areaXMax) return false;
if (target.getBlockY() < areaYMin || target.getBlockY() > areaYMax) return false;
if (target.getBlockZ() < areaZMin || target.getBlockZ() > areaZMax) return false;
return true;
}```
that’s all i had to check for…
yes
😠
in yoru listener you use java if (cancelPVP(spawnLoc, radius, event.getEntity().getLocation())) event.setCancelled(true);
?
I think they meant arrays not list?
Falling block entities don’t support that kind of meta I believe
Switch around spawnloc with event.getEntity().getLocation()
jesus
christ
I just noticed my map isn't squared
Nope, what I sent should be correct
Am getting this error when using ChatPaginator in spigot 1.17: https://hastebin.com/wuvebaguqu.properties
that's not spigot
that isnt spigot XD
hello can i get some help?
?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.
?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.
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.culleystudios.provotes.ProVotes
whats this mean?
did you put the right main class in plugin.yml
it means your plugin is set to use a main class that doesnt exist
its a premium plugin i purchased
you got scammed then
the author isnt helping
;-;
then ask the author
I mean you're not running spigot
lol its cuz ur trying to divide by 0
try and catch the java.lang.ArithmeticException so it doesnt happen again
why not
don't divide by zero
don't suppress and silence the error, fix it instead
was gonna say
aha
also ChatPaginator isnt my code...
so isnt really much I can do until paper sorts it out
ik, and you're passing 0 as pageheight
¯_(ツ)_/¯
am looking into that as a possibilty rn
think thats whats happening
wait
yeah
how the hell did my pageheight go bye bye
yeah this was the error, realised that just before u said it aha
cheers
👏
is there a kill() method in Player.class or not i cant find it in the spigot library
Player#setHealth(0.0D)
actually, it's Damageable#setHealth(0.0D) 😉
has any1 made a skyblock plugin that willing help me make 1 ? dm me
ohh sorry
Guys, is this the answer? Storing data in a block.
https://www.spigotmc.org/threads/custom-block-data-store-any-information-in-blocks-without-databases-or-files.512422/
I'm having some trouble with mainly java but spigot related
I save my config in the main class file as per the wiki guide
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yes
But how do I access the config in another class?
Make an instance of ur main class
I'm allowed to do that?
Public static MainClass instance;
Yes
instance = this; in on Enable
U then call MainClass.instance.getConfig
sorry, a little confused
where does this go?
public class App extends JavaPlugin {
change this you mean?
probably not I'm just misunderstanding
Under that line
Dependency injection
?
Create constructor that passes the main class instance
in the other file
App myConfig = new App();
myConfig.getConfig().getInt("teleport_distance")
does this work?
I directly call the main class instance
So MainClass.instance.getConfif
If u get better at java u can also use this
thanks
how do i prevet invalid plugin errors like this [06:13:56 ERROR]: Could not load 'plugins/SolarUtils-0.3.3b1.jar' in folder 'plugins'> org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:141) ~[server.jar:git-Paper-414] at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:397) ~[server.jar:git-Paper-414] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:305) ~[server.jar:git-Paper-414] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[server.jar:git-Paper-414] at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:206) ~[server.jar:git-Paper-414] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:935) ~[server.jar:git-Paper-414] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:173) ~[server.jar:git-Paper-414] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212] Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) ~[?:1.8.0_212] at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_212] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:79) ~[server.jar:git-Paper-414] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:137) ~[server.jar:git-Paper-414] ... 7 more Caused by: java.lang.NullPointerException at the.suncorp.solarutils.SolarUtils.<clinit>(SolarUtils.java:46) ~[?:?] at java.lang.Class.forName0(Native Method) ~[?:1.8.0_212] at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_212] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:79) ~[server.jar:git-Paper-414] at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:137) ~[server.jar:git-Paper-414] ... 7 more
fix the error?
SolarUtils.java:46 null error
instance is null
how to fix Some problems were encountered while building the effective model for org.gstudiosx:MyPlugin:jar:1.0 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 105, column 21 It is highly recommended to fix these problems because they threaten the stability of your build. For this reason, future Maven versions might no longer support building such malformed projects.
try refreshing maven workspace thingy
oh wait i think its cuz i didnt specify a version
cuz i did xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>8</source> <target>8</target> <encoding>UTF-8</encoding> </configuration> </plugin> and now it works but weird that it didnt need it before ?
how do i make something like loginsec's PlayerProfile class? basically i want to store a bunch of data relating to the player that i access from somewhere and then store it to a json when the player logs out
how much data are you needing per player?
not sure yet, but as of rn its just baic things like if the player is allowed to fly andd if illegals shd despawn
then use the PDC and it stores on the player object. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataContainer.html
and their usernames and stuff
how do i store it to a player though
its not mentioned anywhere in the docs
If you didn’t know
handy
tho if you want your plugin to support versions under 1.14 you shouldnt use it since it doesnt work on versions under 1.14 i think
im planning on porting it to 1.17 anyway, i doubt any of my users will be on 1,14
wait just to clarify; persistent means that it stores the data even after the player goes offline right
so i do not need to store in json or yaml or sql or whatever
yes, you can only access it when they are online though
it gets saved whenever the player data is saved.
well crap, guess i will still need to mess with storing it to a file
i need some data to still be accessible afetr the player goes offline
You need it when offline?
yeah, im making a /login cmd
and i need to store the player's logout spot so i can teleport them there
and a /userinfo cmd that returns the logout spot
idfk
may not actually implement them
I mean you could probs just use yaml for that
true lol
It sounds like the only part of that which would need access offline would be if you wanted to check their set location
all players have a pdc by default right?
yes
so i can call PersistentDataContainer pdc = p.getPersistentDataContainer(); without it returning null
oh
yes
quick question: would this code work?
public static void createDatabase() {
try{
PreparedStatement query = Connector.con.prepareStatement("CREATE DATABASE IF NOT EXISTS coins");
PreparedStatement database = Connector.con.prepareStatement("SHOW DATABASES LIKE LIBRARY3");
if(database.getResultSet().wasNull()) {
query.executeUpdate();
}
}catch (SQLException e) {
}
}
quick question: why don't you try?
because i am dumb lol
gimme a min
nop it does not work
ima let the user do some work too
Use code blocks for our sanity plz
Die
😦
just three back ticks like
```java
[Paste code here]
```
?paste
or that ^^
can someone help me I made a lock command that saves uuid and location inside a hashmap, but for some reason it isnt working
https://paste.md-5.net/inusiferod.cs
when i interact with something "this works" shows up
Just add more sysouts to test what isn’t working
Also, are you locking entire chunks?
no i'm just saving the lock in the pdc of the chunk
Hmm, ok
That seems like a bad way to go about it. I would recommend something like redlibs persistent block data but it’s up to you
Pdc could work
That only allows you to lock if it is ALL of the following, TileState, Openable and lockable
its ||
You are also only allowing ONE lock per chunk due to your NamespacedKeys
yes it's ||, if it doesn;t satisfy all of those tests it returns
if any one of those three fails it returns
so if its not a tilestate or not lockable or not openeable it returns
ah if i would put a ! before it it would work
a gate would pass as its openable but it would fail both the first two tests
no
I'm 100% certain I already gave you working code for this a month back.
It looks like you broke everything in it 😦
Lol
im trying another way
That first quick return is wrong, Your code only allows one lock in the whole chunk by a single player.
which one do you mean?
You are calling blockState.update() for some unkown reason
This line java private final NamespacedKey keyOwner = new NamespacedKey(Main.getInstance(), "Owner");Will be identical no matter what player it is
and as thats your key in the PDC its only ever going to allow a single entry in the PDC.
is it better to have everything static or everything non-static
imo non-static, but it is needed sometimes
lastly, once a single lock has been placed, anyone with perms can remove that lock or set a new lock on anything in the chunk
i only use static in utility classes
welp time to unstatic everything
oh idk never used it 🤔
how do i fix it then?
look at the code I sent you originally (a month ago)
that line is in it
/**
* Is this Block a type we want to lock.
*
* @param state
* @return
*/
private boolean canLock(BlockState state) {
return (state instanceof TileState || state instanceof Lockable || state.getBlockData() instanceof Openable);
}```
Use ```java
if (!canLock(blockState)) return;```
(byte)0 or 1
w
lock part works
Now test it and you'll find anyoen can remove teh lock
only something stupid i did
it says locked and immediatly you cannot open it
your locks will be overwritten
so i've to make a list or something that stores the locks?
Thats exactly what he's doing
?paste
Thats the demo I wrote him https://paste.md-5.net/ajifavosel.java
but why can there only be one lock in the chunk?
Because thats how you wrote it
your key is the same no matter who places your lock and you have nothing indicating the location
I like his use of the TAG_CONTAINER
owh yea i forgot to change that i used it before it saved the owner on the block itself and there could be only one lock
what should i put there then?
the players uuid?
You really need to read the original code I gave you, and understand it. It does all that. You literally just need to copy the sections you want.
and why working with locations?
what do you mean?
String s = block.getX() + "/" + block.getY() + "/" + block.getZ();
NamespacedKey key = new NamespacedKey(MagmaBuildNetwork.getPlugin(), s);
so the key corresponds to the block location
and are you using that location any further?
yes, read the code. you use it to check if there is a lock on that block
well i was using this but i have to modify it so it checks for the location
if (container.has(keyOwner, PersistentDataType.STRING) && CommandHandler.getPlayersWantingLock()
.contains(p.getUniqueId())) {
p.sendMessage(ChatColor.RED + "This block is already locked!");
What does everyone in here prefer?
Java 16.0
Java 1.8
?
For spigot development now, still java 8
8
That will not work because you are using teh exact same key every time. So ANY lock in a chunk satisfies that
Isn't 16.0 better though is my thought process xd
java 16 is required for MC 1.17
So getting used to it is a good idea
yes
It is better, but for plugin development Java 8 still the best.
Compability
so i have to check if the location is the same as the one saved in the key and then fix the key will be different for each player?
the key shoudl be different for every block
uh yes
Your plugin won't work in minecraft server below 1.17 If you're using Java 16.
Plugin java 16, but your server is java 8, then it won't work.
If the server is java 16, but you're compiling plugin in java 8, it should work.
Sorry, I mean if the plugin is java 16 and the server still java 8, the plugin won't work.
im completely stucked now
What are you trying to do
Yes a plugin written in 16 will work on 8, IF you set the compatibility to be 8
wdym "set the compatibilty to be 8"
i have this now https://paste.md-5.net/kanavinayi.java
Pure java question : is the form builder of intellij bugged ? or work everytime ? i'm trying to show a jlist with element but don't work
How do you get the player in a jump event... ?
there is not player jump event
lol
e.getPlayer();
you have to determine your self with getfrom and getTo on playerMoveEvent
Or this. Check for jump statistic. https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerStatisticIncrementEvent.html
There is, but that is from paper
ohh
i'll be glade to know what is the name of the event your talking
+1
will it work though: " This event is not called for some high frequency statistics, e.g. movement based statistics."
can u change from spigot to paper after making the project
without changing 100 dependencies
yep you can
But there is Jump statistic.
and how do you propose is the best way
ooh,I misspelled it in ctrl+f 🤣
well it only says how to make a paper plugin not how to change to damnit
Just change the dependency from spigot-api to the paper api, you can google the repo
yeah found it ty
oh it cant find it graet
f you intellij
out of magic it works ok
@eternal oxide is this better? https://paste.md-5.net/zenewatiyi.java
🤣
how does everyone in here do colors
i feel like doing ChatColor.translateAlternateColorcodes gets a bit too long
i have that method in an utils class
and every time i need it i just do Utils.color("")
Does anyone know why setBaby(true) does not work when extending EntityCreature? (NMS)
make it with NBTTagCompounds
Alr
or cast it to Bukkit entity
Yep, exactly
Can I use NBTAPI?
why cant i use ChatColor.translate... in my utils dafuq
i did this
public static String color(String args) {
return ChatColor.translateAlternateColorCodes('&', args);
}
of course
exactly what i tried to do
it doesnt recognize the chatcolor function
very useful api
import org.bukkit.ChatColor; ?
i did
smh
whats even the difference of those
it still wont let me use it
and support 1.16+ HEX
lol
and whenever i did ChatColor.
it referenced to the class
@quaint mantle The key's "isBaby" right
.setByte("IsBaby", (byte)1)
IsBaby with upper I
Lol
and nbt-api is more comfortable to use for me
Do you just do (Entity) this to cast to Entity from EntityCreature
Yeah
I'm new to NMS
what are you trying to do at first?
Create a NBTEntity
you can use simply bukkit entity + NBT-API instead NMS EntityCreature
Lmfao
Is there any way to convert it to a bukkit entity
So EntityCreature -> org.bukkit.entity.Entity
Convert with UUID?
lmao. You needn't use nbt-api/nms for set baby-size:
https://imgur.com/1JwLvvN
but you need already convert it
get entity with uuid?
yes
Yes
are you using maven?
yeah
reload maven
if you upload it in dependecies
No Bukkit has a method for getting entity with uuid
i added to libraries
wtf dude
put this in your pom.xml
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
use pom.xml
and this
<!--Vault API-->
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
and reload 🙂
you shouldn't import any thing in libraries if it isn't your api or spigot/paper core.
ty
ok ill take note of that
my bad
public void onJump(PlayerJumpEvent event){
Player player = event.getPlayer();
//Random prize between 0 and 90.000
int prizeWinnings = new Random().nextInt(90_000);
// Title
String main = ChatColor.color("&7[ &cPRIZE&7: " + prizeWinnings + " &7]"); //Main title
String second = ChatColor.color("&7Congratulations, you won " + prizeWinnings + "$"); //Subtitle
player.sendTitle(main, second, 10, 40, 10); //Outputting title to player
//
plugin.eco.depositPlayer(player, prizeWinnings);
plugin.eco.depositPlayer(player, 20.0);
}
Any improvements here to be made?
it is more comfortable
wtf is that?
what is 90_000?
bruh i fcked up my chunks