#help-development
1 messages · Page 1779 of 1
Hi, I'm trying to be able to walk inside end portals without being teleported, I tried cancelling the event:
public void onPlayerTeleport(PlayerTeleportEvent event){
if(event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)){
event.setCancelled(true);
}
}```
this works only if I'm in the normal world, if im in the end and I enter the end portal, I get stuck in the typical "loading terrain" screen
ohhh nvm
its just meant to look weird but its normal
package private String test
static initializer, when called: println "testing"
setters
static String myString = "a"; //dont warn here
myString = "b"; //warn that the string was changed to b
setters
setMyString
nvm, just got a better idea
setters
setters
A friendly reminder that static shouldnt have any mutable state 🌞
anyone?
Pretty sure the other one fires PlayerRespawnEvent Sapu
use PlayerMoveEvent#setTo instead of cancelling it
Heheh jdk yikes
Its name is the static init block
There's an equivalent init block for instances too. Same thing, just without the static modifier. Will call for any new instance
sysout
choco why do u speak british
hey hey, so im really not sure anymore at this point
basically, i have a HoverEvent for SHOW_TEXT on the usernameColored component, right
but nothing else
that is the only component that should have the event
however, every component after that, has the SHOW_TEXT on it
and i dont know why
This is the part of the code for one of the plugins from my server. whenever I try to execute /rank player rank it says that this.PlayerHandler is null. can someone help?
you have to download the txt file to see it all
wtf
yeah cursed
This guy XD
also i think switch would be better for the command part
Bukkit.broadcastMessage("test");
}
``` anyone know why when i killed the entity it doesnt broadcast it...
PlayerPortalEvent
Yeah u are on a tp event, not a portal xd
well his thoughts wasn't wrong
Well, but the event
he wanted to cancel player teleportation if it's caused by end portal
he just didn't know the event
That's what i said xd
he still can use the tp event
Well, it's more simple using the portal event
if he sets the teleport to a diff place
I guess that he wont xd?
Hi, how can i extend ItemStack lore? This code do not work ;<
ye, but i use setLore() so new lore should be set
Look at what you call addAll on
ahh, ok my mistake
Also, this???
i make class that extends itemstack
Pls tell me those are convenience methods and you didnt extend Item….
wasted
Not the worst, but also not the best
i need extend Itemstack for Inventory GUI
Extending classes isn’t stable api and you won’t ever be able to cast the result of getItem back to your item
You probably dont
maybe not but using pure ItemStack as InventryButton would make big mess in code
why so
for example now i can add property OnClick to each InventoryButton instance
You can do that without extending
what
Yuh, most of the time you actually get your hands on a CraftItemStack when you query stuff
OnInventoryClick event return the Id of clicked slot and thats enough for me
I had a class extending itemstack but it's a bad idea and it turned out useless
Then you don’t need extend
Wrap not extend
I Just made a wrapper class with an itemstack as a constructor parameter
ok that make sense
same thing, I get stuck in loading terrain
This is probably a dumb question, but how do you use meta? I have never needed to use it before.
Most permission plugins support it, and some plugins use it for things such as chat-colour or homeset-amounts, etc.
Thanks
How can you calculate a player's last location?
What do you mean last
like their last x
I'm trying to calculate a players x distance
and to do that i'd need their last location
move event's getfrom() and getto()?
Just to clarify, api-version: 1.17 will prevent the plugin from being used on a 1.16 server right?
yes
Thank you
someone know how to modify the Minecraft Chunk Section palette?
ok
Without crashing the client, you shouldn't. What do you want to accomplish?
Why was isOnGround deprecated?
Check the javadocs?
reading is for chumps
ah
I only accept answers in youtube video explanations
nah md you like reading articles
potato chips?!?!? no!!!!!
Coll is talking about french fries since he's from the UK
Sorry to ask but do anyone know .. how someone will be able to detect User Mouse Click vs PC mouse click
and is it possible somehow? in C++
Note: I'm only a java guy but thinking about going over to c++ for software
Only thing I can guess is a npc click maybe
I don't think this is related to mc at all
changing for example minecraft:stone to minecraft:dirt
someone?
is there any event used to launch players into the air, kind of a like a double jump? i tried playertoggleflightevent, which didnt work
you could probably mess with the players vel
i tried
Hi there, I have one noob question, but I can't find any solution for it. What is the easiest way to completely remove an enchantment?
how did you do it?
You can use that
I have implemented double jumps like that
You have to make sure to call setAllowFlight(true) on the player so they can fly
And set their flight speed to 0 so they can't abuse it
Then when they toggle flight you cancel it and set their velocity
Well yeah but you still need some kind of input to determine when to set their velocity
I thought that was the point of the PlayerToggleFlightEvent for this
Idk that just seems like a security red flag to me
oh shit
alright
Well it's the most common way to implement a double jump and it seems to be what they're trying to do
Not every project is intended to be put on a large server
Yes you can set their velocity with setVelocity
But again, if you're trying to implement a double jump, you need some way to activate it
yay so existed to understand packets ugh
this doesnt work
the event just gets cancelled by the looks of it
i were thinking then i tried to do it in java there was
java Click Event
from mouse input
i used Java Robot Click then
it made infinity loop D:
trigger from Event
ok so what the fuck?
because someone told me to .append everything
so please explain, what other method can i use
What do you mean
idk tbh :/ maybe u have to send in different message
ok no anyone else have an answer?
anyone else have an answer that is coherent and makes sense?
i'm calling spigot().respawn(); on a player on PlayerDeath event, but the dead player picks up the items dropped in the location they died, resulting in a keep-inventory like behavior
Clear drops first and respawn after
event.getDrops().clear;
thanks
anyone know how I can check if a player is spriting with packets?
Surly there must be some sort of flag?
There must be some sort of incoming packet to tell the server
why?
curious
to know if they are sprinting?
Are there not api methods for checking that?
yes player.isSprinting()
because
Why are you messing with packets for that
api bad
That’s.. a bad take but okay
nah
yah
currently im doing prediction
I mean Bukkit's API definitely ain't perfect but you should still use it, probably :p
I’m just struggling to think of a good reason to work with packets for actions that are already wrapped by the api
would you say fly ticks and air ticks are the same?
friends pls
aren't air ticks indicator of how much air do you have under water, or is it something different?
How much air the entity has, in ticks. Fills to a maximum of 300 in air, giving 15 seconds submerged before the entity starts to drown, and a total of up to 35 seconds before the entity dies (if it has 20 health). Decreases while underwater. If 0 while underwater, the entity loses 1 health per second.
?
If you're looking for a api solution, you'd have to ensure that enchanting tables can't give it as well as all loot table sources
Hmm, but there are still loot chests, random drops, ... I know there is a solution for each case, but I am asking if there is something easier as just removing it from some register
you could alter the loot table itself or hook in to LootGenerateEvent
it's a private plugin, so I don't have problems with using nms if it would simplify the code alot
some people just don't learn basic java lol
LOL
ya'll please, someone helpm e.
Idk
Try ComponentSerializer.serialize or whatever and see what the json looks like
I don't see any show text in your example though
finally
in one if that appends he have usernameColored variable, that should be a component with the event from what he said
might be a yucky solution, but maybe appending an empty hover event after that would clear that out?
i'll try these out
didnt work
try again
what
.
like this?
hacky solution should be last resort
try inserting the setHoverEvent after append insted of using it for each component after it, because it maybe gets overwritten
im doing what md told me to do, noted tho
How good would you guys rate my movement prediction? ```
lastDeltaXZ * 0.91F + (profile.getPlayer().isSprinting() ? 0.026 : 0.02)
boom @sullen marlin
🔼
Any way to suggest to fix it because I'm getting some falses in it?
specially when walking
targetSelector.a(0, new PathfinderGoalNearestAttackableTarget<EntityHuman>(this, EntityHuman.class, true));
the pig doesn't walk towards me
well I know sprinting is faster
but this is how im checking difference > 1e-12
and it falses when I walk and sometimes when sprinting
@quaint mantle the issue is .reset operates on the component before it. Consider using the append(..., FormatRetention.NONE)
oh
will try👀
use integer division;
int modulus = a % b;
int result = a / b;
make sure both a and b are ints
actually idk if thats required
other way around
ok 54 % 9
that will return the remainder
you will need 54 / 9 to get how many times 9 fits in 54
but reminder is 0
yeah
working on inventory
anyway i'm curious what would you do if it is a constant value
int modulus = 54 % 9;
int result = 54 / 9;
is that right?
54 / 9 = 6 times
ok i figured that out
no worry i got it :))
public static int getOptimalSize(final int spaces) {
return (int) Math.ceil(((double) spaces) / 9) * 9;
}```
oh Thank you i will use that too
nope, if your first value is an int it will cast all others to int too
I just tested it and you are correct
So both will work
This is a formula we ended up with after a long discussion in here over teh best way to calculate it
There may be some other reasons to cast the first to a double I'm unaware of
optimization possibly
Is there a player property that could help me tell if a player is an admin or not?
admin or op?
Uhh op*
Sorry- and thank you
Is it better to have multiple small plugins or one plugin with lots of code
Small plugins will be easier to maintain
Performance wise the difference is negligible
Thank u
Is there a java program I can use to unzip a server texture pack?
do you mean decompile?
I meant to say texture pack sorry
7-zip
It says its corrupted
then its corrupt
use java to unzip it
But it works in game
I dont know how
link it in here
you in #help-development so
lots of stackoverflow posts of extracting a zip in java
not a zip file
I made it a zip but it didnt work so i set it back
linux unzip command extracts that just fine
I dont have linux
I take that back, everything is empty
try winrar or something then
but what are you trying to do anyway
seems like youre pirating another server's resource pack
I mean his name is "AidanTheBandit" after all
I wanted to run it outside of the server
Is that not allowed?
did the server give you permission?
No. The server is Mineclub
also if you just wanted to run it outside the server you could just load it anyway
you wouldnt need to unzip it for that
Oh ok
if I run ((Creeper) entity).ignite(); when it already ignited, does it reset the ignition?
its part of the client so idk
hmmm do you have link for it?
copy pasted... ok
hmmm so i have to fork minecraft vanilla by shading its own jar
👌
oh btw deobfuscation is done before decompile if a jar is deobfuscated?
you know there is an easier way right...
Contact mojang and asked them for the github repo
Lol
I'm actually curious what they would respond with
i think they will just end up give me a long message talking about how they were made in 2009, then in the end they will just say no and block me

