#development
1 messages · Page 10 of 1
onlinePlayerSaves.put(p, resultSet);
p.sendMessage(onlinePlayerSaves.toString());
I have this on join
Then I access it when breaking a block
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ffs if you want help, show your code. Full classes, no weird pasting together
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
are you inserting entries asynchronously?
also why are you always creating anonymous classes when using hashmaps?
I was going to ask that
and if you are using concurrent access
use concurrenthashmap
instead
Yes use concurrenthashmap
uhh im not putting anything into the db yet
but let me switch over to concurrent
yeah still seem to be getting empty map
remove the {} at the end
d;jdk List#of
static List<E> of()```
Returns an unmodifiable list containing zero elements. See Unmodifiable Lists for details.
9
an empty List
Thats a map though
Hello, it will cause lags if i check every seconds all players if they are on water ?
why use another scheduler
check when they move
if all you are doing is a basic if statement
then it wont affect in a meaningful matter
server does not start ticking
before all plugins are enabled right?
so i could do:
load plugin a
load plugin b that depend on a
load plugin c that depend on a
// do stuff on plugin a once these two are loaded using a delayed task with 1 tick delay
wait, if u need plugin b and c to do stuff on a -- isn't a that depends on the others?
no
a has a listener integration
and needs to fire a socket once all plugins that depend on it pass the references
i could do it with a basic timer
but that doesnt feel robust, so i am trying to figure out if there is a "server is ready and plugins are fully initialized" event
yeah there's ServerLoadEvent which sounds more appropriate than scheduling a task
mh why is it marked as @Deprecated ?
not deprecated on 1.18.2 at least
thanks
is there an equivalent of this in velocity?
or do i register listerners on constructor then subscribe on init event
huh?
The PIE would be the equivalent
This event is fired by the proxy after plugins have been loaded but before the proxy starts accepting connections.
Not really sure what you mean by that second comment
the issue is, there is no "enable" event on velocity
not sure when it calls the constructors though
this basically is the issue
i am not sure about the load order
since if plugin b gets loaded before plugin a then if i register using constructor = no class def exception
The constructor is called whenever it's called but, the plugin class is automatically registered as an event listener (why you can just add a @Subscribe to the PIE)
If you declare the plugin dependency properly, plugin a will always be constructed before plugin b, and by the time PIE is called all plugins will have been created
yes, does plugin initializations also happen according to dependency order
initialization event fires according to the order, not sure about the plugin instances being created though
although must be since, you would run into more issues most likely
It sure as hell should load in the same order; I don't know velocity internals but I presume it eagerly evaluates the entire plugin dependency tree, and then once it's done with that it walks that tree (from "dependent" to "dependee") creating them
At least that's what any sane module system would :D
Is there some command to check all the tags and other data present in an Itemstack?
i cant test from this shitty laptop hence the question here
but that word of caution lowkey scared me
It's more about "you can't do everything in the constructor"
paper has /paper dumpitem i believe
self contained code should be fine then and hopefully the constructor creation is sane
Sweet
/data get entity YourName SelectedItem
hm, that worked, strange, ty
Object blah = getBlah1();
if (check) blah.doBlah2();```if `check` is false, is `blah` still parsed? *basically, are variables parsed before being used?*
also, how can i keep a chunk loaded with a specific item in it? im spawning an item, so if there's a way to keep a chunk loaded by location or something thats fine
what do you mean by "parsed"
a variable is effectively just a pointer
and yes from the point you create it, it will start pointing at whatever you assign it to
for chunk loading, hook up to chunkUnload event
then cancel it
by checking through location
Whats the entity parameter in PlayerFishEvent?
PlayerFishEvent(Player player, Entity entity, FishHook hookEntity, PlayerFishEvent.State state)
does getBlah1 run if check is false?
i imagine it relates to the caught entity
yes, it will fire from top to bottom
getBlah1 - check if true - blah2 - if false stop
is what will that do
javadocs are your friend
I thought so but wasn't sure. Guess I'll just test it.
Yeah read that along with the getCaught() method but still wasn't sure.
apparently it can still be an item as well
@hoary scarab
are you creating your own entity fish event?
yes, so it changes over the events time
rather over the state
according to the last variable
Just creating a new event so my listener can run instead of me trying to match methods to events.
and just so i understand correctly, if its like this:
if (check) getBlah1().doBlah2();```if `check` is false, `getBlah1()` wont run?
yes
if getBlah1 does not do anything
and just returns an object reference
then performance impant is non-existant
its o(1)
but if you are calculating something, its probably better to do it inside the if
if its not necessary
but if getBlah1 does do something, it would be better for performance to have it inside of the check?
ok
ty
don't try to micro-optimize code by doing stuff like that though
optimise for readability 
i probably wont, but ive just been wondering about it for so long
but some stuff i have is stupidly inefficient/performance-heavy cause i cant be bothered to fix it 
Any reason why when creating a new lore and setting it with meta.lore(list<Component>), it makes the whole lore italic?
Even though i havent made it italic anywhere
not exactly a micro optimization honestly, if you need something after an if check then its a given that you get it after the if check
its mc default, put ChatColor.RESET at the beginning
how do I disable that?
for just getting a reference sure
Vanilla behavior that's removed by spigot for strings
At the beginning where
but with calculations sure
for Components, u need to set the TextDecorations to false i believe
Append each line to an empty component with italic false is what I do
is that adventure?
yeah
is it easier/better than chatcolors in ur opinion?
if it's e.g. just a getter, it's rather a micro optimization
It looks a bit cleaner I suppose
^
Components is what minecraft uses for years
I am using paper, should it not do this automatically?
Not Adventure directly, but yeah
If you rename an item in vanilla, it will be italic
like for events, i usually put all the event.getBlah() stuff at the beginning cause that just makes sense
yeah, but thats just a reference
Spigot disable the italic for strings, that's why you have never seen it
I changing the lore through code though
Ahh
It's not strings as it is text components
but if you need to pull data from sql and thats what the "get" does
then thats a bad idea
Yes, Adventure works just like vanilla does
bad naming smh
So I have to append italic false to each single line
That's... very inconvenient
😟
No no, append the line to an empty component with italic false

that's minecraft for ya
Append the line where?
First line of the lore?
oh god
you can just have a static component that you always append to
what do you want to name it, fetchData?
probably just not beginning with get
So I have to set italic to false before..?
Why not after
it doesnt matter where
I prefix fetch/query to anything-IO yeah
just that the parent component has it set to false
I think i am better off making a util method to do this for me automatically
Removing it from the line itself will remove italic set manually
even when its packaging the data after fetching it?
ComponentUtils.NON_ITALIC.append(stuff) is always an option. idk how "improper" it is but it doesnt seem too bad
cuz in normal usage, you have it in a continuation
or through a callback and never really directly
Looks decent enough
yes
you'd have to define it yourself obv but its pretty straight forward
Or, you know, shovel it in your parse method or whatever
Right yeah I can just have a loop append that at the end of each component
Start*
But yeah, is a small thing anyways, and something that could also be a thing on spigot but someone decided to remove it for some reason
the best part about components is that ItemStack#displayName() and ItemStack#itemMeta().displayName() return different components 🥲
Yeah, I believe the first method does extra checks to return the name depending on client's language if the item doesn't have a custom name set
While the second just returns what was set in the ItemMeta
even if it does it returns the name in []
Oh it also has a hover? Mhm
yea
Nice, nice
I'm making an API that gets shaded into a given plugin, and should support whatever (non-legacy) version of spigot that plugin is built on.
How do I allow it to accept things like materials from a higher version than the API was compiled on?
eg. if you compile against 1.19 you should be able to use Skulk blocks
but if you compile against 1.18 you shouldn't
(this is in a method within the API that accepts Materials)
wouldn't it just take a Material and that's it?
doesn't matter
oh, does it use the version depended on in the main project over the one I do?
The highest you need I guess
I just worried it would be trying to accept a 1.18 material, while being given a 1.19 one
thanks 🙂
the api version you depend on doesn't matter
all you care about is taking a Material
your plugin doesn't hard-code the available Materials during compilation
I mean the compilation of the API vs the compilation of the plugin
I get that part
since the project now has 2 versions of spigot it depends on
one within the API that's lower
and a higher one within the plugin
i'm still not sure what the concern is
The api is not different from a plugin that supports multiple versions
No matter the version you still use Material#getMaterial for example
unless you need to use e.g. Material.SKULK directly inside the api/plugin then it doesn't matter
alright. Just wanted to check if there would be compile errors
oh yeah, that's what I mean
or use minimessage 👀
using Material.SCULK hardcoded into the plugin, even though it depends on a higher version of spigot than the API, which does not know about Material.SCULK
You still need to remove the italic
<reset> ...
Itemstacks are wrapped in a dumb component
then you need to change the dependency on the plugin, not the api
okay, cool
so that should make it allow newer blocks?
that the API was not compiled to know about
I guess as long as it's not shaded it's fine
thanks Emily
all you care about is that on the version that your plugin is running on
You can probably get around that with adding some versions checks, but depends on the use case I guess
I was just worrying that Maven/Gradle would be a pain with the 2 versions of spigot API in one project really
internals dont matter since its dynamic depending on whats being loaded on the server
use the highest version and avoid using any materials directly in the api
then you should be fine
but if I'm hard coding a 1.19 only material, it has to accept 1.19 materials everywhere
that's all
What are you trying to do with skulk, Fred?
but yes, I think I get it now
I'm making a plugin manager thing for a few of my plugins to link them together
and it will add a GUI to manage the plugins
all in one spot
and the icon for atleast one of my plugins is skulk related
Add a fallback material maybe? Or use skulls
But I don't need a fallback, since the plugin is 1.19 only
i would fill the gui from the plugins
rather than filling them from the api
to avoid this whole issue
cant put it as dependency?
Yeah but if you want to show all your plugins, it matters
nope
just loaded ones
idc about unloaded ones, atleast at the moment
though that is a cool idea actually
but I can filter it out to only that version and below
Material pluginXIcon = ServerVersion.is_1_19 ? Material.SKULK : Material.PAPER;
api doesnt need to know whats being registered
it will work now though, I get that
just needs the item / material
my only worry was that
ApiThatOnlySupports118.setIcon(Material.119Material)
would be an issue
no
it wont be
right, I get that now lol
your api takes Material
it just takes a Material, any material
Just wanted to verify
it would only pose an issue
if you try to load your 1.19 plugin on 1.18
but thats an issue regardless
api-version: 1.19
yeah but that's on the plugin itself, not really to do with the api
your api just uses bukkit api for the material
and thats already dynamic depending on the version of the server
you are not compiling the dependency into the plugin so, it is runtime
api is, not bukkit
How can I play the "health regen" animation the hearts have when regenerating naturally?
Ahh got it
Gotta do sendHealthUpdate()
How do I prevent zombies from converting into drowneds?
actually EntityTransformEvent is better
Is there any way to change the base damage a tool does when swung?
Attributes probably
Didn't know they also worked for items
d;fields attribute
org.bukkit.attribute.Attribute%GENERIC_ATTACK_KNOCKBACK
org.bukkit.attribute.Attribute%GENERIC_MOVEMENT_SPEED
org.bukkit.attribute.Attribute%GENERIC_ATTACK_DAMAGE
org.bukkit.attribute.Attribute%GENERIC_ARMOR
org.bukkit.attribute.Attribute%HORSE_JUMP_STRENGTH
org.bukkit.attribute.Attribute%GENERIC_FOLLOW_RANGE
org.bukkit.attribute.Attribute%GENERIC_LUCK
org.bukkit.attribute.Attribute%GENERIC_MAX_HEALTH
org.bukkit.attribute.Attribute%GENERIC_KNOCKBACK_RESISTANCE
org.bukkit.attribute.Attribute%GENERIC_ATTACK_SPEED
org.bukkit.attribute.Attribute%GENERIC_FLYING_SPEED
org.bukkit.attribute.Attribute%GENERIC_ARMOR_TOUGHNESS
org.bukkit.attribute.Attribute%ZOMBIE_SPAWN_REINFORCEMENTS```
d;Itemmeta#addattributemodifier
boolean addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier)
throws NullPointerException, IllegalArgumentException, NullPointerException```
Add an Attribute and it's Modifier. AttributeModifiers can now support EquipmentSlots. If not set, the AttributeModifier will be active in ALL slots.
Two AttributeModifiers that have the same UUID cannot exist on the same Attribute.
true if the Attribute and AttributeModifier were successfully added
attribute - the Attribute to modify
modifier - the AttributeModifier specifying the modification
NullPointerException - if AttributeModifier is null
IllegalArgumentException - if AttributeModifier already exists
NullPointerException - if Attribute is null
Caused by: java.lang.ClassNotFoundException: me.filoghost.holographicdisplays.api.HolographicDisplaysAPI
``` anyone got any idea why its giving me it? I'm using the newest HolographicDisplay Plugin and also the newest version of the API for the 3.0.0 HolographicDisplays Plugin
show the entire error
?paste
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
Do you actually have HD installed on your server?
if you do, make sure you are not shading the API inside your plugin
are you using maven or gradle?
maven, but im using the newest JAR since the 3.0.0 api isn't there with maven yet
ok. in your pom, what is the scope of HD? is it provided?
Shading dependencies is the process of including and renaming dependencies (thus relocating the classes & rewriting affected bytecode & resources) to create a private copy that you bundle alongside your own code.
better than I Could've ever said it
I don't have it in POM since i use the jar of the API
how do you use it tho? using your IDE's dependency manager?
added the jar to Libraries
anyways. there's an easy way to check if this is the case or not. Use either a tool like JDGui or just an archive manager like WinRAR to navigate thru the packages and see if by any chance the HD packages are there
as far as I see, they aren't
in my plugin
can you send a full startup log of your server and possibly the plugin jar here as well?
ah I Found the reason
you said you use the 3.0.0 development builds?
works fine on my server
means what can i do?
nvm i did fix it
using the HD Plugin as API now and it works as it should
Anyone have an idea as to why this SQL query is failing?
private static void createBoosterTable() throws SQLException {
System.out.println(connection);
String query = "CREATE NEW TABLE IF NOT EXISTS BOOSTERS" +
" (ref_name VARCHAR(255) PRIMARY KEY, " +
"time INTEGER)";
Statement stmt = connection.createStatement();
stmt.execute(query);
}```
When this one works perfectly fine
private static void createAuctionTable() throws SQLException {
String query = "CREATE TABLE IF NOT EXISTS AUCTION" + "(index INTEGER PRIMARY KEY," +
"item INTEGER," +
"itemdata INTEGER," +
"start BIGINT(255)," +
"bids MEDIUMTEXT)";
Statement stmt = connection.createStatement();
stmt.execute(query);
}```
remove the "NEW"
happens when you do sql too much in one day
basecomponent is depraciated, what should we use for 1.18+?
adventure
Is there an easier way to show item in hand using adventure?
Trying to figure out how to use HoverEvent<HoverEvent.ShowItem>
player.sendMessage(itemStack.displayName())
Sorry I meant I want to show like the hover, with a component in chat of the whole item
player.sendMessage(Component.text("hi").hoverEvent(itemStack))
wait you can do that
yes
didn't know
now you do
that made things a lot easier wow
for displayName(), how do I have it as a string, it's a Component rn
why do you need it as a string?
I wanna do Component.text(displayName)
Component.text gives you a Component
ItemStack#displayName already is a Component
You already have what you want
oh im dumb got it
lmao
itemHand.displayName().hoverEvent(itemHand)
ItemStack#displayName will already have the hover event added
It's whatever vanilla shows in, e.g. the feedback for /give
This adventure update is pretty dope
i guess vanilla doesn't show the lore for /give 
oh no it returns whatever shows when you kill someone with a renamed or enchanted item and such
yeah, not /give
whats the best way going about editing asyncChatEvent.message()
I wanna replace a text with a new component
can I use a bukkitschedule with a timestamp to exexute?
to prevent lag from making a given schedule run longer
why can't I upload pics?
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload or similar service to upload images/screenshots.
ty
can I not save two collections to a db async?
both functions "run" but the playerData isn't getting saved
public void saveMasteryData(MasteryData p, String pid) {
Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
@Override
public void run() {
String playerJson = DrugCore.gson.toJson(p);
collection.updateOne(Filters.eq("uuid",pid), Updates.set("data",playerJson));
}
});
}
public void savePlayerData(PlayerData p, String pid) {
Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
@Override
public void run() {
String playerJson = DrugCore.gson.toJson(p);
collection.updateOne(Filters.eq("uuid",pid), Updates.set("data",playerJson));
}
});
}
PlayerData isn't null either, the collection just isnt getting populated
what is the best way to eliminate race condition with databases that happen when a player switches server?
server a - player quits - data gets saved - server b - player joins - data loaded
connection happens first then the old server disconnects
resulting in old data being loaded due to this can't just lock the row in the database
and no, can't save when changes happen or load with a set delay
Someone that knows anything about Laravel?
so the they both have different collection names and both JSONs are not null, can't figure out why playerData won't save into the DB
why do you even need two methods that do the same
When is switch server event called? Or there's no such thing
Or, hmm, can you add a few seconds delay before save and on join, check if the player is coming from a server and request the data directly from that server, save the data on the new server and cancel the save task from the old server?
Leave server A
Add task to save later the data on server A
Join server B
Request the data from server A
Save the data on server B
Cancel the save task from server A
the issue is that
?
to transfer data you need to use plugin messaging
and that requires a player on the server
Yeah but there's other ways to do this
I'm wondering since it connects first to the second server then disconnects
maybe there is a window in between to transfer data
otherwise I think distributing from a bungee plugin is probably the safest
when was the chat component api added to spigot? 1.13?
Bungee components you mean?
yeah
Nah I think it exists even on 1.8 + bungee is not version specific, you can use latest for 1.8 for example
wait. does it not come inside the spigot jar?
d;1.8 Player$Spigot#sendMessage
public void sendMessage(net.md_5.bungee.api.chat.BaseComponent component)```
Sends the component to the player
component - the components to send
I think it does, but you need to define a repo for it, idk
Why do you need to use that shit?
I don't know if I actually need it.
I was looking for a way to send a json message in spigot that would work from 1.12.2 to 1.19.2
Adventure
but looking at it, doesn't even seem like they have a way to translate that

yeah was just thinking, they have a json serializer right?
Yes
shadowing adventure
nice. they don't use a special serialization right? strings that would be send with /tellraw would work with it just fine?
And id say we should promote some [mini] action instead of [json]
legit decreased my lifespan
?
I guess so
Try to generate a json on the webui
we talked about this gaby
Shading adventure is the same process besides that u should use 1.16.4 api or below
ok. and who said we will promote JSON lol?
I just serialize using data classes in kotlin
we ain't even doing that now
and don't bother honestly
Ok blitz
Hiberna… 
Hmm when I loop through a item lore with
for (String s : item.getItemMeta.getLore()) {
if (s.contains("whatever-is-in-lore") {
// code
}
}
it only can get the first line otherwise code wont run, anyone have any idea why?
I tried also creating the list first but albeit still wont work
Show your actual code
Code?
code
Smh
I have literally isolated that specific code on a test plugin and it wont loop through the arraylist's string but when i return the list as string it displays all the items lore
???
@EventHandler
public void onPlayerAttack(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
Player player = (Player) event.getDamager();
Player victim = (Player) event.getEntity();
ItemStack getItemInHand = player.getItemInHand();
//Check for Perun's Wrath//
if (getItemInHand.hasItemMeta()) {
if (getItemInHand.getItemMeta().hasLore()) {
for (String s : ((Player) event.getDamager()).getItemInHand().getItemMeta().getLore()) {
if (s.contains("per diamond piece")) {
player.sendMessage("true");
}
}
So it should send "true" if a line in the lore contains that. So whats the output?
nothing
however if i just use it to send the list as string to player it sends the whole lore like it should
i honeslty dont why it only takes the first line
have you actually tried printing each line inside the for loop without any checks?
to see if it doesn't loop thru all lines like you said?
well then the loop works
Show screen shots. Lore and output.
ahhh
figured it out
why do I need to include the color code symbol
lol
pretty odd but with the symbol in it works
bcz those are also characters in the string
they're only hidden for the user by the minecraft client
but they exist within the string itself
yeah only just figured that lol
I thought translateColorCodes removed the symbol in the list
after also translating '&' or whatever
anyway thanks for the help gotta learn java more lol
hey I'm making some slashcommands, and wondering do I need to make the slash commands in the interaction.guild deployment and the index? i have tried to make a custom command but hasn't worked.
anyone know how to turn mongodb driver messages when starting up?
Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
mongoLogger.setLevel(Level.WARNING);
I've used this and it still seems to spam console
can someone send a link to a tutorial on vectors pls
idk which one is the best to read
what are you looking for?
For some weird reason my entity does not have a killer when fetched in a EntityDamageByEntityEvent
Though I damage it with mob.damage(damage, shooter);
Shooter is not null, neither is mob
killer != damager
Even with this though
mob.damage(damage, shooter);
mob.setKiller(shooter);```
It still says it's null
Actually even event.getDamager() says it's null?
Even if the method documentation says @NotNull
might be a bug 
depending on where you call that method, it might clash with other functionality
It gets called when using a weapon which throws a ray out
the method checks for entities near the ray, and then damages any that are hit by it
Could dealing the damage in a BukkitRunnable have something to do with it?
Or
or nothing idk
this is weird
wait let me check this i have done the exact same thing recently
and had that problem at a certain point
wait if you don't kill the player so "setKiller" not working
is that possible
i kinda have the same code over here and no problems with it
I'm killing a mob
yeahh
did you tried that exact code in outside of the event
outside where?
so you said that it may be related with the entitydamageevent
Right after I set the killer yeah i checked and it's not null
you can just test it out
so it's for sure that this is related with the event
right?
I'll check with a interact at event
Yeah when right clicking the killer is not null
Only in the EntityDamageByEntityEvent
alright thats a progress i guess
Yeah
are you testing it with any plugins?
maybe some other plugins may be playing with the setKiller in that event
so you can change your events priority
the killer is probably applied after the event in case the event is cancelled
although I haven't looked at the messages below your question yet
its likely
(so that bukkit doesn't have to set the killer to the previous killer again)
:nostatic:
god fucking christ i hate bukkit with a passion
Hmm what then ffs
i am not really sure tho
i can't find fucking anything when searching something in this code
its like a maze
Even in the EntityDeathEvent it's null
any tips for this?
so what you need is to basically set the killer in EntityDamageByEntityEvent
this is happening to me again with 1.10.0 -> 1.10.1 :(
had this issue before
you have to set the cache thing to disabled
1 sec
outputs.upToDateWhen { false }
where?
processResources {
outputs.upToDateWhen { false }
expand("pluginVersion" to project.version)
}
```this is what I use for ex
alternatively you can clean on every build 🥴
(not recommended)
alr ill see if this works next time i update, ty
or do it the proper way
👀
processResources {
inputs.property("version", project.version)
expand(...)
}
like ```kt
processResources {
inputs.property("pluginVersion", project.version)
expand("pluginVersion" to project.version)
}
yea
what does inputs.property do?
declares a task input, helps gradle know when a task is up to date or not e.g. if an input changes value
not really
that's for the specific task action itself when it runs
not the property's generic inputs
like it can not run at all if none of the inputs have changed
Ohh I see
> Cannot call TaskInputs.property(String, Object) on task ':processResources' after task has started execution.
show your build.gradle pretty please
in an onInventoryClick event, can you not track when players click on armor slots in gamemode creative?
cause i want to track when a player clicks on the armor slot in both gmc and gms
don't even bother with creative mode
lots of the player's own inventory stuff is purely client-sided
so there is no way to track when a player clicks on their head slot in creative with a non armor item?
i don't really know for sure about specific scenarios but you're gonna spend more time banging your head on the wall than successfully tracking stuff
how do I remove italics for itemName
nope its clientside only
I tried setting the ItemStack.color() to white
using components?
.decoration(TextDecoration.ITALICS, false)
that worked, thanks
sometimes I get this error: https://pastebin.com/NLyc2jAp
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
it runs when a player quits
public void saveData(MasteryData m, PlayerData p, String pid) {
Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
@Override
public void run() {
String playerJson = DrugCore.gson.toJson(m);
collection.updateOne(Filters.eq("uuid",pid), Updates.set("masteryData",playerJson));
playerJson = DrugCore.gson.toJson(p);
collection.updateOne(Filters.eq("uuid",pid), Updates.set("playerData",playerJson));
}
});
}
I run this
show with inputs.property
o shoot right
is this a plugin or a program?
since if it's a plugin you don't need the application plugin
and put expand outside of filesMatching
no
inputs.property outside of filesMatching
whoops
what is at line 42?
the bukkit scheduler
Bukkit.getScheduler().runTaskAsynchronously(DrugCore.getInstance(), new Runnable() {
this?
ye
i assume it has something to do with DrugCore.getInstance(), but im not sure what
what is DrugCore?
my main class
hm
maybe put DrugCore.getInstance() into a try and set the catch to ClassNotFoundException, then print stack trace (and a debug msg) if exception occurs. just to confirm thats what is causing the issue
i tried googling it a bit, and all i found was issues regarding getting the main classes of other plugins, and that the person was trying to get them before the plugin enabled or something. but i dont think that would be the case here considering its happening when a player leaves, and not on plugin start
does it only happen to some players? like does it only happen to you?
im the only one relogging
yeah im not rly sure whats going on, sry
if i do that then it doesnt generate a -all file (which i need)
also the version thing worked, thx
trying to set an armor stand's velocity to follow a vector from point A to point B
this is what i have rn:
stand.setVelocity(stand.getLocation().subtract(locationB).toVector().normalize().multiply(1));```but when the velocity is set, the armor stand just doesnt move
ohhh i think i figured it out, i was setting the stand's gravity off
which ig messed with the velocity
so now the armor stand is moving, but its not moving in the correct direction
figured it out, but now how do i keep it so that it doesnt fall to the ground (since setting no gravity wont work)?
You might have to animate it frame by frame or something?
or idk maybe make it ride another armor stand without gravity
No idea if that would work
yea i dont think it would since then it's velocity would be overwritten by the armor stand its riding
i think i might just be able to set the velocity's vector's Y to 0 using Vector#setY
this didnt work :(
i also need to figure out how to make it so the armor stand can go thru blocks
im trying to eject all passengers from an armor stand, but it just isnt working
stand.eject();
stand.getPassengers().forEach(entity -> Bukkit.broadcastMessage(entity.getName()));```2nd line is for debugging, every time it sends my username when it shouldnt send anything
i also tried doing `stand.getPassengers().forEach(entity -> stand.removePassenger(entity));` but that didnt work either
what does eject return?
Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
mongoLogger.setLevel(Level.WARNING);
why doesnt this prevent the spam from mongo from showing up
d;Player#eject
boolean eject()```
Eject any passenger.
True if there was a passenger.
Still not required
Make sure you're running gradle shadowJar
Spigot doesn't look in Java main class
So even with application plugin u can remove the main class line in the build gradle
Has String.split(String) always included the string used in the method in the array?
String example = "a | b";
String[] array = example.split(" | ")
ConsoleOutput.debug("Array Size: "+array.lenght);
Arrays.asList(array).forEach(arg -> ConsoleOutput.debug(arg));
```Outputs
> 3
> a
> |
> b
Edited the message for context
that's because split uses a regex and | is a special character in regex
Ok let me test. Never had an issue with it before.
Might be an issue with java17
i can assure you it's always functioned like that
Ok well fixed it with \\ thank you.
np
hey is there a way to check on EntityDamageEvent if the damage is caused by the plugin?
Nevermind figured it out by setting a damageCause of Magic
help
what am I doing wrong here
placeholder class
https://paste.helpch.at/luraduyimi.java
dunno
whats the problem?
that is not how papi works
then how so
strings in java are immutable so setPlaceholders returns a new string with the placeholders set
it doesnt do any magic
and what do I have to do to make it work?
use the returned string rather than "%blah%"
what
did the api for creating an expansion change since the last time i used it cus afaik its public String onRequest(OfflinePlayer player, String params) {
I can see 2 methods in the wiki
onPlaceholderRequest(Player, String)
theres this one as well
or atleast thats what i followed and it works like a charm
btw you did register the expansion in your main class's on enable right?
@Override
public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvents(new LocationEvent(), this);
new LocationPlaceholder().register();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}```
and in your plugin.yml your depending on placeholderapi right?
thats exactly what I followed
yep
version: '${project.version}'
main: me.none030.crypsisplaceholders.CrypsisPlaceholders
api-version: 1.19
depend: [PlaceholderAPI, WorldGuard]```
im using the placeholder on SimpleScore plugin
according to With a Plugin (Internal Class) it uses onRequest rather then onPlaceholderREquest
the only time onplaceholderrequest is shown to be used is by the relational placeholders
try switching to onrequest and see if it starts working
If I spawn using packets an armorstand, and set it as passenger or a player and set me as passenger of the armorstand
we will see it as we are mounting, what would others see? (people who joined the world or the server or didnt recieve the spawn packet)
would i look like "mounting" the armorstand which is mounting the player?
i dont wanna run shadowJar every time, i prefer just running gradle b
is there another way to generate -all when using gradle b?
start by having it return something, make sure that its not just a problem with the content of the onrequest
tasks {
build { dependsOn(shadowJar) }
}
so in the if identifier equals, have it return something like an empty string
or run gradlew sJ instead lol
if the return statement on line 39 still doesnt work then its gotta be something else
hey any one know where i can find support on coding a bot/
a bot for what?
Probably here, just ask
k
actually yes, someone here might know a solution to your problem
so I'm creating a discord server bot and am struggling on slash commands, https://discordjs.guide/creating-your-bot/creating-commands.html#resulting-code so I've created the initial ping commands, ping, server and user, but struggling to add in my own, do I need to add the command to index.js, interaction.guild and deployment-commands.js for this to work? also on the next section called command handling, im struggling to get the new commands like avatar, kick and beep to respond atall, i even resulted to coping the code, to rule out any mistakes. maybe im missing a file or something but im just stumped. here is the section im on now https://github.com/discordjs/guide/tree/main/code-samples/creating-your-bot/command-handling/commands
finally made it work it was just a dumb mistake
I typed the wrong world name
if anyone can help please ping or dm me thankyou! your help is greatly appreciated 🙂
why in the world does it prematurely kill the player at 5 hearts when I do this:
if (victim.getHealth() - event.getFinalDamage() <= 0) {
event.setCancelled(true);
victim.setHealth(victim.getMaxHealth();
victim.teleport(victim.getWorld().getSpawnLocation();
The code cancels the death screen however testing it it does it too quick at 4-5 hearts
disabled all other event handlers etc and same result
Someone?
commands needs to be sent to be registered using that deployment-command.js
can i
hide particles for everyone?
only for one specific effect though
night vision
you askin why I want to hide only nv particles?
for everyone
i want to hide it from everyone
.
can anyone help me with these 2 things?
o and this
why not simply set particles false?
how are you adding the effect?
i wanted to make a toggle on/off command
that gives you night vision
and removes it from you
when you send the command a second time
also how do I create a toggle on/off command, ik how to make regular commands but not commands that turn off and turn on
but I think I already figured it out
check if player has night vision and if they do, remove it
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public final class Nvod extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("nv")){
if(sender instanceof Player){
Player playerWhoToggled = (Player) sender;
playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada.");
}
}
return true;
}
}
``` have a look
if (playerHasNightVision) {
playerRemoveNightVision;
return true;
}
playerAddNightVision
return true;```
thats it?
yes
do I have to put this below the if statement that gives nv?
wdym
you just check by hasPermission like normal
you dont need to hook up to luckperms specifically
explain this to me actually
if a player has night vision it will remove it
if they dont have night vision it will add it
thats what it does already
but this won't work
is returns the part that confuses you?
its pseudo code
so you cant copy paste obviously
playerHasNightVision etc
you need to replace with stuff that does that exactly
to check if they have night vision u can loop thru their potion effects btw
its psuedo code so u adjust the variables to the ones u have
if (playerHasNightVision) { // Check if the player has night vision
playerRemoveNightVision; // Since they have it, remove it
return true; // Stop the code
}
// They dont have it, since the case where they have it is above
playerAddNightVision // Give them night vision
return true; // stop code
but does playerHasNightVision exist?
nope
.
i explained how u can check here
depending on if they have it or not
nvm there is Player#hasPotionEffect
thats even easier then
no u replace that with a boolean using Player#hasPotionEffect
okay
if (check if player has night vision) {
remove night vision
return true;
}
add night vision
return true;```
thats only the easier part of the plugin btw
ill have to do something way more complicated later
that i dont even know
if its possible
what is it?
basically
this plugin is for a minigames server
which has a lot of minigames
most minigames will have this nv thing
but theres this one minigame
where its like dead by daylight
and it doesnt make sense
if the people escaping from the killer have night vision
so my friend asked to make this plugin work
only in specific worlds
because the minigames are built on different worlds of course
@dark garnet
what do I do now
It's saying that hasPotionEffect cant be referenced from a static context
you need to use it on player instance
Mk
OH
I GET IT
thanks
was using player instead of playerWhoToggled
also this object name is horrible
no reason to be that long
but who cares
will this work?
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public final class Nvod extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("nv")){
if(sender instanceof Player){
Player playerWhoToggled = (Player) sender;
playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada.");
if(playerWhoToggled.hasPotionEffect(PotionEffectType.NIGHT_VISION)){
playerWhoToggled.remove();
}
}
}
return true;
}
}
if(command.getName().equalsIgnoreCase("nv") this part is not needed
if you register your executor properly
and no that wont work
i think that's the only way I can do it for now
whats the problem
just the command part
the only thing wrong that I can think off
what happens when a command is received
do this please
ok
first it gets if the command was sent or not
if it was sent, then get who sent it
and set night vision without particles, amplifier of 1
duration infinite
and send a nice message in chat
then?
wdym
oh
which is always true
also
else give
will that remove part work?
no
you need to check the exact method
for removing potion effects
google something like
spigot remove potion effect java
(or learn to use javadocs so you dont need to depend on forums)
I found this
i feel that
I think it worked
playerWhoToggled.removePotionEffect(PotionEffectType.NIGHT_VISION);
}```
if that was what I was doing wrong
then it will work ig
hey thanks for the reply! but I think there is a problem with the documentation according to people on git saying the we write from v12 to v13 is in the wrong order or broken up. they seem to have provided an answer but cannot make sense of it.......https://github.com/discordjs/guide/discussions/823
you found the correct method ye4s
now
how do I check if he doesn't have the potion effect
do I only put else at the end of the if statement?
or else if
do exactly the same thing but put a ! at the front
playerWhoToggled.removePotionEffect(PotionEffectType.NIGHT_VISION);
playerWhoToggled.sendMessage(ChatColor.RED + "Visão noturna desativada.");
}
playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada!");```
have a look at this
thats how it is now
i know its wrong
your removing the potion effect, then readding it?
if (haspotion) {
removepotion
sendmessage disabled
} else {
addpotion
sendmessage enabled
}
also id replace the number with Integer.maxvalue()
what number
the 2147 number
oh
the duration you mean
yeah i set it to the limit of an integer because they said on the forums that if you did that, the effect would last forever
yes, means you dont have to write out integer maxvalue every time you wanna use it
also it wouldnt last forever, but basically forever
it would last for around 60 years or something like that
also
will it make the code run faster?
because it isn't writing out 2 billion and shit
but just max value
this correct mah guy? ```if(command.getName().equalsIgnoreCase("nv")){
if(sender instanceof Player){
Player playerWhoToggled = (Player) sender;
if(playerWhoToggled.hasPotionEffect(PotionEffectType.NIGHT_VISION)){
playerWhoToggled.removePotionEffect(PotionEffectType.NIGHT_VISION);
playerWhoToggled.sendMessage(ChatColor.RED + "Visão noturna desativada.");
}else{
playerWhoToggled.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 2147483647, 1, false, false));
playerWhoToggled.sendMessage(ChatColor.GREEN + "Visão noturna ativada!");
}```
why is discord text formatting stupid today
yep quite correct
what a weird way to do your commandexecutor class
thats the only way i can do it for now though
the spigotmc forums has a tiny section of creating a command
the only thing left to do is add onEnable method and register the command
add the command to your plugin.yml, register the command in your onenable method in your main class and create a class that implements commandexecutor
cant believe im actually going somewhere with java
a few weeks ago i was like "the fuck is a variable"
now im here
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
should tell you everything you need to know to make a command and register it and stuff like that
look at that page i sent
scroll down
tho thanks for helping
it says how to register the command
no worries, was just giving some trial and error guidance, which im glad you figured out what the issue was.
yes
thats your own class
ah
that extends commandExecutor
getCommand() requires the command string, in this case it would be "nv"
the set executor is your command class, the class has to implement commandExecutor
i havent created a class that extends command executor (i wrote all this code in the main class basically)
ill have to do that ig
once you have it up proper
it will only send the one that you register
as in this.getCommand("kit").setExecutor(new CommandKit());
writting everything in your main class is the best way to have a mess of a plugin
you will only get the command kit
so the first part of your code checking if its nv
is not needed
if its set up properly
so for each command you will need a seperate command class
i usually call them all Command<CommandName> so like CommandAnvil for example
the ide is asking me to make the class that implements command executor abstract
do i have to
?
no
Class 'Nvod' must either be declared abstract or implement abstract method 'onCommand(CommandSender, Command, String, String[])' in 'CommandExecutor'
it should have an option for adding the onCommand method.
when you hover
now i just need to paste the code i wrote here right?
yeah of course
and you are done
make sure to return true
at the end
will stop it from sending the message "/nv" every time you send the command
register it
on your on enable
if you didnt already
and put it on your plugin.yml
so you guys can spot any errors that that I haven't seen k?
well if there are errors, more then likely it would spit them out before compile
anything unneeded
or something like that
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class NvodMain extends JavaPlugin {
@Override
public void onEnable() {
this.getCommand("nv").setExecutor(new Nvod());
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return true;
}
}
thats the main class
you can drop the on command
since its not needed in the main class anyore
thats legit it
