#help-development
1 messages Β· Page 2097 of 1
I would recommend making a custom gui system like hypixel skyblock if you have the time & knowledge
i was
LITERALLY
telling him how to
π
Hey majin mind helping with a basic thing
its alright he was just tring to help lol
sure wsp
nah its good
i prolly shouldve said
I switched to excellentcrates, to make the chest cost a key what do i add to this code
Cost:
MONEY: 0.0
EXP: 0.0
I wanna remove the money/exp
and add the cost of 1 key
so basically you should use a different crate plugin
Which do u recommend?
wait you dont need to edit the config for this
goldencrates renamed to excellentcrates for whatever reason
they should have a builtin editor gui, or atleast they did the last time i used it
Yeah but it only specifies money/exp to open the chest and i want them to use a key
I'll lay it out for you, not sure why this is so confusing.
A) Make a method that creates your custom crafting table (or make a custom crafting table class/wrapper if you choose)
B) Listen to PlayerInteractEvent for your crafting table, if you're worried about performance don't compare with stripColor or titles, it's really taxing.
C) I would probably make a 2d array of the section that you can use as a crafting section. Then listen in there for your recipe
D) If all the slots are filled for a recipe then put the item to craft in the Recipe Results Section
use the gui, im positive they have it
ok
ok can i just like explain this to him, hes using a workbench he doesnt need all of this
Well that's your best bet if you're making a custom crafting gui
But sure if you just want to add recipes that's fine aswell
if I can use the work bench one then id rather do that
cause it looks a lot better
ok
create your workbench gui
then listen to the inventoryclickevent
if the inventory isnt yours, return
Ok so dumb question
then loop through the items in the inventory (make sure to ignore the extra spots around it)
It gave me a tripwire_hook with nbt tags. How do i know what the ID is to give players
check if this order of items matches one of your custom item recipes
if it does, set the item in the result slot to the custom item
easy done
np
If you just want to do custom recipes, you can add custom recipes like so:
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("bangun"), banGun);
sr.shape(" ",
"DDD",
"S ");
sr.setIngredient('D', Material.DIAMOND);
sr.setIngredient('S', Material.STICK);
not what he wants
i mean i recommended that to him
is it really that easy?
it really is :P
even easier with just a normal inventory
^
cause then you dont need to mess with the shitty item slots of a workebnch
what if i want to create a recipe with specific slot
embed fail
wym
shaped recipe or something
like i only want the recipe to work if they are placed in the configured slot
well the way i explained this, it would work like this
if you werent worried about the order then you'd probably sort by hash (my guess)
huh! i didn't realize you could reference the slots from the general inventory object! good to know for the future. (friendly bystander here) :)
then just use an array of ints (array of the item hashes) as a key in a hashmap (ironic haha laugh)
this guy is cool
elaborate
When i created the key with the plugin it gave me a tripwire_hook with 3 nbt tags. Its a custom name called "votekey" how do i get the item id for that so that i can make it when players vote to give them that id
I agree. lol.
yeah, thats fair enough
never tried it, ill have to someday :D. that day ain't today
im still not following
what are you trying to do exactly
So im trying to reward players with the key from that plugin i made to give to players when they vote so they can open the chest
what vote plguin are you using
nuvotifier
and voting plugin
link
Its not the voting plugin thats the issue though
well you need the voting plugin to give the item in the first place
I just need to know how im able to get the key id
I already know how to give them the key
then whats the issue (sorry im just not understanding)
So.
would permissions be of use here? (legitamate question)
im pretty sure the key id is a form of anti-dupe
I got excellentcrates, which yes its goldencrates renamed. When i am in the GUI and created the crate, i also created the key in which it gave me in my inventory slot. I need to know the ID of the key so i can then input that and give it to players when they vote through votifier
id being the material id?
Yes but when it gave me the key it was named and everything.
the code in votingplugin is poop
like its really fkin bad
So you are not sure how to do so?
im not even sure if the plugin is capable of giving custom items
FYI, particles across a water barrier act really strange. i.e. looking into the water from abovfe when there are particles makes them invisible, and reverse for looking out of the water from in it. weird rendering issue that im not sure is fixable. lol. #BugsAreFun
How i check if path is String or List<String>
I have tried with path instaceof List<String> and im getting errors
For config?
Yup
There is FileConfiguration#get, it will return an Object, but you might as well make the path a list string
There's no need to make a path can have different object imo
What does send do?
Send the message of the path to player, but i need to first check if its either a String or List<String>
Why do you need to check that?
Because it could break?
So the config path can be a List<String> because you want to send a multiple messages, right?
is the PlayerInteractEvent the best event to listen for to detect when a player makes a path block with a shovel?
Wait i will explain
Test: "Just a string message"
List-Test:
- "Just a list string of message"
- "Just a list string of message"
So having that structure i need to able to send the player a message string when the path is String
Or if path is List<String> send it doing a foreach
What's the different about this?
test: "Just a string message"
list-test:
- "Just a string message"
Do i expΓ±ained?
It will send the same message
Hee?
I dont think im explaining what i need
:/
Oh let go again
player.sendMessage() doesnt allow me sending List<String>
I know what you mean
You can use a string list to send a single message
Instead making it complicated, you can make the path only a list string
You will choose when you configuring the yaml
Im just doing a lib
So if i only allow sending path of type String then he will want to send a path of type List<String> and it will explote
π€
Do i explained?
The config value is for sending a message right?
I'm saying you could receive the same result If you use only List<String>
You could check for the size of the List
Its possible to check the type or not?
Yes
We are over doing diff
When it easy
Its simply just check if type i list<string> or string and its done
π€
I dont know why its diff to explain it
Maybe because im not native english
I'm just saying I don't see why you want to do that
but anyways
Check with FileConfiguration#get, it will return an Object
Yes i know that
You can debug the Object type
But i dont know how to check if that object is string
Because getConfig()#get(path) instaceof List<String> doent work
You can debug it first to see
I completely understand you
So why are you confusing me?
If its simply to check using instaceof
π€ π€ π€ π€ π€
I told you to debug the class name so you'll know what to put on the instanceof
getStringList() == null
or
isEmpty()
getString == null
or
isEmpty()
if (getStringList() == null || isEmpty() {
getStringHere
}
we do you just dont understand what were trying to tell you
will getStringList return null or empty?
it returns one of the two i know
okay xd
will take someone 2 seconds to test it
afaik it will empty
i think so as well, but too lazy to confirm xD
The config path can either be String or List<String> so if check the path as List<String> and its a string it will explote, and viceversa will happen the same
i can check docs
Use instanceof ArrayList
Show the config your trying to iterate through
That what i was saying since i ask
I told you to debug the class type
The config will change depending the one who using the lib
So you'll know what to compare
Then show the 2 possibilites on where one is a string and one is a string list because
An actual path wont be a list
I only need to check if the path he is sending is a String send the player the string and if it a List<String> send each string to him
yes
Check if its a list or string first by checking isEmpty or is null
idk how this is that hard to understand...
HM
You dont use instanceof for this
I cannot check like that because they can leave empty list
HUM
π€
So will still explote
Then here
is !isList
its a string
Read the javadoc i sent
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
look
even a isString method
you can receive the same result without using instanceof
why are you determined to use instanceof
Because the all in line capabilities
if (config.isList("value.value")) {
config.getStringList("value.value");
} else if (config.isString("value.value")) {
config.getString("value.value"):
} else Bukkit.getLogger().info("Uh oh! Invalid confiuration detected");
or similar
that what i dont want
I want to use:
boolean ? is a string : is a List<String>
π
I dont want to much lines
Because the code looks harcoded
why can't you just do that then how you've described it
return isList("path");
or
boolean isList = config.isList("path");
your overcomplicating this so much
My method its a void
But that doesnt allow me to use:
getConfig().isList(path) ? getConfig().getStringList().forEach(player::sendMessage) : player.sendMessage(getConfig().getStrign(path));
of course you cant do that
as i told you, just use string list
Oh fuck i need yes something for void
you can send a single message with string list
List<String> list = config.isList("path") ? config.getStringList("path") : null;
if (list != null) list.forEach(player::sendMessage);
iirc
if isList is false, null list, if true return list from config
idk i dont really use ternarys all that much
thats what i told him 10 minutes ago
U told in a way that i didnt udnerstand
Consistency is good π
you could told me you dont understand so i will explain it more
but if he wants to make both ways seriously if it's just a string make a new list with 1 element
I told it many times
π π π π
Like 5-6 times
you keep saying it will explode
back to figuring out EliteMobs configuration
Now i find something else
Its possible to do:
send ("Message-Path", player, "{var-1}", var-1-value, "{var-2}", var-2-value)
I know that the vars, are just an Array
Does anyone know the secrets behind creating an invisible shield
Packets probably
Object[] placeholders = {"{name}", "alex", "{age}", 25};
Map<Object, Object> vars = IntStream.range(0, placeholders.length ).boxed().collect(Collectors.toMap(i -> placeholders[i], i -> placeholders[i++]));```
Why it print this:
alex : alex
{name} : {name}
25 : 25
{age} : {age}
When im doing i++ shouldnt be incremenedt, so it get the 1 value from the array ("alex")?
i++ increments after
i is a lambda parameter
well yeah but
It only exists in the scope of the lambda
Can you seriously stop trying to use streams and lambdas for everything
It's making your code much worse and you're making it our problem rather than just not using it unnecessarily
No
Because it's a lambda
All it does is return from the call
Effectively the same as a continue
If you want to, you can use takeWhile or allMatch
If you do allMatch then it will stop looping as soon as you return false
That being said, are lambdas necessary here?
interesting
its cleaner?
In this case it's really not
using a for loop seems a little robust
Just use a regular enhanced for loop
There's no benefit to forEach here especially since you need to be able to break the loop
i dont
seriousness is not an option
Wtf how do i remove this
Its a chest from a lootchest plugin i installed but its not on my server
Its invisible and wont go away. Any way to possibly fix this at all?
#help-server unless your questioning about java, send a pic of it too
!verify
Usage: !verify <forums username>
^ ty
Intellij: Hey you know this could be null right
Me: No, its checking for null already
IntelliJ: HEY DID YOU KNOW THIS COULD BE NULL
Searching for a math genius: y = cos(x) * sin(0.5x)Β² (need to know x). Ping me if you know the answer
finding x?
i dont think thats how algebra works
This isn't really a development question but more or less a grammar question:
Say I wanted to generate a random name for an item, what would be the best combination of verbs, adjectives, and nouns combination(s) to achieve this? (More or less I just need ideas)
Most I can really think of is:
Noun Adjective Verb
EG:
Dad demonic design
But, that doesn't necessarily sound right IMO LMFAO
x = 4 pi n
Thanks, but what is n?
My calculator can solve it too, I just need to know the steps
integer
?
Integer is number
this isnt a solvable equation
its just there
This is a function, not a solvable equation
its a number inside the Z numeric set (do you say it like that? idk)
Ok sure, but in reverse calculating y is so easy...
What is that? Never heard about
just 4 pi then
Oh, you wanna a x = equation?
y = 0 right?
Not in this case
mhm
Let's say, x is for example 45*
You need a value for y if you wanna solve it
what
What is y?
the y variable
do you know how math works
Yes
Sounds like some type of math homework/college homework question lmao
I am in secondary school, this is used in the haversine formula
x is given here
If you need x then y must be given
y is the problem...
well didnt you just say its 45
For example, if x = 45, then y = 0.10355...
And if this for example 0.10355, then I want to get x back, in this case 45
mhm i think that there are no reverse functions for that, but i'm not sure
WolframAlpha doesn't give a clear answer too
Any math solves doesn't give a clear answer
where did you get this from?
The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. Important in navigation, it is a special case of a more general formula in spherical trigonometry, the law of haversines, that relates the sides and angles of spherical triangles.
The first table of haversines in Engli...
It will if you constrain it [0, 2Ο) or whatever your preferred interval is
wish formatting wasnt so bad for math
is it this?
wait
i solved the inverse i think
shat
ok.
Btw for the lat I didn't have such function, I could easily solve it
But can't for the lon
If I am calculating the distance to the equator
Why does my server stop responding when I use the placePlotOnNextAvailable Method? Here is code and error: https://gist.github.com/ItzJustNico/3e1e4806a18d14161969ca0880b7dd6f
I'm not too sure on this bit it could be that in one of your loops you have "ii" as a variable. The problem with that is in that loop your using "i" as a variable. So what I think is happening is that instead of it using "ii" it is thinking you used "i" twice together. Which then equals 00. So I'd suggest changing "ii" to something else.
I would like to make a plugin with a skywars minigame that resets the map after every game, I plan on duplicating the world and sending the players to the duplicated world, once the game is over, I will delete the duplicated world. Is there a better way of approaching this?
I think I know what the problem is but I dont know how to fix it: the method blockOccupied is searching through json files and I am using the method way to often when going through the for loops so it stops responding. How do I fix that tho? https://gist.github.com/ItzJustNico/a8e3b3980479d38e93168a7e43051422
Server crashing because of iterating through Json files
is Vault safe to use on 1.18?
hey, i kinda need help
i tried to add a library to my project, but like i used the modules, added the library and so on... but rn, when i m trying to test the plugin this happens
oh wait i cant send a picture
ok so :
the error : package org.inventivetalent.bossbar does not exist
the way i implement it : ```java
import org.inventivetalent.bossbar.BossBar;
import org.inventivetalent.bossbar.BossBarAPI;
the code its used in : ```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (!gamehasstarted){
BossBar bossBar = BossBarAPI.addBar(player, // The receiver of the BossBar
new TextComponent("Hi " + player.getName() + "!"), // Displayed message
BossBarAPI.Color.BLUE, // Color of the bar
BossBarAPI.Style.NOTCHED_20, // Bar style
1.0f, // Progress (0.0 - 1.0)
20, // Timeout
2); // Timeout-interval
}
if anyone knows how to solve this, could you pls help?
fixed this, only happens when a server updates the plugin, sometimes the nbt data gets replaced by a 1b or byte for no reason lol
that is for these one
try using maven dependencies
<dependency>
<groupId>org.inventivetalent</groupId>
<artifactId>bossbarapi</artifactId>
<version>2.4.1</version>
</dependency>
paste this in the <dependencies> tag in your pom.xml
<repository>
<id>inventive-repo</id>
<url>https://repo.inventivetalent.org/content/groups/public/</url>
</repository>
and this in your <repositories> tag
np ^^
ye
and then the reposistory
then click the lil' button to reload
what do you mean. 1b is boolean true
yeah idk why it still receives illegalargument exception
do u know why it doesnt?
but the stacktrace tells the error
since It stores string, the data sometimes gets converted to 1b which is also a bool
bro stop
i m just asking for help
i did lmao
i just dk how this thing works
bro
i did 1 error and now u are like always making fun of it
ima just ignore u lmao
i did
but imma just not listen to u
the others are way nicer (:
Yes why
if u tell me to change i CANT
and how do i not depend on the local jar
k wait 5sec
well, i get an other error and that one is cuz im using the bossbar library
but if i dont lemme check
.
when i compile it i get that
i added it as a dependency yes
look at the pom i sent u
nope thats the whole error
when i try reloading the maven
i gtg get some food rn brb
Use version 2.4.3-SNAPSHOT
GUYS
I'VE FINALLY DONE IT
I'VE BECOME A PIG!!!
I am literally the pig
I'm not just invisible and over the pig or something
I don't know what I did
I can't move
I sent a packet to spawn in a new entity with an entity id of myself
there seems to be no option to set meta data
there's this method but that was deprecated in 1.15
metadata is its own packet π€
I see
I want to spawn fake players
npcs
I wanted to do it with packets so I could avoid nms and make cross version
but then again the packets aren't fully cross version anyway
Well generally, the server internally just has an ever incrementing counter
which you would just have to get and increment
to "reserve" your id
can anyone help me in my thread pls?
Wdym
write a minimal reproduction example
and then basically report it
however iirc this is already partially known
That make sense
This is the "I write stuff to yaml, get it back from yaml and string is byte" issue right ?
Similar to that, mine happens to a pdc
Yea this is PDC to Yaml uglyness
urgh we should have just never made this human readable and just base64 it
if you want to save yourself some trouble right now, don't store "true" or "false" as a string for now
Yeah but I kept it for the sake of keeping players items, especially if they have other progress inside them or datasets
I mean, generally the conversion to yaml works
just the "true" and "false" string values are an issue
Correct
Yeah if i get to receive more git issues regarding it, I'll set it to 0 and 1 instead
I'll let it sit for now
Since other server already got this temp fix for which they said works well π€·ββοΈ
Appreciate the feedback, atleast I thought this thing is unknown
Generally, I would suggest moving to a 0 and 1 byte
and yea, it is just pain to fix
Best way to store massive amounts of player data locally?
A db would suit that well as long as u do it async
You got it right from this link
Yea, welp, you can comment under the issue if you want to bump it (idk the spigot policies or if this is wanted)
but besides that, eeek not much
Status is open, might bump it later
How can i make 1.18.2 plugins on Intellij? Minecraft development it says latest version is 1.18.1
Just manually set the spigot-api version on maven to 1.18.2
Got it ty
What's the best way to create a cooldown system for a rewards plugin? Like reward can only be claimed once every 24 hours.
Looking for a developer! Please message me. Simple task and willing to pay!
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation());
``` How would i set the damage for that particular bolt to be 0?
i was thinking alone the lines
```java
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation()).getLastDamageCause().setDamage(0)
But am not sure if last damage cause would be that strike
?docs
youll probs have to do a listener for it
?docs
?jd
thanks
How do I get all keys under a specific key in a config?
you can get the configuration section
How do I get the ConfigurationSection?
YamlConfiguration#getConfigurationSection
I see, thanks!
what command api do yall recommend
How do i use the spigot api?
Like all my methods are based off bukkit api
lol
spigot api extends bukkit api doesnt it
Where is my placeBlockStartLocation getting changed??
System.out.println(placeBlockStartLocation);
int squareSize = 5;
Location placeLocation = placeBlockStartLocation;
for (int i = 0; i <= squareSize; i++) {
placeLocation.setX(placeBlockStartLocation.clone().getX() + i);
System.out.println(i);
System.out.println(placeLocation);
System.out.println(placeBlockStartLocation);
placeLocation.getBlock().setType(material);
}
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-282.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: 0
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-282.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-282.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: 1
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-281.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-281.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: 2
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-279.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-279.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: 3
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-276.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
[14:30:07] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=-276.0,y=69.0,z=775.0,pitch=0.0,yaw=0.0}
and updates it
well when i try do java strikeLightning(Location loc, boolean isSilent) as stated in the docs it says 'strikeLightningEffect(org.bukkit.Location)' in 'org.bukkit.World' cannot be applied to '(org.bukkit.Location, boolean)'
Location placeLocation = placeBlockStartLocation;
you need to clone it
its currently a reference to the same object
and you dont need that clone in the loop as its just a getter
ohhh okay thanks
yeah was just getting confused where its was coming from
i use my own
it is in wlib
you can see it in my github which is in my profile
y=69
UWU


hehe
How can i fix this issue?
simp
coincidenceπ€
Anyone got experience with Mockito and getting the mockStatic to work?
there is no such thing
the better way for him was just to add(0, 1, 0)
also
.setCustomName("Bolt");
}
}
}
@EventHandler
public void damage(EntityDamageEvent event){
if(EntityDamageEvent.DamageCause.LIGHTNING.name().equals("Bolt")){
event.setDamage(0);
}```
:) that helps alot lol
Ikr brain time
strikeLightingEffect without the boolean
well when i trigger the event in game i can't hear anything?
wdym
wait i thought it would play a sound
would i need to get close entities then play a sound?
u good?
you dont want sounds?
yeah but what r u doing
cancelling the damage of that lighning
then you need to use packets to spawn only the lighting
without sounds
i guess
no it works dw
Anyone know how to save an arraylist to config.yml?
use the set()
There is a method for that in the API
World#strikeLightningEffect iirc
i think he dont want sounds
return timer.getOrDefault(p.getUniqueId(), 0) != 0;
}``` if player's timer isnt 0 it should return true?
of bossbar? doesnt exist
I think using Map#containsKey is better
public class CustomMob extends PathfinderMob {
public CustomMob(Location loc, EntityType type, float maxHealth, float damage, double speed, String displayName, double followRange) {
super(type, ((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
this.setCanPickUpLoot(false);
this.setAggressive(true);
this.setCustomNameVisible(true);
if(this.getBukkitEntity() instanceof LivingEntity) {
LivingEntity entity = (LivingEntity) this.getBukkitEntity();
entity.setMaxHealth(maxHealth);
this.setHealth(maxHealth);
entity.setRemoveWhenFarAway(false);
entity.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(damage);
entity.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(followRange);
if(speed > 0) {
entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(speed);
}
}
this.setCustomName(new TextComponent(ChatColor.GREEN + displayName +ChatColor.RED + " " + (int) this.getHealth() + "/" + (int) this.getMaxHealth()));
this.persist = true;
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new FloatGoal(this));
this.goalSelector.addGoal(2, new LookAtPlayerGoal(this, ServerPlayer.class, 4.0F));
this.goalSelector.addGoal(3, new MeleeAttackGoal(this, 1.0D, true));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<ServerPlayer>(this, ServerPlayer.class, true));
this.goalSelector.addGoal(5, new MoveTowardsRestrictionGoal(this, 1.0D));
}
}
I made a custom mob here and I created a list where it spawns everytime it dies but when I leave the world then come back they seem to duplicate, any1 knows why?
not what i was asking
yes it should return true if the value is not 0
thanks
maybe you are spawning 2 mobs?
Nope, They only seem to come after I have left the world for a while then come back
which mob are you using
When i want to send packets for npc's with mojang remapped i keep on getting this error:
java.lang.ClassNotFoundException: net.minecraft.world.entity.player.Player
And this is how i send packets:
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
connection.send(new ClientboundAddPlayerPacket(npc));
Could someone please help me?
bruh mojang remapped looks so nice
Should I run socket litener on demon thread?
I got custom messaging channel for some data between servers
So is it ok just to run socket listener on async thread
yeah run it async otherwise server go boom
Or run it on demonthread
can you help me though?
@echo basalt I know u can't run it on main thread because it would block
you're probably using the remapped version of your plugin
I never really messed with remapping
Question is just do I make new runnable and run it async
Or I make demonthread
And run it there
just a regular thread
a daemon thread has a lower priority and will die if other threads are done
is there a quick way to send minimessage messages without deserializing and serializing?
paper has a sendMessage(component)
im tryna do it in logger
logger?????
i wanna log colored stuff
It does
...
Hello, how can I make my plugin support NBT or "custom items" as my players define it?
A little bit of a difference between custom items and full NBT support
I'd hate to interrupt, but would anyone know how you can check if a player has a data file in a world, or has played in a world before?
Well I asked them and they simply want custom items support(for example supporting McMMO items), I'm not really sure how to add that. My plugin uses bukkit's serialization to save items to yml files(soon switching to GSON), what am I supposed to do differently?
The spigot yaml configuration does not really support configuring custom NBT data
How would I make a loop to check if a specific structure was built by a player?
some sort of 3d array then just checking if the block isn't air?
Any interactions with NBT on your end will require NMS usage
I found a cross version NBT library so that wouldn't be a problem
The question is what exactly I'm supposed to save
my support requests are starting to sound so weird you'd think I'm making them up
I guess I'm an idol now
i would use worldedit
load a schematic
and check if the schematic fits in where the player interacted
._. alright i guess
hey so i m trying to display the player a bossbar using this :
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
BossBar bossBar = BossBarAPI.addBar(player, // The receiver of the BossBar
new TextComponent("Hi " + player.getName() + "!"), // Displayed message
BossBarAPI.Color.BLUE, // Color of the bar
BossBarAPI.Style.NOTCHED_20, // Bar style
1.0f, // Progress (0.0 - 1.0)
20, // Timeout
2); // Timeout-interval
but when i try it, when i join the game, the server gives me an error :
[14:19:51 ERROR]: Could not pass event PlayerJoinEvent to VampireUhc v1.0-SNAPSHOT
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:298) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:157)
at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:814) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:397) ~[server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:123) ~[server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.scheduler.BukkitRunnable.runTaskTimer(BukkitRunnable.java:100) ~[server.jar:git-Spigot-21fe707-741a1bd]
at org.inventivetalent.bossbar.EntityBossBar.<init>(EntityBossBar.java:54) ~[?:?]
at org.inventivetalent.bossbar.BossBarAPI.setMessage(BossBarAPI.java:267) ~[?:?]
at org.inventivetalent.bossbar.BossBarAPI.setMessage(BossBarAPI.java:247) ~[?:?]
at org.inventivetalent.bossbar.BossBarAPI.addBar(BossBarAPI.java:158) ~[?:?]
```
at com.vampireuhc.vampireuhc.VampireUhc.onPlayerJoin(VampireUhc.java:275) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_312]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_312]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_312]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_312]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-21fe707-741a1bd]
anyone knows whats wrong?
Use pastebin jeez
yeah sorry
you probably have to initialise BossBarAPI with your plugin instance
wdym?
u mean register it in the pom.xml?
No, it looks like the bar api is trying to register a timer task to update the bossbar
but fails to do so
hm yeah but why does it do that
it seems like the bossbar is depending on https://www.spigotmc.org/resources/api-apimanager.19738/
u sure? cuz like what u sent is for 1.16 but the one i have is for 1.8.8
APIManager
This API is compatible with APIManger.
Click here for information on how to implement it.
You basically want to follow
If you are making a Plugin with dependencies:
Make sure the API you depend on supports APIManager In your plugin's onLoad method call APIManager#require with the API class you require and your plugin instance In the onEnable method call APIManager#initAPI with the required API class Add the plugin name of the required API to softdepend in your plugin.yml You successfully added an API dependency! (Repeat steps 2-4 for all APIs your plugin depends on.) Finally just compile all of the required API classes with your plugin. Maven is the easiest way to do so.
i get a 404 error
yea
you are using a legacy af plugin
for a legacy af version
tbf the version is more legacy than the plugin but still
yeah ik but i dont have a choice
I mean follow what I pasted above
yeah but i cant find the spigot api for my version
Hello.
yeah but the thing is
But I would guess you do something like
APIManager.require(BossBarAPI.class);
they say i need tidepend on supports APIManager
APIManager seems like such a random thing to depend on for them lol
does BossBarAPI not provide it ?
Yeah that's what I mean, seems like an example of over using libraries lol
like as a transitive dependency
ah
okay
wait
no that should actually work
what is the error
oh
you need to also pass your plugin instance
e.g. require(BossBarAPI.class, this)
where do u put that exactly?
their wiki says onLoad
and then APIManager.initAPI(BossBarAPI.class) in your onEnable
imagine if all this BS could be skipped by just not coding libs that abuse static state π
Could also be avoided by developing in latest where Spigot has a built-in BossBar API lol
Is there a non-depreciated way to get an OfflinePlayer by name?
tho tbf the lib is pretty old. Inventivetalent is pretty cool
making a uhc (vampire hunters uhc) so yeah
If i have multiple Diamond itemStacks in a player inventory adding up to 100 or more, does calling player.getInventory().removeItem(new ItemStack(Material.DIAMOND,100)); remove exactly 100 diamonds?
it should ye
?tryandsee
How can I make raycasting with vectors? I tried a few things, like add 1 in a loop to a clone of the player's position, but that didn't work.
Yeah but I want to get all the location between the player and the target to spawn particles
Well then yea, define your line at which you spawn the particles as a point of origin and a unit vector
divide the vector by the amount of particles you want to spawn then do a for(i=0;i<desired;i++), then add to a location object the unit vector in that loop and spawn a particle at the location object
I've done the exact same thing before one sec
^^
ok thanks
dragVector = dragVector.multiply(1.0/precisionA);
for(int vI = 0; vI<precisionA;vI++){
world.spawnParticle(Particle.DUST_COLOR_TRANSITION,edges[i].clone().subtract(dragVector.clone().multiply(vI)),volume, particle);
}
something like that
https://pastebin.com/wtGqJtNx does anybody know why the scoreboard isn't updating the values? (i put it in pastebin cause it was too long)
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.
I tried that and it didn't wok:
Vector currentPlayerVector = player.getLocation().getDirection();
currentPlayerVector.add(new Vector(player.getLocation().getX(),player.getEyeHeight()+player.getLocation().getY(),player.getLocation().getZ()));
Vector vector = currentPlayerVector.clone().multiply(1.0/10);
for (int i = 0;i<10;i++){
player.getWorld().spawnParticle(Particle.ASH,player.getLocation().clone().subtract(vector.clone().multiply(i)),10);
}
Sry if i made a stupid mistake, i am very new to vector programming
whta
it started disabling plugins
but ran into errors
it should still continue shutting down
It stops automatically
Just so you know that's a cracked (offline mode) server
??
the algorithm is as follows.
- Store the starting location of the line you want to draw/ray you want to draw
- Get the direction of the line from that origin, (I guess player direction)
Vector start = ...;
Vector end = ...;
double density = ...; // distance between points, 0.1 makes a thicc line
Vector difference = start.clone().subtract(end).normalize().multiply(density);
Vector current = start.clone();
double distance = start.distance(end);
for(double index = 0; index <= distance; index += density) {
current.add(difference)
...
}
well
pretty much xD
If you abuse the fact that Locations are mutable too you can avoid allocation a new location every iteration
that's kinda what I'm doing
Ye but with vectors
which I don't think the API accepts as parameter for particle spawning
vector.toLocation(world)
Yea but that allocates a location
vector programming isn't hard
every iteration
vector math is fun
you can make satanic cows with vectors and some particles
then you combine that with pathfinders and make those cows shoot fireballs :)