hmmm???
wtf?
what?
used to be :gay_pride_flag:
you can still use that alias tho
it just shows up as rainbow_flag now
I mean :shit: is an alias for 💩 as well
:hankey:
🤔
hey the FormatRetention.NONE didnt do anything
acutally idek wjhat it does tbh
Basically I have a reputation plugin and players can only give 3 reputation, and after that it will start a countdown 24 hours till player can give 3 reputation again, How can I accomplish countdown timer and format it like 2h 15m? And I saved the LocalDateTime when player ran out of reputation usage.
Here's how I saved the LocalDateTime reputationRunOut: 21-11-2021 00:01:44, and I need to check If that time has passed 24 hours (which I already know) and I want to know the remaining time until it pass 24 hours too.
ok
big question
when should i save my config?
obviously not every time i change it
On disable
what if the server stops sudenly
or the plugin is restarted wrongly?
I generally do a weird system where if I do a ton of changes, I only save once all those changes are done
async ofc
and on disable?
Once every 5 minutes might be unreliable
y?
like if changes have ocurred
If you're using a .yml file for a database I'd suggest you stay away from that
say im not using yml file for a database
say im using json
then should i save every 5 mins?
If you don't need something human readable make a proprietary extension and save often
Or just use an SQL database
i dont wanna get into sql lol
i know it wont be hard
and i probably should
but until i need it
im not gonna
you'll use it eventually
If you scale up, json is very bad
ye
but i havent done any big projects yet
SQLite is quite easy
It's not about the size of the project
It's about the amount of data it needs to handle
Pair it with MongoDB and you'll be pretty good
Saving a JSON file means you have to write all of the data every time even if only a single value changed
SQL on the other hand
It's built to scale for handling truly mind-boggling amounts of data
oki
For a public plugin, ideally, you'd add like 25 different ways of storing data
and a way to convert between database storage
I personally think MongoDB, SQLite and MySQL are solid choices that cover 99% of servers
So a loading from 1, saving into 2 type thing
I'm trying to do a custom AreaEffectCloud. I took a look at the documentation and I'm wondering if anyone has better Googlefu than me, but the interface is pretty confusing.
i messed with particles once
uhhh
leme find it
AreaEffectCloud effect = world.spawn(location, AreaEffectCloud.class);
or just packets
¯_(ツ)_/¯
block.getWorld().spawnParticle(Particle.WATER_SPLASH, block.getX() + random.nextDouble(), block.getY() + random.nextDouble(), block.getZ() + random.nextDouble(), 1);
@dense shoal
that's completely different lmao
The more you work with spigot, the less you work with spigot
Bit odd but that's how it works
Believe me, my dev environment has a base library of a couple hundred classes with spigot stuff in it.
My dev env is like
basic utilities (simple async file loading, simple menu stuff)
then 200 classes that have nothing to do with spigot
Does anyone know how to get remaining time until LocalDateTime pass 24 hours?
store the long and its simple math
24*60*60 - getEpoch % 24*60*60
LocalTime#getLong has a parameter of TemporalField, idk what to put there.
Circling back to area effect clouds for a second, do I have control over the density of the particles?
working with LocalTime https://zetcode.com/java/localtime/
Doesn't seem like it
Install a plugin that does it
I'm listening for PotionSplashEvent and it's not firing when I throw a splash health. Are there any common reasons why this event might not fire?
Listener is registered
OK, so it seems it's only firing if I throw the potion directly on the ground
are you using a splash potion or a lingering potion?
Splash
Lingering would be like......uhh, I think just checking EntityDamageByEntityEvent and seeing if the damager is an instance of an AreaEffectCloud
no, there is a lingering potion event
Am I doing it right? https://paste.md-5.net/efivofevov.cs
Oh man, that's big brain
yes, its 11 hours and 59 minutes
It doesn't work...
yess finally
you could do Minutes % 60 to see teh minutes
i was gonna ask that, thank you so much
OK, so programming 1am mind here, but a PotionSplashEvent only fires if someone gets its effects. I wanted to use PlayerInteractEvent anyways rip
mvn install:install-file -Dfile=C:\Users\archi\OneDrive\Desktop\Plugins\MVdWPAPI\pom.xml -DgroupId:be.maximdw -DartifactId=MVdWPlaceholderAPI -Dversion=3.1.1 -Dpackaging=jar -DgeneratePom=true is da cmd im using, cus MVdWPlaceholderAPI doesnt work.
OK, nope, I'm still stuck. I'm not sure if this is tired me coding yet or not, but I'm soooo close. This event is only firing if the potion effect from the thrown potion (the clockwork bomb), reaches a player. I need to cancel a potion throw outright. Is using the PlayerInteractEvent not the move here?
// Prevent non Qadirs from using a clockwork bomb
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPotionThrow(PlayerInteractEvent event)
{
// If the event is fired because of a player
if (MUtil.isntPlayer(event.getPlayer())) return;
Player player = event.getPlayer();
UPlayer uPlayer = UPlayer.get(player);
// and the item is a clockwork bomb
if (!isClockworkBomb(event.getItem())) return;
// and the thrower is a level 3 Qadir
if (!abilityCheck(uPlayer, 3))
{
uPlayer.msg("<i>Only <h>Qadirs <i>may use a <h>Clockwork Bomb<i>.");
event.setCancelled(true);
return;
}
// and the cooldown period has passed
if (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue() < ConfigQadir.get().clockworkBombCooldown)
{
uPlayer.msg("<b>Clockwork Bomb is not ready yet! Wait %s<b>.",
TimeDiffUtil.formattedVerbose(TimeDiffUtil.unitcounts(ConfigQadir.get().clockworkBombCooldown - (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue())), "<h>")
);
event.setCancelled(true);
}
}```
Anyone more experienced knows how I can stop invisible blocks when loading chunks after modifying their content?
I seem to experience weird bugs where if I change the region files and immediately load the chunks, the blocks are there, I can't move, but I'm in a void world
Just don't ignoreCancelled, @dense shoal
PlayerInteractEvent will be called with its cancellation state set to true if right clicking the air
Just a weird quirk of the interact event
Also, as an aside, EventPriority.NORMAL is default. You can omit that too. Just @EventHandler will suffice
Good point
Removing ignoreCancelled didn't fix my problem sadly
Do I need to restart rather than recompile?
Should recompile and reboot your server, yeah.
Though if that still doesn't resolve it, debug all your checks to see which one is failing
PIE is the event to listen to for this
No problem :))
Wait, it's firing twice! fml
Once for each hand
Yep. Can ignore if the event.getItem() is null
Sadly, we're still having trouble. Redeploying to test.
I am logging the item, it doesn't seem to be null.
// Prevent non Qadirs from using a clockwork bomb
@EventHandler
public void onPotionThrow(PlayerInteractEvent event)
{
// If the event is fired because of a player
if (MUtil.isntPlayer(event.getPlayer())) return;
// If the item is not null
if (event.getItem() == null) return;
System.out.println(event.getItem());
Player player = event.getPlayer();
UPlayer uPlayer = UPlayer.get(player);
// and the item is a clockwork bomb
if (!isClockworkBomb(event.getItem())) return;
// and the thrower is a level 3 Qadir
if (!abilityCheck(uPlayer, 3))
{
uPlayer.msg("<i>Only <h>Qadirs <i>may use a <h>Clockwork Bomb<i>.");
event.setCancelled(true);
return;
}
// and the cooldown period has passed
if (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue() < ConfigQadir.get().clockworkBombCooldown)
{
uPlayer.msg("<b>Clockwork Bomb is not ready yet! Wait %s<b>.",
TimeDiffUtil.formattedVerbose(TimeDiffUtil.unitcounts(ConfigQadir.get().clockworkBombCooldown - (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue())), "<h>")
);
event.setCancelled(true);
}
}```
I remember there was some kind of duplication checking in a different event, maybe PlayerAnimationEvent. Am I missing something like that?
It could be null on the off hand.
Wait, what is the problem?
PlayerInteractEvent is firing twice for some reason and I am getting double messages. I'm making sure that I'm just checking the main hand and that the event.getItem() is not null.
// Prevent non Qadirs from using a clockwork bomb
@EventHandler
public void onPotionThrow(PlayerInteractEvent event)
{
// If the event is fired because of a player
if (MUtil.isntPlayer(event.getPlayer())) return;
// If the item is not null
if (event.getItem() == null) return;
// If the item in the main hand is the potion
if (event.getHand() != EquipmentSlot.HAND) return;
System.out.println(event.getHand());
Player player = event.getPlayer();
UPlayer uPlayer = UPlayer.get(player);
// and the item is a clockwork bomb
if (!isClockworkBomb(event.getItem())) return;
// and the thrower is a level 3 Qadir
if (!abilityCheck(uPlayer, 3))
{
uPlayer.msg("<i>Only <h>Qadirs <i>may use a <h>Clockwork Bomb<i>.");
event.setCancelled(true);
return;
}
// and the cooldown period has passed
if (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue() < ConfigQadir.get().clockworkBombCooldown)
{
uPlayer.msg("<b>Clockwork Bomb is not ready yet! Wait %s<b>.",
TimeDiffUtil.formattedVerbose(TimeDiffUtil.unitcounts(ConfigQadir.get().clockworkBombCooldown - (System.currentTimeMillis() - uPlayer.getNumericData(LAST_CLOCKWORK_BOMB).longValue())), "<h>")
);
event.setCancelled(true);
}
}```
It still fires twice?
Yeah! lol
I think this is a product of tired me.
But I won't be able to sleep if I can't get this lol
It's very unlikely to fired twice after you check the hand.
do you have anything in your offhand?
Your mouse could be double clicking lol
🤔
If I left click instead of right clicking the event is only fired once which is interesting.
Is throwing splash potion fired PlayerInteractEvent?
Yeah throwing a regular splash potion fires twice as well.
Then yeah, you have the answer why it fired twice
So it's firing twice by functional design?
I just happened upon that
Same thing happened when you drop item too.
Quick solution would be to Map<UUID, Long> for when they were last messaged and only send a message, say, once every second or so
A bit dirty, but it would be a solution
Yeah, add a cooldown or something
Never heard of PlayerAnimationEvent before.
This might be some crazy person stuff going on, I cannot be trusted right now.
I don't know what happens if you cancel the animation event though, it might still allow the other stuff to happen.
OK, well the good news it that it only sends one message
Is there a way to get the associated PlayerInteractEvent(s) from a related event? Can I do that with handlers?
I think you are overcomplicating stuff.
Good point. I'm going to do the messaging in PlayerAnimationEvent and the cancellation in PlayerInteractEvent
The workaround that Choco gave is enough to fix your issue.
Good point
Have you tried invalidating your cache?
how?
That should be fine. It will take a few minutes for your IDE to get reacclimated, but it might help!
I have this: e.getClickedBlock().getState() instanceof Openable in an if statement, but its always false, why is this? i know that the block i clicked was a door.
Show your full method
oh, that explains
guys if i put my recipe in another class and then in main i do Bukkit.getRecipe(MyRecipe); will it work?
Probably not
Best to just pass it around as needed
i want to have an own recipe class and then that class is registered to main so it will work but im not sure how, anyone know?
Get an understanding of what class is
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Can anyone help me with this command it isnt working
mvn install:install-file -Dfile=C:\Users\archi\OneDrive\Desktop\Plugins\MVdWPAPI\pom.xml -DgroupId:be.maximdw -DartifactId=MVdWPlaceholderAPI -Dversion=3.1.1 -Dpackaging=jar -DgeneratePom=true
It's for MVdW PlaceholderAPI
Just abandon mvdw
I'm an enterprise Java developer and I still don't know Java
damn
Who called you enterprise LoL
I've never done enterprise work in my life but I know more about Java than 90% of enterprise developers.
How come Java is the most used language for enterprise app development?
because its uniform across all architectures.
A lot of reasons
Ah, I'm quite surprised actually.
🤔
Somehow I doubt this
It's just kinda conceited
I'm not here to test you but even if it's true it doesn't come across well to say such things
Do you think Java will still be on the top for at least 1-2 decades
I don't know
The landscape changes quickly
Java is a very solid language so I doubt it's going away anytime soon
It might be overtaken by other, more modern languages
It's hard to say though
Out of all programming language I only interested in java right now
Mmk
python will overtake java
I don;t see that happening
haha
C# : )
if BloodCoinsAPI is your plugin you never use new BloodCoindAPI
you will have a big error in your startup log
nono, the top code snip is the plugin that houses the api
I'm trying to access it from a separate plugin (which is the second code snip)
then you are setting your bloodCoins too early
so what you're saying is that bloodcoins is loading after the other plugin trying to access it?
Well I'm only guessing from teh minimal code you posted, and it is confusing
depend will make your plugin load after the depend one
right, so isn't that what's needed here?
at what point are you initializing your bloodCoins variable?
you mean the api variable?
the BloodCoins prefix to the variable is just the class
not a variable
BloodCoinsAPI bloodCoins = BloodCoins.api; is a variable, when are you initializing it?
No, it's an imported class
bloodCoins is the variable, when is it initialized?
onEnable
then you'll have to show some actual code as what you describe makes no sence
ok you need a reference to the BloodCoins plugin, you can;t just static access it
you need the instance
getPlugin(BloodCoins.class)
or getPlugin("BloodCoins")
I tried this one but it gave me null
Let me give the other one a go
I got a casting error
Cannot cast com.example.warzonepoints.WarzonePoints to com.example.bloodcoins.BloodCoins
WarzonePoints?
That's the plugin that's trying to access the API
why are you getting a plugin reference to itself?
It's not
Your error and teh code you are showign is impossible
using https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/java/JavaPlugin.html#getPlugin(java.lang.Class) it would be impossible for it to return your WarzonePoints plugin
I'll re-compile but it's the code being ran
unless you are passing it WarzonePoints.class
here let me add debug prints
just to assure it's the same code
[03:21:40 INFO]: [WarzonePoints] Enabling WarzonePoints v1.0-SNAPSHOT
[03:21:40 INFO]: [WarzonePoints] 1
[03:21:40 INFO]: [WarzonePoints] 2
[03:21:40 ERROR]: Error occurred while enabling WarzonePoints v1.0-SNAPSHOT (Is it up to date?)
java.lang.ClassCastException: Cannot cast com.example.warzonepoints.WarzonePoints to com.example.bloodcoins.BloodCoins
at java.lang.Class.cast(Class.java:3818) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.getPlugin(JavaPlugin.java:408) ~[patched_1.17.1.jar:git-Purpur-1397]...
unless you called your main class in your WarzonePoints plugin BloodCoins thats impossible
Nope, it's not called or imported into it
?paste show teh full stack trace
which line is WarzonePoints.java:34
BloodCoins bloodCoin = getPlugin(BloodCoins.class);
ok, thats an impossible error
I'm not trolling, I've tried everything to get this stupid variable over
(Or just dont use singletones at all)
guys
i want to import import com.comphenix.protocol.events.PacketEvent; this
but i dont know how to import this one
can i get any help?
that error and the code you showed is impossible
I can screenshare you the code and show you it occurring
its literally impossible for getPlugin(BloodCoins.class) to return the WarzonePoints plugin instance.
Can we hop in a vc on here and I screenshare it?
You don't have to talk or anything. I just want to make sure I'm not going crazy
@eternal oxide
try it with getPlugin("BloodCoins")
do I cast it?
but the errors you show and the code you posted are impossible
same issue with super
BloodCoins bloodCoins = super.getPlugin(BloodCoins.class);
returned
Cannot cast com.example.warzonepoints.WarzonePoints to com.example.bloodcoins.BloodCoins
yeah, that makes no sense at all. Never seen it before
yes
ok so new output:
BloodCoins bloodCoins = (BloodCoins) Bukkit.getServer().getPluginManager().getPlugin("BloodCoins");
returned
class com.example.bloodcoins.BloodCoins cannot be cast to class com.example.bloodcoins.BloodCoins (com.example.bloodcoins.BloodCoins is in unnamed module of loader 'BloodCoins-1.0-SNAPSHOT.jar' @570c3d43; com.example.bloodcoins.BloodCoins is in unnamed module of loader 'WarzonePoints-1.0-SNAPSHOT.jar' @361216a7)
does this channel support embedding links?
or, you have shaded one plugin into the other
wdym
you have to verify
do you use maven?
or you added one plugin into the others dependencies and included it when you compiled
teh dependency needs a scope of provided in maven
do I set it to provided?
yes
else its shading yoru api jar into your plugin jar and its using the wrong imports
the error went away
let me test it 1s
that fixed it @eternal oxide
thank you so much
anyone knows how to be able to walk inside end portal without being teleported? I tried cancelling the portal event but this works only in the portals that are in the normal world, if I try the same thing in the end world, I get stuck in a loading terrain screen
public void onPlayerTeleport(PlayerPortalEvent event) {
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) {
event.setCancelled(true);
}
}```
trapdoors are instanceof Openable right? but this check never works for trapdoors and doors
ugh i have the org.bukkit.material.Openable;
what do i have to do if i can import this one
it doesnt work, it sends errors at Arrays, newArgs & reason
Is there an alternative for the specialsource-maven-plugin for gradle? I wan't to use mojangs nms mappings
paperweight. Thats for paper, but it would work on spigot aswell, unless you use paper specific features
or special-gradle
?google jpenilla/special-gradle
Google your question before asking it:
https://www.google.com/
Oh
Well I'm using paper anyways. So that won't be a problem. Thanks!
Could not load 'plugins\plugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: depend is of wrong type
at org.bukkit.plugin.PluginDescriptionFile.makePluginNameList(PluginDescriptionFile.java:1191) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1070) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:259) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:175) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:409) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.reload(CraftServer.java:908) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.Bukkit.reload(Bukkit.java:697) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:790) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Iterable (java.lang.String and java.lang.Iterable are in module java.base of loader 'bootstrap')
at org.bukkit.plugin.PluginDescriptionFile.makePluginNameList(PluginDescriptionFile.java:1187) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
... 17 more
how can i fix this problem
this is actually so bad
Whats your plugin.yml? Its invalid
You did something that broke it. Most likely in the depend: block
: Could not load 'plugins\plugin.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown dependency ProtocolLib. Please download and install ProtocolLib to run this plugin.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:269) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:409) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.reload(CraftServer.java:908) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.Bukkit.reload(Bukkit.java:697) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:790) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchServerCommand(CraftServer.java:775) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.dedicated.DedicatedServer.handleCommandQueue(DedicatedServer.java:475) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:439) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1217) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1050) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot.jar:3258-Spigot-dc75aca-960f310]
at java.lang.Thread.run(Thread.java:831) [?:?]
after i fix the depend
protocollib is not installed
what do i have to do?
Install Protocollib
open spigot MC, download jar, put it in the plugins folder ..
ty dude
PacketPlayOutMapChunk.class
int[] biomes; // size is 1536
byte[] blockdatas; // huge byte array
BitSet extractedChunkdata; // size is 64
NBTTagCompound heightmap;
List<NBTTagCompound> tileEntitys;
int chunkx;
int chunkz;
// where is skylight, the blocklight, the blockdata
and the palette stored and how to read it?
isnt blocklight stored in the block itself?
Nvm i think thats outdated
hey
i have question
i want to make an array list
that is global
so that i can access it on all classes
is there a way to make that ?
static
oh
Create a manager class that manages the ArrayList.
And pass around the manager class.
Get an understanding of what class is
don't actually do that lmao
yeah i really need to do that LOL
the static thing, i'm joking
shouldnt be joking with noobs like me xD
almost fell for it
lol
is it better to use mysql ?
or am i stupid and mysql wont work for this
That has nothing to do with your first question.
Depends on what are you trying to do
yep, the new palette system is what i need
trying to make a list of every player that joins the server
i'll need info like how many joined,they uuid , name and etc
u could read the folder playerdata for this
Mysql is absolutely different concept and it solves absolutely different tasks
oh okay
Newbies shouldnt know about static at all
so array list is the way to go ?
You want to log every player joined the server?
why?
yes and be able to remove them from the list when i want
cuz they gonna abuse it
oh
Because without understanding it can and will lead to bad design solution
Yes aka abusing
intensive research about static meaning on java
Sure you can use ArrayList for that, do you want it to also persist on server restart?
yes
mysql, sqlite, or even yaml
okay
i tried doing something before
similar to this
but used .json file
and everyone destroyed me for it
lel
why lol
Hi, is it possible to access internal Spigot classes that are not in the spigot api? Something like Class.forName("CraftTravelAgent")
i still dont know lol
Yes
they said its just useless and not efficient
what means bad design?
to store player data on a database?
thats common practice
yeah
.json file
for discord members database
but it gets modified
lol
so Class.forName("org.bukkit.craftbukkit.CraftTravelAgent") would return the CraftTravelAgent class right?
just use mongodb or sql or something
dont use flatfile unless you want the user to modify the data inside the file
ok i'll do that
Make sure to cache it so you can access it without directly accessing the database.
A messy, non-scalable code thats hard to maintain and expand?
manya are you nny?
who
oh nevermind xd
still interesting what does nny mean
nny is a guy
he was active in this server
and for some reason he got ban and always come back with different account xd
why does he get banned
offensive language i think
Class.forName doesn't work, I get ClassNotFoundException
arent craftbukkit packages versioned like nms?
Yeah they are
im in a BlockBreakEvent and I tried to clear a block's drops when broken, doesn't seem to work. is it correct if i say e.getBlock().getDrops().clear();
wdym cache
I don't know what nms is. Do you mean I have to specify full package path?
i mean, org.bukkit.craftbukkit.<version>.CraftTravelAgent
can i get help
thanks, I'll try that
store it in a field, so you don't need to access your database everytime you need some data.
so like on start the plugin gets the data, stores it on a local file and on stop the plugin stores the data on the database ?
something like that yes, on start load and cache it, on stop save it
but then if i want it to be accessible for other servers aswell
that wouldnt work ?
for like a bungee network
for example if i want that a player is frozen on all the network
and i link them all to same database
?
or is that too advanced for me to understand rn xD
you can save and load data on player quit and player join too i guess
idk if that's efficient ?
it might get some errors ?
but idk
afterall am learning so i'll just test around
also thank you @quaint mantle for your suggestion xD
it isn't the minecraft version is it? Is there a method in Spigot api to get that version name?
Class.forName("org.bukkit.craftbukkit."+Bukkit.getBukkitVersion()+".CraftTravelAgent");
Class.forName("org.bukkit.craftbukkit."+Bukkit.getVersion()+".CraftTravelAgent");
Class.forName("org.bukkit.craftbukkit.1.12.2.CraftTravelAgent");
Class.forName("org.bukkit.craftbukkit.1_12_2.CraftTravelAgent");
didn't work
thats how you get the version
V1_17_R1
that did work, thank you a lot
is there a good tutorial for using sqlite somewhere?
i'm not sure if i did it the right way
Show us how you did it
?paste
my code 😅
It's never too late to fix everything 🙂
tell me your design skills and "rules"
Google "SOLID"
hmm md5 paste says something wrong when saving
i made an abstract database class
https://paste.md-5.net/kudajizuye.java
and a class for sqlite
https://paste.md-5.net/iliqeruyax.java
and a databasefactory which creates the startup tables and stuff
https://paste.gg/p/anonymous/939e17ba6b7949018ff44200a121b63b
static ☹️
The Open–closed principle: "Software entities ... should be open for extension, but closed for modification."[7]
does that mean always try zo usw private and protected if possible?
and this is an example how to use it
No not really
That's encapsulation
You should be able to modify the behavior without changing it
For instance using an Enum might break this
Because when you get a new constant of said Enum, you have to find all the switches that switch on the Enum
But if you use something like a base type
Then if you want to add a new type
Simply derive the base type
And you have changed nothing in the system
Apart from adding the new class
why should i even use private and protected i dont want anyone to use reflection later lol, i never understand it
Depends
But mostly because you want to encapsulate the state and variables of objects
Since that’s usually a low level detail
If you have a getter or setter, you can at anytime change the behavior of how other classes query and change the data in your class.
thats not about hiding
Needless to say, it can make your class substitutable for other classes which can save some effort sometimes
its easier to control and edit methods behaviour rather than fields
when i create classes i never use getMyString() {
return this.mystring
}
i always use classobject.mystring;
is that bad?
yes
just bc all do i t over bc its slower? i mean its less code needed, isnt that better anyway always?
Less code doesn’t make it better.
And it is somewhat slower to use getters and setters ofc, but that difference is negligibly small
well
It’s just naive and foolish to compare performance in this case
Needless to say that you if you want polymorphism you cant use fields
no but i mean its not needed
Im trying to use the #playEffect method in 1.8.8 spigot. But after running that all the other stuff in the file stops working.
But in the future, a change might be necessary
i accidently created a thread xD
Preparing yourself for that change is a wise choice
well when i need it i can easly change it
hehe.. (no)
wdym
why
Let’s say someone is depending on your code
you'd have to replace ALL field references with methods
Changing that will make their code break
That’s untrue
First of all
The change would require a recompile
well if i update things they have to update to, if i change the getter method name their code is broken too
well, its much easier to deprecate methods
bc my names are anyway very weird xD
That’s a you problem
i dont find the right words to describe a method
is there even a way to learn this or am i stuck
Learn what?
to find the right words for something
put something in short
etc.
i am very bad at it
What is this something? xD
a thing what a method do not in 3 sentence but in some words
Anyways a method is just a function which is bound to an object and can be invoked by the objects type. To make it even simpler, it is an instruction containing other instructions.
Im playing around with Texcomponents and their events, but it seems there is no neat way of calling a method from a class when a clickevent is triggered without making a command that just calls that method. Am I wrong or can I just call a method directly ?
No you can’t
So I need to make a command that just calls my method ?
annoying, but ok
unavoidable
but why required for just getting a field xD i dont get it
Yeah you probably don’t get it now, because you’re simply making a mere small plugin
The best way to experience why public fields are disastrous regarding design is by using it a lot such that you can see for yourself all the downsides
Although small project doesnt means you can ignore principles
Indeed
hey
hi
No
Minecraft isn’t ideal regarding code architecture tho
Thats dumb bukkit with .at that makes almost all fields public instead of creating a getter
any recommendations ?
pls
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Just picked one
but public static final field still acceptable right?
Yes. Static is acceptable if it doesnt have mutable state 🌞
anyone can help me understanding how to modify the palette that get send to the client
but some i do set in the constructor
thanks
You are probably doing something wrong
me?
is there a plugin where u can steal hearts in 1.16.5?
and create hearts?
@coral pilot
is there?
oh but if i set them at field creation i get null sometimes (when i do a world that have zo load by multiverse first)
idk but i think this is made with packets
whats that?
oh
player#damage()
i dont have micro
so what command do i do
are u coding or do u search a plugin?
when do u want to damage or heal a player?
this channel is for plugin development
WHen you kill someone it gives your one of there hearts
u better in #help-server
#help-server about plugin, config, or other stuff
how can i make it so my plugin includes resource files? like other files that my plugin uses
why does JavaPlugin has an empty onCommand and onTabComplete method?
Add them to src/main/resources and use saveResource?
wdym?
Cuz it implements TabExecutor
use saveResource?
for what reason?
plugin.saveResource() copies a file from your jar to data folder
oh ok
Maybe, a long time ago plugins were meant to just add commands..
Plugin is a default command executor for commands you define in plugin.yml actually
This class is provided as a convenience to implement both TabCompleter and CommandExecutor.
smh
like this?
yes
i still get this error tho which is wierd
Checkif your jar contains the file

oh gosh me!