#help-development
1 messages · Page 1760 of 1
you did not understand what I want to do
I don't want to read/load group name from file
Ok now how do I turn these into an NBTCompound?
I mean
you probably can't turn them into a compound
and actually that means you don't need to parse the values on the right, as NBTBoolean doesn't exist
so just use an NBT string
is there a way to let mobs spawn outside of the world border?
no
Actually I need to turn them into a map apparently
And I have an idea of how to do that
If the border is small, you might be able to make a client-side small border and the real border be big
Is there a way to convert a Map<String, String> into an NBTCompound?
<<<>>>????!?@?!@?!
you create a compound, iterate over map entry set and do Compound.put(key, value)
that makes sense
i googled and i found out i can use packet borders to make borders only for players
so i will try to use that
Yeah that's what I meant
How can I get the TPS of the server?
/tps
I mean in code 🤦
literally just look at what they give you when you execute the /tps command
eh hi Coll
Hi
It worked thx
Paper has getTPS btw 🙂
MD is coming for you
Bro, I use Spigot
Well, another reason to move...
How can I make it?
what
get the TPS
public MongoClient mongoClient;
public MongoDatabase db;
public MongoCollection<Document> history;
@Override
public void onEnable() {
getCommand("cmd").setExecutor(new Cmd(this));
initMongo();
}
private void initMongo() {
mongoClient = MongoClients.create();
db = mongoClient.getDatabase("PunishmentHistory");
history = db.getCollection("StaffHistory");
}
}```
https://hastebin.de/huyivukaqi.properties - anyone know why I am getting this error?
I have never had this issue when working with discord bots, all the sudden I try using mongo with spigot and I get that
how do i prevent this message?
How can I get the TPS with code? I have for one entire class space.
CraftServer.recentTps or something
Dont work
Dont work
hey , i am wondering if there's devs that are willing to work on my server with me, am looking for someone that would help me build the network and keep working together in the long run and benefit together
||i cant afford paying that much right now but am willing to once the server is working well||
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/
How do I convert chunk relative coords to global coords?
wdym
I have some coords in a chunk (15,67,12 for example) and I need them to be global coords (243,67,402)
Because chunks have their own coords
multiple the chunk cords by 16 and add relative cords
Oml tysm
this is global to chunk
chunk.getBlock(Integer.parseInt(data[0]) & 0b1111,
Integer.parseInt(data[1]), Integer.parseInt(data[2]) & 0b1111))
Thats alot more confusing than chunk coords * 16 + relative coords
that's a strange syntax to do coords to chunk coords calculation
its just
relative -> chunk
x & 0b1111
y
z & 0b1111```
oh
im not normal
bitwise is not my stuff
<< 4 is for nERdS
yeah x & 0b1111 and x << 4 is basically the same, isn't it?
i dunno 🥺
I also don't know, I just assumed it 😄
because if it's not the same, it wouldn't make sense that it works 😄
[19:05:16 INFO]: [LcraftAPI] Enabling LcraftAPI v1.0.0
[19:05:17 INFO]: [LcraftAPI] The Spigot Module Lcraft Languages API will be loaded.
[19:05:17 INFO]: [LcraftAPI] The Spigot Module Lcraft Languages API is loaded.
[19:05:17 INFO]: [LcraftAPI] The Spigot Module Lcraft Permissions API will be loaded.
[19:05:17 ERROR]: Error occurred while enabling LcraftAPI v1.0.0 (Is it up to date?)
java.lang.NoClassDefFoundError: de/lcraft/apis/languages/utils/spigot/ModuleCommand
at de.lcraft.apis.permissions.main.spigot.ModuleMain.onLoad(ModuleMain.java:15) ~[?:?]
at de.lcraft.api.plugin.modules.minecraft.spigot.ModuleLoader.loadModule(ModuleLoader.java:15) ~[LcraftAPI.API-1.0.0.jar:?]
at de.lcraft.api.plugin.modules.minecraft.spigot.ModuleManager.loadModule(ModuleManager.java:76) ~[LcraftAPI.API-1.0.0.jar:?]
at de.lcraft.api.plugin.modules.minecraft.spigot.ModuleManager.loadModules(ModuleManager.java:27) ~[LcraftAPI.API-1.0.0.jar:?]
at de.lcraft.api.plugin.main.spigot.APIPluginMain.onEnable(APIPluginMain.java:24) ~[LcraftAPI.API-1.0.0.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Purpur-1393]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Purpur-1393]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Purpur-1393]```
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Purpur-1393]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:727) ~[patched_1.17.1.jar:git-Purpur-1393]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:318) ~[patched_1.17.1.jar:git-Purpur-1393]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1216) ~[patched_1.17.1.jar:git-Purpur-1393]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[patched_1.17.1.jar:git-Purpur-1393]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: de.lcraft.apis.languages.utils.spigot.ModuleCommand
at java.net.URLClassLoader.findClass(URLClassLoader.java:433) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:586) ~[?:?]
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:852) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
... 15 more
[19:05:17 INFO]: [LcraftAPI] Disabling LcraftAPI v1.0.0
I have made an API(https://github.com/Lcraft-Developers/Lcraft-APIs), but it dont works.
Does anyone know why?
java.lang.ClassNotFoundException:
the class exists
In jar?
I made 3 APIs
- Lcraft API
- Lcraft Permissions API
- Lcraft Languages API
But when I use in my Test Module the Permissions and Languages API the main api says, he dont know these...
I dont want to implement the Permissions API and Languages API to the Main API, because in future it will be
more apis.
Does the jar contains ModuleCommand class?
how can i use worldborder with packets? so that i can make individual borders for players
No, because I use maven
But its not public maven reposetorys
thats it
Even with maven you should shade classes you use LoL
uhh
https://pastebin.com/Lxm4rUKy
Why it isnt working when i go to the cords that were set in main-lobby.safezones?(im sure the Doubles are fine cause i got an output with a sendmessage and the values were true.)
Bruh use pastebin for all that code
it takes the whole screen you just hide previous messages
use a BoundingBox, then you can simply call .contains
Bruh, set location variablr
Why are you using Double and not double
is there any differents ?
oops
a double is a primittive and will nto accept null.
it will better show if your config is working
hm i'll edit that
double is a primitive type, while Double is a class wrapper for double.
btw what should i do for fixing my problem :
Since double is primitive, its default value will be 0. On the other hand, Double variables are objects, so their default value will be null
use a BoundingBox to check locations like you want
new BoundingBox(x,y,z,x1,y1,z1)
This also applies to other primitives and their respective class wrappers:
• int and Integer
• long and Long
• float and Float
• boolean and Boolean
thanks for the details.
Don’t forget Short and short and Character and char
Ya
chars are totally useless for me atleast.
i never used them
How can I upload a maven repository?
I rarely use this so I didn't write
i never use it lol
char is useful when you work with string.toCharArray
probably
sure
is looping through all players and checking if they have a permission a heavy operation?
no
depends how many players
like 20 so probably no
then no
pretty sure you wouldnt get more than 200 players on a single server
Even then it’s probably not that significant
probably not, so long as its not repeatedly. Its just a lookup
my problem isnt fixed yet...
errors?
are you now using doubles?
yes
then it should be working, if you checked it 🙂
no, you shoudl change to a BoundingBox so you don;t need to know whether its > or <
you just call if (box.contains(location.toVector()))
are you sure?
Nope random guess. I thought it looked pretty
how do i get the player who throws the xp bottle in expbottleevent
How do I transform a String like this [Kiwi, Banana, Strawberry] into a list of String like this ?
Fruits:
- Kiwi
- Banana
- Strawberry
expBottle is a projectile, you getShooter()
how
Projectile#getShooter()
there is no .getShooter in the event
``` like this?
Did they say Event#getShooter?
bruh .getShooter isn't a method from your event
exactly
so how do i get the person throwing it
.
Projectile#getShooter()
um how to use it
yes, but clean it up so its readable
whts #
!learnjava
um
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Method#class
So when someone writes Projectile#getShooter() it means the method getShooter() comes from the class Projectile
what should i put the location
it should be player location?
Look at the javadoc for your event and it will become clear
Yes, its the location you want to see if its inside that box
Any idea? Because I have a String with player names and I want to turn that string into a list of strings where the name of each player is one string
You used the wrong BoundingBox, or you are not using a recent version of Spigot
would this work?
wrong BoundingBox import most likely
No need to cast to projectile
oh lol fixed
yeah that was accident, but would it work?
Sure
great
np
before you do
it would be better if you stopped storing each x,y,z,x1,y1,y2 and just store the locations of each two Vector positions
hm
config.set("path", location.toVector())
that will save a Vector to yoru config
you can load it as a complete Vector
so will it do the same thing i used to did?
I mean i used to use
config.set("path.x",location.getX()
to the whole code and it took very time
actually you could just save teh BoundingBox
its serializable
just save the BoundingBox
ok
config.set("path", location object)
hello i am trying to connect to this page in java and read the structure but i have an error Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://pl.namemc.com/search?q=Proscreeam1337
https://pl.namemc.com/search?q=ProScreeam1337 but in chrome every think work perfect
you are probably ignoring a redirect in the header
wdym?
Many websites auto redirect. If you do not process that redirect you will get a 403
So I made this
if (yaml.getString("team_one") != null) {
for (String str : yaml.getString("team_one").split("\\s*,\\s*")) {
if (Bukkit.getPlayer(str) != null) {
manager.setTeamGroup(Bukkit.getPlayer(str), Group.TEAM_ONE);
}
}
}
But yaml.getString("team_one").split("\\s*,\\s*")) gives me the player's name surrounded by [ and ]... Any idea how to remove them?
what do you mean about redirect? url doesn't change
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
URLConnection conn = url.openConnection();
conn.setReadTimeout(5000);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);
// Handle redirects.
String redirect = conn.getHeaderField("Location");
if (redirect != null){
conn = new URL(redirect).openConnection();
}
try (JsonReader reader = new JsonReader(new InputStreamReader(conn.getInputStream()))) {```
what's the event for something being thrown?(e.g. snowballs, potions, ect.)
When yaml.getString("team_one").split("\\s*,\\s*") returns this:
[Max094_Reikeb, Nat7123]
Then every string str is under the form [Username]
Do you have any idea how to remove []?
replace or substring
There shoudl not be any [] Are you sure its not from auto formatting in teh toString?
Ah right, arrays have [] when run through toString
if(BotController.getSessions().containsKey(player)) if(BotController.getSessions().get(player).equals(playerIp)) return;
Why the BotController.getSessions().containsKey(player) returns false if there is that key? (CraftPlayer{name=EstrangedFury}:127.0.0.1)
Is it ok to use it if the server is using online-mode=false?
UUID will be based on the name then, but you can still use it
ok, tysm
https://paste.md-5.net/duyajunuwu.java
https://paste.md-5.net/giyejimaga.rb
and don't work ;/
Do you have any other plugins
Try using an HttpURLConnection instead ```java
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(5000);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);
// Handle redirects.
String redirect = conn.getHeaderField("Location");
if (redirect != null){
conn = (HttpURLConnection) new URL(redirect).openConnection();
}```
raymando just wondering
what java version you using
it isnt related, but theres a new cool http api built into the jdk for later versions
java 11 http client is pretty fun ^
Yep
sometimes java 8 sometimes java 16
https://paste.md-5.net/qenivuluda.java
https://paste.md-5.net/sulefecava.cs
and again don't work
I'd guess its looking for a cookie
@eternal oxide hi, when i get the nbt tag compound of an item, even though i added my custom nbt called bottleType:grand, it returns null
what do i do
i've already told you
With EntityDamageEvent how do i get the player who damaged
or
wait
can i use getcause
yeah
Thank you! Ill use the event u said
How?
Im dumb, ive realized i need to use the same event
wait
No
Im lost in my own stuff rn
I understand
I just thought i couldnt use it but realized i can just move my code into this
tyvm
In NBTTags why is Unbreakable a byte?
I think because there is no boolean type
Yeah
It just uses 1 or 0 as true or false
Yeah but instead of an int... its a byte...
Not by much though. 1 is smaller than 1b in other forms xD
It's 4 times smaller
An int is 4 bytes
anyone know some kind of thing where I can put annotations on fields then make all those fields editable in a gui without me having to write so much code for every damn field I want people to be able to edit
public MongoClient mongoClient;
public MongoDatabase db;
public MongoCollection<Document> history;
@Override
public void onEnable() {
getCommand("cmd").setExecutor(new Cmd(this));
initMongo();
}
private void initMongo() {
mongoClient = MongoClients.create();
db = mongoClient.getDatabase("PunishmentHistory");
history = db.getCollection("StaffHistory");
}
}```
https://hastebin.de/huyivukaqi.properties - anyone know why I am getting this error?
https://hastebin.de/etowoziray.xml - pom.xml
How can i make minion-skeletons that kill everyone but you?
Well I haven't used Mongo but it looks like you aren't shading/importing it properly
I copied the same pom from a working project and added spigot
It only seems to give me that error when trying to do it in the onEnable()
psvm works fine no errors
Sorry I don't have experience with mongo
declaration: package: org.bukkit.entity, interface: Mob
How can I check if an item has a certain word in it's lore?
Get the meta and then check the lore
Check if the lore contains the word
lol
How to check the lore??
Get the ItemMeta and use getLore()
I also recommend stripping the lore of any chat colors when checking
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
I got thelore
So what's the issue?
I am wondering how do I check if a word is in the lore?
String.contains(anotherString)
check each line for that word
Thank you
Each line?
the lore is a list of strings
Yes
so you would have to iterate through that list
Can I check only the first line
Loop foreach string in getLore
Because the custom item I have only has it in the first line
i mean, sure you could but once you change it your server will throw exceptions in your face
PersistentDataContainer
And I want to check if the potion is a player dropped potion by the plugin
in higher versions items has a place in the data file of bukkit to store namespacedkeys with values
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
Thank you
I've duplicated teh header and that site will not allow me to make a request. No mater what I try
Im trying to use launch projectile to spawn a fireball out the player but how do i make it go slightly to the left
public void onDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if ((player.getHealth() - event.getDamage()) <= 0) {
event.setCancelled(true);
PlayerCorpseEntity.execute(player);
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), getRespawnItem(player));
player.setHealth(20.0);
player.getInventory().clear();
player.setGameMode(GameMode.SPECTATOR);
}
}
}
Why does this not drop the player's dead items?
What does .clear(); do
So it won't delete them right?
So it does delete them??
Why
It doesn't even drop them
Why would I want them to delete them lol
Is it possible to calculate the knockback a player should be affected with when he gets hit?
I asked why it didn't drop them
Now, better question how?
Well?
Why does it not drop the player's items
Actually the player keeps the items some how
i dont want to drop them
Why doesn't it just drop naturally
??
But he goes in spectator
Ye
and
after i put him into survival
tthe items are still in his inventory
Ye I guess
how can i make an entityarmorstand that has something similar to noclip? I would like to give it velocity, but when it's in a block it gets stuck
maths
thats an event??
When I have my own module loader, how can I copy/link the sources from the modules in mines? (https://github.com/Lcraft-Developers/Lcraft-APIs/blob/main/LcraftAPI-API/src/main/java/de/lcraft/api/plugin/modules/minecraft/spigot/ModuleManager.java#L65)
https://www.spigotmc.org/threads/custom-particle-wings.334506/ maybe this helps ya
nvm
What is the best idea to give armorstand a natural movement mob (e.g. like a pig)?
first google results https://www.spigotmc.org/threads/change-a-players-skin.187203/
https://stackoverflow.com/questions/45809234/change-player-skin-with-nms-in-minecraft-bukkit-spigot @quaint mantle
I'm looking to add a /disguise plugin to my network (to be) for when we hire huge youtubers, so they don't get targeted. This should change their name...
When I have my own module loader, how can I copy/link the sources from the modules in mines? (https://github.com/Lcraft-Developers/Lcraft-APIs/blob/main/LcraftAPI-API/src/main/java/de/lcraft/api/plugin/modules/minecraft/spigot/ModuleManager.java#L65)
What would the method be exactly?
Just setting the loc I guess
hmm
public boolean runCircle(Location loc, float radius, float speed) {
double amount = 7;
for (double t = 0; t < amount; t += 0.1){
float x = radius * (float) Math.sin(t);
float z = radius * (float) Math.cos(t);
ArmorStand circle = (ArmorStand) Bukkit.getWorld("world").spawnEntity(new Location(loc.getWorld(), (float) loc.getX() + x, (float) loc.getY(), loc.getZ() + z), EntityType.ARMOR_STAND);
circle.setVisible(false);
circle.setGravity(false);
circle.setMarker(true);
circle.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
Bukkit.getScheduler().runTaskTimer(CircleMarker.getInstance(), () -> {
circle.getLocation().toVector().multiply(speed);
}, 0, 1);
}
return false;
}```
i have done something like this
but doesn't look to move
is this what you mean?=
Alrighty. Time to dig through nms code
How can i shoot fireballs out of a dragons mouth, LivingEntity#launchProjectile isn't working for me
when a player clicks in their own inventory when having a custom inventory open, will inventoryClickEvent.getClickedInventory().getHolder() return the custom inventory or the player's?
isn't that with arms movement?
probably spawn a new entity of the Fireball type, then set a vector
You can search in nms and copy the math method (?
what would the vector be
math
Prob.
whatever youre shooting at position - the dragons position
?
then put that xyz into a vector and boom you have the thing youre trying to make
just drag.location.toVector?
come to think about it, there is probably a method for it
Ive always done it with math
ok, ty
Do i set the direction or velocity
NMSophobia go brr
if you set velocity it would probably go faster the further away the dragon is
are you setting the velocity at least?
val fireball = dragon.world.spawnEntity(dragon.location,EntityType.FIREBALL) as Fireball
fireball.velocity = dragon.location.toVector()
nms isnt needed here, im just asking wether querying the holder of an inventoryclickevents inventory will return the player inventoryholder or the custom inventoryholder when the click in their own inventory
do it via a set
setVelocity or so
it is, thats just how kotlin works
oh nvm me then
fireball.velocity = fireball.setVelocity in java
you probably wanna delay the velocity set by a few ticks
oh lol
for some reason it usually doesnt work when you set the velocity directly after spawning the entity
Can you elaborate
Yea
Anyway can you elaborate on the using nms
The fireballs are just like this
val fireball = dragon.world.spawnEntity(dragon.location,EntityType.FIREBALL) as Fireball
object: BukkitRunnable(){
override fun run() {
fireball.velocity = dragon.location.toVector()
}
}.runTaskLater(SandboxCore.instance,2)
The majority of the time you are spawning that fireball inside the dragon
dragon.getLocation().add(dragon.getLocation().getDirection())
or use the Entity#launchProjectile
Whenever I force respawn a player from a pvp battle, the still take knockback whilst respawning, is there a way I can prevent this? https://imgur.com/a/u71ESx7
already tried setting velocity, ill try waiting a tick,
today on is this kotlin or java
ok its kotlin
Hello, i have this code:
public boolean runCircle(Location loc, float radius, float speed) {
double amount = 7;
for (double t = 0; t < amount; t += 0.1){
float x = radius * (float) Math.sin(t);
float z = radius * (float) Math.cos(t);
ArmorStand circle = (ArmorStand) Bukkit.getWorld("world").spawnEntity(new Location(loc.getWorld(), (float) loc.getX() + x, (float) loc.getY(), loc.getZ() + z), EntityType.ARMOR_STAND);
circle.setVisible(false);
circle.setGravity(false);
circle.setMarker(true);
circle.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
Bukkit.getScheduler().runTaskTimer(CircleMarker.getInstance(), () -> {
circle.getLocation().toVector().multiply(speed);
}, 0, 1);
}
return false;
}
}```
i'm trying to move the stands in circles, but it doesn't seem to do it... could anyone help me?
Plz could anyone help?
People already awnsered?
where?
yes but how do I replace/substring?
Like this?
String playerName = str.substring(1, (str.length() - 1));
Yeah like that
Anyone know why these fireballs arent going to the point i set (-669,9,-275)
fireball.velocity = Location(dragon.world,-669.0,9.0,-275.0).subtract(fireball.location).toVector().normalize()
how can i add default movement to nms entity?
how would i check if a listener is already registered to the plugin
just loop through the list or is there an easier way?
is there an easier way to get a HumanEntity's inventory's InventoryHolder than humanEntity.getOpenInventory().getBottomInventory().getHolder()?
Is there an event that fires when a player types a command?
isnt that what the implements CommandExecutor for....?
how can i give a player knockback
Im spawning primed tnt how would i make it not explode
so im using spigot/java to code plugin and i was looking at examples. they put super(Type.PLAYER_EGG_THROW, player); they wante me to replace Type with something but idk what that means. i have low iq sorry if this sounds dumb
No idea what that code refers to, I don't recall anything like that in the API
public PlayerEggThrowEvent(Player player, Egg egg, boolean hatching, byte numHatches, Boat hatchType) {
super(Type.PLAYER_EGG_THROW, player);
this.egg = egg;
this.hatching = hatching;
this.numHatches = numHatches;
this.hatchType = hatchType;
this is the stuff before and after if u need
thats not all just a little of it
that tutorial is at least 10 years old
seriously
events haven't worked like that for at least 10 years
Explains why I didn't recognize it
its for the old event system which was removed on 31 Jan 2012
so not quite 10 years, but almost
yea but can u help me?
Set their velocity
find a better example
Not if you don't tell us what you're trying to do
& what do you want to do
i want to make an egg spawn 100 boats when it breaks
md which mob did you vote for
Then listen for ProjectileHitEvent
And spawn 100 boats if it's an egg
Not sure why that's what you want to do but who am I to judge
allay
so theres no possible way to use the code i already have in there
the code you posted so far makes 0 sense
its code from inside spigot not a plugin
suggest you find a newer tutorial
anything in the last 8 years should do
I would just read the wiki lol
anything in the last 8 years should do
XD
running sonarlint on my project for the first time... let's see how many issues it finds
hahaha 3202 issues
one issue every 12 lines of code, fantastic
Nice
man this is going to weigh on my conscience until it's down to 0
Good luck with that
what's the difference between the getX function of a Location and the getBlockX?
getX returns the precise location, blockX returns the location rounded
floored I belie~ dangit
that's it?
Yes
what's the best way(least amount of text) to teleport an entity 10 blocks into the air?
e.teleport(e.getLocation().add(0,10,0))
so e.getlocation returns a copy?
yes
thanks!
how would i make my mob not drop any of its armor
On the death event getDrops and use the clear method
Will that work for its armor ive given it too?
Yes anything that is in its inventory will not be dropped
If you only want to remove armor you can remove each item from getDrops
Thank you
LivingEntity#getEquipment#setXDropChance
Huh I haven't used that but ig that might be easier
ohh
Oh
but then it wouldnt be able to drop custom items after right?
Yeah you should be able to set all the drop chances to 0
yeah but i would like to add a custom item to drop after
Well if your doing that it would be easier on death
You can just add it to the drops
You could but that would be the best way of doing it
Wouldn't*
It's easier and better to just add it to the drops
got it!
So, I have a class that is a command which destroys a block and adds it to a list. I want to set it so that when the server is shutting down, the onDisable logic runs through this list and replaces all these blocks. How do I create a list variable that lasts through multiple uses of the command, and can also be called from the onDisable logic?
maybe you should save the variable to a file every time you use it?
i'd rather not constantly save and load it from a file if possible
if that's the only option i can do that
i just want to use a hashmap 😦
I don't know any other options, but I'm terrible at spigot, I started like 6 months ago, so there probably are other options
what is a 'list instance variable'?
A field of type List
^
i wish i knew words better
I generally advise against fields inside of classes that implement CommandExecutor or Listener if those fields are to be accessed outside of those classes, so you're probably best to make a List in your plugin's main class, have a method to add to it and call that method in your command class
Suppose if you're restoring those blocks, you'd want to use a Map<Block, BlockData> or Map<Block, BlockState>, but it's up to you how you want to handle that
yeah that was just a lie to more easily explain my problem
it's actually a map of Chunk keys and then an integer which is just the number of active bukkitrunnables using that chunk
basically while these chunks are 'in use' i have to prevent things like paintings or such from dying
and also prevent them from unloading
is there a way to create an entity which doesnt tick?
could be useful for armor stands
to make custom entities
so it uses a small amount of server resources
maybe see paper source code for how they have an option for no tick armor stand?
Doesn't 1.17 introduce the server-sided non-ticking entity that just holds data?
Or was that 1.18?
Yeah. 1.17. Marker entity
It's an invisible entity with no hitbox that doesn't tick
blarg
can it hold and render items?
im doing something stupid arent i
like heads?
verify
No, it's an invisible data entity ;p
any idea what the actual proper syntax for this is
if (activechunks.putIfAbsent(CL, 1) != null) {}
seems good to me
it says '!= cannot be applied to 'null', 'int''
no idea what ur trying to accomplish tho
im just tryna make my code efficient
i think it returns the value
yeah
an int primitive can't be null
it returns either the value, or null if no value was there
i mean that's sort of the point though
isnt it supposed to return Integer?
@hasty prawn
nevermind
im an idiot
i dont know why my map can't use a primitive as the thing it's storing
but
OH WELL
works now
yeah
generics dont accept primitives
use Integer instead of int
and Float instead of float
etc.
nice
how do i make the worldborder instantly kill a player
check if they are out bounds
if player touch the nearest block near the worldborder kill it.
i only want to kill them once they are far enough that the border would start damaging them in vanilla
welp
meh
maybe search it on
Google your question before asking it:
https://www.google.com/
couldn't i just kill them if the damage cause was whatever the world border's damage type is?
well or just check how many blocks away in vanilla they will start taking damage
i think it may be suffocation
since there's no other way to take suffocation damage in this gamemode i guess i could use it
then add that to your border size to get the block then just kill them
// schedule
Bukkit.getScheduler().scheduleSyncRepeatingTask(() -> {
for (Player player : Bukkit.getOnlinePlayers()) {
// get position and world
Location loc = player.getLocation();
World world = loc.getWorld();
// get size and center of border
int s = (int)Math.floor(world.getWorldBorder().getSize());
Location c = world.getWorldBorder().getCenter();
// check position
if (Math.abs(loc.getX()) > c.getX() + s || Math.abs(loc.getZ()) > c.getZ() + s) player.setHealth(0);
}
}, 1, 5);
this might work
havent tested it
wrote it in discord
might not even compile
i realized that you could set the damage buffer and damage amount of the worldborder which does exactly what i need
Why would you abs it
so it doesnt matter if ur negative or positive on the axis
but i have a better way
// schedule
Bukkit.getScheduler().scheduleSyncRepeatingTask(() -> {
for (Player player : Bukkit.getOnlinePlayers()) {
// get position and world
Location loc = player.getLocation();
World world = loc.getWorld();
// get size and center of border
int s = (int)Math.floor(world.getWorldBorder().getSize());
Location c = world.getWorldBorder().getCenter();
// check position
if (Math.abs(loc.getX() - c.getX()) > s || Math.abs(loc.getZ() - c.getZ()) > s) player.setHealth(0);
}
}, 1, 5);
that should work
making a plugin to make lightning possibly strike players if theyre holding a metallic sword, will using LightningStrikeEvent suffice?
and also, is there a /good/ way to test if where they are standing, they have direct sky view?
like no blocks obstructing the path between lightning and player
right now im just doing this which feels like it should work but could be better
how do i make a block like purple stained glass
using set type
setData is deprecated
Material.PURPLE_STAINED_GLASS
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Player target = Bukkit.getPlayer(targetName.trim());```
Anyone know why target is returning to null? The targetName is a valid player
Are they online
yea
Does it happened to be colored? I see you're getting this from a title
If it's colored you need to strip the color from it
ah thats exactly what it is makes sense
thanks
Where is targetName being set?
Yeah just strip the color then. ChatColor.stripColor I think
How can I get the overworld when creating a new Location()?
getServer().getWorld("world") i believe
I am using the litebans api and when it gives me the startdate of a ban, it gives me a long string like: 1636258711477. Anyone have any ideas on how to convert it to an actual date lol
Pretty sure thats just time in millis
Any date lib should have a method to convert it
It’s a pretty bare api tbh, docs are horrible and don’t give much help at all
thanks
String string = "hello world sus"; // initial string
String[] words = string.split(" "); // split into words
// replace words
words[0] = "among"
words[1] = "us"
// concatenate
StringBuilder b = new StringBuilder();
for (String word : words) b.append(word);
a bit messy
but yea
oh wait u removed msg
oh lmao
thanks g
nice
hello
i can connect to my mysql monitor using sudo mysql -u root
but my plugin cant
i run the server with sudo btw
no password
idrk bout mysql but do you have to whitelist ips or smth
I know for mongo you have to manually whitelist ips that can access it
even localhost
How would I add nbt tags to an entity.
Nms if i remember right…
Welp maybe im wrong meh
It's fine, I made a janky way of getting my entity through custom name.
join gen 1
how would i go about detecting when a player is 30 blocks away from an entity to do stuff? im trying to make a plugin that deletes entities when a player is 30+ blocks away from an entity then when a place is under 30 blocks away from it, it apppears. i just dont know what id use for it, a constant bukkit runnable to check the players locations and the entities or is there another way?
How do I compare entity.getCustomName() to a string, I've debugged and know that the string is exactly the name of the entity yet it returns false.
public boolean mobExists(){
for(Entity entity : world.getEntities()){
if(entity.getCustomName() == null) continue;
if(entity.getType() != this.entity) continue;
if(entity.getCustomName() != this.name) continue;
return true;
}
return false;
}
Location#distance
PDC
yeah i know but is there an event i can use or something? or just a repeating task
Anyone?
if(event.getMessage().contains(bannedWords)){```
umm how do i get CharacterList from config.yml
i meann and check if the chat has that words
You compare strings with .equals
anyone?
List<Character> bannedWords = plugin.getConfig().getCharacterList("Banned-Words");
for (String word : bannedWords) {
if(event.getMessage().contains(word)) {
hi
i have this custom recipe
problem is if i put 1 item per slot, crafting table shows the result and there is no need to put 32 item per slot
how do i make it neccessary to have at least 32 item per slot
how can i make individual world borders for players using packets?
You'd have to make a craft event and listen for the items in each slot
Anyone know why I get this error?
here is the code:
why tf you need getInstance
you literally passed the plugin in constructor
if BrewingRecipe is your plugin
I was trying smth new and was following a guide
Ye it is, so I can just the delete the runTaskTimer?
you do runTaskTimer(recipe, 0L, 1L)
however imo you shouldnt run code in constructor, construct the object first, and only then schedule
.equalsIgnoreCase
Yes, for the subcommands, use a map for the subcommand tokens rather than switching on the first argument
No
No worries, I’d also suggest taking a look at Java naming conventions again.
?tempban @quaint mantle 7d false advertisement
Done. Enough chaos for now.
what version of buildtools should i use for a 1.16.5 server?
latest
?
after i built the path with buildtools there is no org.bukkit
no because this is spigot?
work/bukkit
wat
no
the server jar contains a package with the name org.bukkit
but that's not a folder name
it might have been a group id back in the days
i have found the buildtools file i used ages ago
is there a better way than doing 3 for loops to check if there is a block in a specific radius around a location?
probably not
you to a certain extent need to iterate through three dimensions so three loops seems reasonable
cOmMaNd BlOcK mOmEnT
i misread
.
🤷♂️ > 🤷
🌞
this is hilarious
is there any fancy way to listen to bukkit events, or having Listener or Handler named class with Listener implementation is enough?
oh yeah speaking of hilarious, this is how the smile with tear emote looks on iOS https://cdn.discordapp.com/attachments/165129131770511360/906725844628701244/IMG_3456.png
🥲
that’s as fancy as it gets
that’s worse
I usually if I can use EventExecutor over the reflective invocation system
idk if it's classified as fancy though
can you provide me an example
because i'm having two repeating blocks of code doing the same thing in both events and having one function interface to both of the events would be great.
ik there's registerEvent() method, but I really don't know where to get EventExecutor argument
I managed to dig up my NMS needs faster than this class lol
Hey so I'm trying to write to yml to setup groups and all...
I made a method that adds a player to a group (the group being a String)
private void addPlayerToGroup(Player player, String group) {
YamlConfiguration yaml = new YamlConfiguration();
List<String> values = new ArrayList<String>();
values.add(player.getName());
yaml.set(group, values);
try {
yaml.save("plugins/MaxiCity/teams.yml");
} catch (IOException e) {
e.printStackTrace();
}
}
but I don't know how to remove the player from the group now
there's no YamlConfiguration#remove or #delete...
set it to null
afaik YAML implementation of bukkit doesn't allow to add or remove entries from lists
you need to remove it from list and then set the list without the player
yeah ok
i could be wrong tho, but I had this problem before, couple years ago 😄
so I get the list, remove the player, and set the entry to new list without player
getStringList(java.lang.String) Returns a defensive copy. You have to re-set the value in the path. yes I was right
Also I modified my first code tho
This code was reseting the list to have 1 player
how should i handle vanished players on my server? Right now when they vanish they are added to a Set<UUID> and when they leave the server vanished, they are removed from that set and written to a config file. Should i consider keeping them into memory until the server restarts or not?
depends what kind of vanish do you want to have
if you want to have persistent vanish, i suggest saving it to a file instead.
since you will be vulnerable to a memory leak
class EventExecutorListener<E extends Event> implements Listener, EventExecutor {
final Consumer<? super E> c;
EventExecutorListener(Consumer<? super E> c) {this.c=c;}
@Override public void execute(Listener l,Event e) {
c.accept((E)e);
}
static<E extends Event> void register(Plugin plugin, Class<E> clazz, Consumer<? super E> blah) {
EventExecutorListener<E> e = new EventExecutorListener<>(blah);
plugin.getServer().getPluginManager().registerEvent(clazz,e,NORMAL,e,plugin,false);
}
}```
dovidas sry for the wait but yeah
thanks
yesh
it's a functional interface handling an event call from a listener
along with the event instance
shouldnt an eventExecutor pass the value back somehow to another listener
the value?
i mean the event object
this is going to my snippets folder
pog, but yeah you might wanna take a closer look at the event system impl yourself
yea im looking into JavaPluginLoader class rn
I forgot most details by now but there's a good reason why its a (Listener,Event) -> void
damn
thats sexy
let me copy and paste
lol yeah
arent u alr pro coder
Nah
DeluxeMediaLibFunctionProviderAbstractFactory?
lol
the biggest reason I see why you might wanna avoid the reflective system is because of speed but even then JIT does a fairly significant job in minimizing reflective invocation overhead
ArrayList<Player> :kekw:
?paste
this is mine
https://paste.md-5.net/otesecohob.java
what's the issue with that? ArrayList<UUID> could work too
its bad because contains method of ArrayList is O(N)
which would be problem if there's big amount of players
prefer using Set or Map for this
the issue is not that is an array list
and also turn types like ArrayList -> List, HashSet -> Set
🙏
just make everything static cause if there are no instances there is less memory usage

Yes
😏
the secret way
depends
it’s not bad
its not bad yeah
just has its uses
any comments to my code?
singleton like GSON or something lol
🎃
// no
show code
I mean I have seen some pretty awful work arounds because "static bad" like a singleton for sneaky throws which could have been a simple utility
you must die
private static
o:
bar = Bukkit.createBossBar(new NamespacedKey(plugin, "vanished"), "Vanished", BarColor.BLUE, BarStyle.SEGMENTED_10);
dont do this
lmao
Store your namespaced keys
in a class?
It's a shame NamespacedKey isn't 100% value based
Yeah
Problem is it sometimes requires the plugin instance
yeah well you can decide whether it is appropriate to make it a bit more coupled Ig
aaaaaaah
not a huge deal in this case
i thought there was something going brr 🤔
but its the main class pulse!
Fu
stop
Just pass plugin through constructor, no reason to overcomplicate stuff 🙂
but why
thats not dependency injection
constructors exists for a reason
lol
it seemed unnecessary to me if there was a static way 🥺
dont be lazy
Even then there's little to no reason passing your main plugin class instance around to every other class, in fact if you need to use something like BukkitRunnable, create a mid-level component that requires your plugin instance then just pass that mid-level component to the command handler rather than directly passing the plugin instance to the command handler.
Here's my GroupCommand : https://pastebin.com/iXUenPTu
Could u check the methods at the end of the file used to add/remove a player from a group?
I just want to make sure I did things write, especially for the remove method...
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.
mid-level component?
yes
If I did not a correct thing, then idk how to do it and I would need some help
whats a mid-level component?
//highest ordered class
class JavaPluginImpl extends JavaPlugin {
@Override public void onEnable() {
var scheduler = new Scheduler(this);
this.getServer().getPluginManager().registerEvents(new ListenerImpl(scheduler),this);
}
}
//mid level component
record Scheduler(Plugin plugin) {
public BukkitTask run(Consumer<BukkitRunnable> consumer) {
return new BukkitRunnable() {
@Override public void run() {
consumer.accept(this);
}
}.runTask(this.plugin);
}
}
//low level component
record ListenerImpl(Scheduler scheduler) implements Listener {
@EventHandler void onApple(AsyncPlayerPreLoginEvent e) {
this.scheduler.run((o) -> Bukkit.getPlayer(e.getUniqueId()).sendMessage("Yo"));
}
}```
or smtng
lol does it?
lmao
lol
this is probably a relic from 1.7.2 craftbukkit days, when NMS was compiled only on java 1.7 or lower
because Java 8 introduced lambda expressions and functional interfaces, but still
its at least 8 years old
in the codebase lol
you can probably check the last commit on teh git
december 2016
interesting
but why
java 8 was released in 2014
here's lombok getters and setter impl in java 14
Still no auto delegate 😪😪
IntelliJ can do that 🍉
is there a way to set a player flying an elytra and don't remove the chestplate?
when i execute this on a player in survival, they can fly but when i switch to creative and back to survival, their fly is gone
player.setAllowFlight(fly || player.getGameMode() == GameMode.CREATIVE);
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer();
if (CommandFly.getFlyingPlayers().contains(player.getUniqueId())
&& event.getNewGameMode() == GameMode.SURVIVAL)
player.setAllowFlight(true);
}
probably not since client renders armor items based on item slot contents
check the block type
my scheduled delay thing isnt running, I think it has something to do with the delay, but I cant find anything on what the values relate to in seconds/minutes java int task = Bukkit.getScheduler().scheduleSyncDelayedTask(WorldControl.instance, () -> { try { connection = DriverManager.getConnection(UrlString, username, password); if (connection != null && !connection.isClosed()) { //if (useBackup) { loadBackup(); } everMySQLWorked = true; useBackup = false; } iterations[0] = 101; System.out.println("MYSQL Connection Resecured"); isConnected = true; } catch (Exception ignored) { System.out.println("MySQL Connection still unsecured."); } readyForNext[0] = true; System.out.println("ReadForNext is now true"); }, 1L);
if you're asking for values in second and minutes, the provided argument value is counted in ticks
20 ticks = 1 second
you're executing this after 1/20 second passes away
alright, so putting 1L makes it 1 tick?
is there no method that accepts a TimeUnit? i think i saw it somewhere
yes
it doesnt print anything, when or if it runs, which it should print at least 1 or two things
Why Suspicious 'List.remove()' in loop ?
Umm, are you setting int = to a task?
private boolean removePlayerFromGroup(YamlConfiguration yaml, OfflinePlayer player, String group) {
List<String> players = yaml.getStringList(group);
boolean flag = true;
for (int i = 0; i < players.size(); i++) {
if (players.get(i).equals(player.getName())) {
flag = false;
players.remove(i);
}
}
yaml.set(group, players);
try {
yaml.save("plugins/MaxiCity/teams.yml");
} catch (IOException e) {
e.printStackTrace();
}
return flag;
}
thats what it was in the documentation, and my other methods work fine with it as a int
sus?
there's an int at players.remove(i); saying Suspicious 'List.remove()' in loop
probs because the returned List type is not known
thus you should use iterator
``public void PlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if(e.getFrom() == e.getTo()){
Block block = (((org.bukkit.Location) Location( 1,2,3) ).locToBlock(Material.GOLD_BLOCK));
Material material = block.getType();
if(material.equals(Material.GOLD_BLOCK))
p.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 40, 100000));
}
}
private Object Location(int i, int j, int k) {
// TODO Auto-generated method stub
return null;
}``
like this?
return List type of what?
bruh, do this
```java
code
Change it to @twilit wharf
System.out.println("About to run scheduler");
Bukkit.getScheduler().scheduleSyncDelayedTask(WorldControl.instance, () -> {
System.out.println("Started scheduled task");
try {
System.out.println("Line 1 of Try statement");
connection = DriverManager.getConnection(UrlString, username, password);
System.out.println("Line 2 of Try statement");
if (connection != null && !connection.isClosed()) {
System.out.println("Line 3 of Try statement");
//if (useBackup) { loadBackup(); }
everMySQLWorked = true;
useBackup = false;
}
System.out.println("Line 4 of Try statement");
iterations[0] = 101;
System.out.println("MYSQL Connection Resecured");
isConnected = true;
} catch (Exception ignored) {
System.out.println("MySQL Connection still unsecured.");
}
System.out.println("Line 5 of Try statement");
readyForNext[0] = true;
System.out.println("ReadForNext is now true");
}, 1L);
just to test it
k
Player p = e.getPlayer();
if(e.getFrom() == e.getTo()){
Block block = (((org.bukkit.Location) Location( 1,2,3) ).locToBlock(Material.GOLD_BLOCK));
Material material = block.getType();
if(material.equals(Material.GOLD_BLOCK))
p.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 40, 100000));
}
}
private Object Location(int i, int j, int k) {
// TODO Auto-generated method stub
return null;
} ```
thanks
mhm
iterator of what and what returned list isn't known?
Create a region and then check if they have moved in that region
doesnt seem to do anything
so nothing prints?
just says About to run scheduler and then doesnt print anything
send the code
WorldControl.instance.getLogger().log(Level.SEVERE, "MYSQL connection failed, retrying in 5 minutes.");
final boolean[] readyForNext = {true};
for (final int[] iterations = {0}; iterations[0] < 100; iterations[0]++) {
if (readyForNext[0]) {
readyForNext[0] = false;
System.out.println("ReadForNext is now false");
System.out.println("About to run scheduler");
Bukkit.getScheduler().scheduleSyncDelayedTask(WorldControl.instance, () -> {
System.out.println("Started scheduled task");
try {
System.out.println("Line 1 of Try statement");
connection = DriverManager.getConnection(UrlString, username, password);
System.out.println("Line 2 of Try statement");
if (connection != null && !connection.isClosed()) {
System.out.println("Line 3 of Try statement");
//if (useBackup) { loadBackup(); }
everMySQLWorked = true;
useBackup = false;
}
System.out.println("Line 4 of Try statement");
iterations[0] = 101;
System.out.println("MYSQL Connection Resecured");
isConnected = true;
} catch (Exception ignored) {
System.out.println("MySQL Connection still unsecured.");
}
System.out.println("Line 5 of Try statement");
readyForNext[0] = true;```
System.out.println("ReadForNext is now true");
}, 1L);
}
else {
iterations[0]--;
}
}```
um, one thing
it could be something wrong with WorldControl.instance
alright
?paste
are there entities that are not instanceof Creature?
ah yes
it doesnt seem to be a issue, it works as a value in a few other things