math
make a pentagon
but instead of drawing lines between each point
draw it between point and point+2
Is that plugins
I'd hope so π
So do I have to spawn the particles on the location from the current vector?
yes
It doesn't work. I outprinted the location:
Location{world=CraftWorld{name=world},x=NaN,y=NaN,z=NaN,pitch=0.0,yaw=0.0}
I've never seen something like this before
@echo basalt
How would I get plugin? like should i make a return method
public Plugin getThisPlugin(){
return this;
}```
i tried this is my main class but it's not picking up this method in other classes
for other classes to be able to call that method they'd require an instance of your main class
at which point, that method becomes useless
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
^^ see how to pass your plugin instance to other objects on creation using dependency injection
Thanks ^^
Well
i recommend u to learn java
theres a similar method if u get annoyed by di
instance;
instance = this;
static JavaPlugin getInstance() { return instance; }
Right
yeee forgot basic oop lol
well ppl dont usually forget that so i assume you never knew it
Ye my bad :(
dunno if still relevant but you add a direction vector to a position vector. That doesnt work. I'd recommend doing Vector currentPlayerVector = player.getEyeLocation(), you would have to check if the direction is included.
If not, DON'T add the direction vector, you have to do vector#setDirection(directionVector)
they are both vectors, but their purpose is completely different; adding them together doesnt work
ok thanks
ItemStack e = new ItemStack(Material.STAINED_GLASS_PANE, DyeColor.GRAY.getData());
gui.setItem(1, e);
gui.setItem(2, e);
``` can i set multiple slots at once instead of doing this?
Ig just loop the indices you wanna set
I canβt login to my spigot side .. only if I change the password every time ππ
hey, so i m using BossBarApi to create a bossbar in 1.8.8 but i m having trouble with like getting the health to go down. here is my code :
public float a
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
BossBar bossBar = BossBarAPI.addBar(player, // The receiver of the BossBar
new TextComponent("Hi " + "!"), // Displayed message
BossBarAPI.Color.BLUE, // Color of the bar
BossBarAPI.Style.NOTCHED_20, // Bar style
1f, // Progress (0.0 - 1.0)
20, // Timeout
2); // Timeout-interval
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
while (a >= 0) {
bossBar.setProgress((float) a);
a = (float) (a-0.1);
Bukkit.broadcastMessage(String.valueOf(a));
}
}
}, 20L, 20L);
}
so the bossbar was acting strange so i decided to send in chat "a" to see the progress and here is what i see :
i want to see wmth like 1 then 0.9 then 0.8 and so on
not sure but might be worth a try
nope
why not working with a double?
lol dont combine floats with doubles
ik but the double alone didnt work so
imma just try
with double alone or with the 0.1f still same thing in chat
why are you even casting a float to a float
if i dont it gives me an error
oh
np
no
that? i was just trying things
i tried doing that too ```java
public float a = 1;
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
BossBar bossBar = BossBarAPI.addBar(player, // The receiver of the BossBar
new TextComponent("Hi " + "!"), // Displayed message
BossBarAPI.Color.BLUE, // Color of the bar
BossBarAPI.Style.NOTCHED_20, // Bar style
1f, // Progress (0.0 - 1.0)
20, // Timeout
2); // Timeout-interval
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
while (a >= 0) {
bossBar.setProgress( a);
a = (float) (a-0.1);
Bukkit.broadcastMessage(String.valueOf(a));
}
}
}, 20L, 20L);
}
new BukkitRunnable(){
Location loc = player.getLocation();
double t = 1;
double r = 3;
public void run(){
t = t + Math.PI/16;
double x = r*Math.cos(t);
double y = 1;
double z = r*Math.sin(t);
Particle.DustTransition dustTransition = new Particle.DustTransition(Color.fromRGB(255, 0, 0), Color.fromRGB(255, 255, 255), 1.0F);
player.getWorld().spawnParticle(Particle.DUST_COLOR_TRANSITION, player.getLocation().add(x, y, z), 10, dustTransition);
player.getLocation().subtract(x, y, z);
}
}.runTaskTimer(plugin, 0, 1);
How can I make it so there is less space between the particles?
rotate less at a time
it uses one field for every player so after one player has ever joined the server it wont show again i think
it only resets on server restarts
so maybe bring the float into the method
right ty ty
Hello, has anyone experienced before when a plugin succesfully launches, shows in the /pl, but doesn't access any commands?
you just didnt register the commands
what do you mean by accessing commands
keeping in mind that weirdly enough it had worked before, after the restart it didn't work
errors?
just poof, i try to do any command, and they aren't working
also here's a pro tip you can get rotation calculations using the vector operators in the spigot api, you don't actually have to rotate thigns yourself
I have never worked with vector operators :(
oh wow look at the calendar
The commands worked before, server restarted, and then not anymore
recommended though
wait are vector operators built into java or a spigot thing?
both, you want to look at the spigot ones specifically in this case
mhm ye that would make sense
how do I execute a console command with the player's name in it, but not send the player a message?
how do i set a golden apple itemstack with itemdata 1?
ex: I don't want it to say "Given 1 grass_block to player"
what's the method to creating a tablist with rotating colors, I tried with this ```java
StringBuilder sb = new StringBuilder(servername);
Main.instance.getProxy().getScheduler().schedule(Main.instance, new Runnable() {
@Override
public void run() {
for (int i=0;i<servername.toCharArray().length;i++) {
sb.insert(i, "&c");
if (i==servername.toCharArray().length) {
i=0;
sb.insert(i, "&f");
}
}
}
},0, 1, TimeUnit.SECONDS);``` but it doesn't work
that won't be the output but still
Yeah i'm turning it into a char[] to get the length so I can insert a color at each char java String servername = "MC.PTCOMMUNITY.NET";
i'll use String.length then
π€
i'll watch a tutorial
what's the flag to get the remapped server.jar again?
--remapped
How do I execute a console command with the player's name in it, but not send the player a message?
gpg: skipped "2Hex gmail@gmail.com": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
i fucking have a secret key
im tryna set it up with intellij
but the option disappeared
from settings
it was there months ago
nothing like that
Why are the custom events of my api plugin ran on plugin 1 only handled by plugin 1 listeners?
and ran on plugin 2 only handled by plugin 2
Is there anything special I should know about spigot APIs?
it isnt listened by other plugins
i think I made something wrong
I called the event by the java class in plugin 1, not by RegisteredServiceProvider, might this be the reason?
``@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
if (!(event.getDamager() instanceof TNTPrimed)) {
return;
}
World w = Bukkit.getServer().getWorld(Main.plugin.getConfig().getString("Spawn.World"));
if (Join.game.contains(event.getEntity().getName()) && event.getEntity().getWorld().equals(w)) {
event.setCancelled(false);
}
}
}``
why the code is not working? it is supossed to allow explosions damage if the player if on the world defined in config and has the game variable in them and the damager is a primedtnt
but when i test it the damage is cancelled
and i 100% sure there are no other plugins other than my own cancelling the event
i know because i unload plugins one by one
put some debug messages in there and see which conditions aren't being met
Might be stupid by me but can it be the exclamation marks?
``@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player)) {
Bukkit.getConsoleSender().sendMessage("Entity Damaged is not a player");
return;
}
if (!(event.getDamager() instanceof TNTPrimed)) {
Bukkit.getConsoleSender().sendMessage("Damager is not a tnt");
return;
}
if (!Join.game.contains(event.getEntity().getName())) {
Bukkit.getConsoleSender().sendMessage("Player are not in game");
return;
}
World w = Bukkit.getServer().getWorld(Main.plugin.getConfig().getString("Spawn.World"));
if (!event.getEntity().getWorld().equals(w)) {
Bukkit.getConsoleSender().sendMessage("The world are not kitpvp world");
return;
}
event.setCancelled(false);
Bukkit.getConsoleSender().sendMessage("TNT DAMAGES GETS UNCANCELLED");
}
}``
like this?
that works
eventsLibrary = getPlugin(EventsLibrary.class);
any idea why this throws a ClassCastException?
in another plugin it works
I think you need to pass in the plugin name
so it included the api in the end plugin
Hi, I'm trying to code a plugin that duplicates a world and deletes it after the game played there is over
I'm running this on a server that has 1GB ram and it keeps running out of memory
Am I doing something wrong or is it just heavy? (version 1.18.2)
Because up until now, the server was running survival and some plugins pretty nicely
Is there any way to call a new BlockBreakEvent?
To where itβll also be listened to listeners
Bukkit.getPluginManager().callEvent
yes
Okay cool Iβll try that
allocate at least 2
4 tends to be enough for a test server
how do i make an anvil inventory that people can use?
how can i cancel player commands
gpg: skipped "2Hex gmail@gmail.com": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
i fucking have a secret key
im tryna set it up with intellij
but the option disappeared
from settings
it was there months ago
using CommandPreprocessEvent or CommandSendEvent?
preprocess prob
The first
thank you
?paste
done
and its still like that
javac -version and java -version
says 17.0.1
and your java home points to the correct spot
I mean, generally update the JAVA_HOME
I did its java 11
no go for java 17
you have jre 17 ?
this is weird af
very confusing
ye
is Bukkit.getServer().shutdown(); a safe way to shutdown a server?
Yes
allright thanks.
how do i check if enchanted book is sharpness 2?
You're trying to target Java 11 but it's building using an older version
declaration: package: org.bukkit.inventory.meta, interface: EnchantmentStorageMeta
Hello. Trying to make a plugin following this guide https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-vs-code/. Should I remove the pre-generated content in pom.xml or just add to what is in the guide?
I highly recommend using a proper java IDE instead of vscode
witch do you reccomend?
Intellij
https://www.jetbrains.com/idea/download/#section=windows
Download the community edition
Anyways if you want to continue with vscode just replace and modify the contents of the pom
Do I leave plugins in pom?
Actually it doesn't really matter which IDE you choose for that step since you're working with maven
No delete everything and use the one from the example
okay thanks
What does it mean by From "MAVEN PROJECTS" pane, right click "BlankPlugin" and select "install" from the menu.
Are you still using vscode?
18.04 22:23:40 [Server] Server thread/WARN Legacy plugin FireWars v0.1 does not specify an api-version.
18.04 22:23:40 [Server] Server thread/ERROR Could not load 'plugins/FireWars-1.0-SNAPSHOT.jar' in folder 'plugins'
``` this happens upon loading of my plugin. How do I fix this
you're importing a legacy deprecated class
or
you dont specify an api-version in the plugin.yml
which it says
would I just do api-version: 1.18?
did that. now I just get a [Server] Server thread/ERROR Could not load 'plugins/FireWars-1.0-SNAPSHOT.jar' in folder 'plugins' error
Oh wait im dumb
?paste
nvm i figured it out
Just added a database to my plugin and was wondering how to make it so that instead of writing to the database it would instead cache it and later on add it to the database. How do you do this. Im using mongodb. TIA
hey guys, trying to make a little thing that stops entitys/mobs from burning. thought itd be easy and its turned out to be a pain in the butt. this is what i have and it doesnt work at all
package mobsdontburn.mobsdontburn;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class MobsDontBurn extends JavaPlugin implements Listener {
@Override
public void onEnable() {
System.out.print("Mobs Don't Burn has enabled.");
}
@Override
public void onDisable() {
System.out.print("Mobs Don't Burn has disabled.");
}
@EventHandler
public void onCombust(EntityCombustEvent event) {
event.setCancelled(true);
}
}
Register your listener
i thought you didnt have to do that if it was the same class
Nope
You need it
I mean, you register any listener you want to listen to events
in this case, your main class extends Listener
so you register it
Since @EventListener only hint listener annotation processor that you want to handle this event via annotated method
But processor doesnt know exactly what annotations to process if you dont specify class or object instance
You're thinking of commands
All commands registered by your plugin will, by default, route through JavaPlugin#onCommand() as it's a CommandExecutor
Would I just put all the info into a hashmap and if so how would I do that