#help-development
1 messages · Page 567 of 1
Wanted to do a lvl 40 to test the diference fast
i am trying to save/load file using GSON
Crossbows don't get affected by power
Look up wiki for crossbow enchantments
lmao
do your Boards have a reference to File object ?
Is is possibly private ?
wdym?
"Failed making field 'java.io.File#path' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type."
Probably does not like the JavaPlugin then
make plugin transient
Oh right, that keyword exists
Have not used it in years
That is, I need to come up with a way that will skip JavaPlugin, DataManager, Config?
this is the way
how to make that?)
transient JavaPlugin plugin;
oh, thanks
transient just indicates that the serializer will ignore the variable
whats List<Task>?
you should probably isolate the data you want to be serialized into a separate class
what even is java.lang.ref.Reference
sounds like some post compile shit
@smoky anchor Thanks for helping me, all works now!
problem in List<Tasks>?
Do you have any other parameters in there ?
would be nice if gson gave the tree
no
oh
you might have to make a TypeAdapter for Location
I'd assume that has to be somewhere somehow registrated, no ?
yeah in the gson lib
or is the instance enough
nvm ignore that gist, they did it wrong
you have to extend TypeAdapter
similar tho
so I need to use "extends TypeAdapter'? ChatGPT gave me that
have a look at that tutorialspoint link
does anyone know how i can stop this error from coming up in the console? The plugin doesn't break or anything everything works but it's annoying and some people may think the plugin is broken because of it
[12:45:57] [Server thread/ERROR]: Error occurred while enabling EliteSpawn v1.4.1 (Is it up to date?)
java.lang.IllegalArgumentException: The permission elitespawn.set is already defined!
Only register the permission once?
now I have that ☠️
lets see the TypeAdapter
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.io.IOException;
public class LocationAdapter extends TypeAdapter<Location> {
@Override
public void write(JsonWriter out, Location location) throws IOException {
out.beginObject();
out.name("world").value(location.getWorld().getName());
out.name("x").value(location.getX());
out.name("y").value(location.getY());
out.name("z").value(location.getZ());
out.name("yaw").value(location.getYaw());
out.name("pitch").value(location.getPitch());
out.endObject();
}
@Override
public Location read(JsonReader in) throws IOException {
String worldName = null;
double x = 0, y = 0, z = 0;
float yaw = 0, pitch = 0;
in.beginObject();
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "world":
worldName = in.nextString();
break;
case "x":
x = in.nextDouble();
break;
case "y":
y = in.nextDouble();
break;
case "z":
z = in.nextDouble();
break;
case "yaw":
yaw = (float) in.nextDouble();
break;
case "pitch":
pitch = (float) in.nextDouble();
break;
default:
in.skipValue();
break;
}
}
in.endObject();
return new Location(Bukkit.getWorld(worldName), x, y, z, yaw, pitch);
}
}
try to delete the json you're reading and have it generate again
damn gson really hates you hey
how? rn i do this
that's what im asking how tf do i do that
i don't have it
then what are you reading
You can store the permissions object as a static final variable
or if you want you can register the permission in your plugin.yml and get the permission object from the plugin manager
sorry im quite new to this what does static final variable mean?
um you might want to learn basic Java before making plugins
I have nothing to read, I need to first create a file and then upload it. But when the server is turned on, my information is loaded, and when it is turned off, it is saved
that error just means whatever gson is reading isinvalid
it got a [ instead of {
which can't happen if theres no intervention
or it's reading the wrong thing
So you might be trying to load a possibly non-existent Json then ?
Probably wanna guard against that
So how can I save/create the file then?
the saving seems alright, but you have to make sure you don't load a file that does not exist
I ran the code with only save after shutdown and nothing was created. However, there were no errors.
First create the file then ?
var f = new File(path);
f.createNewFile();
and maybe pass the file to filewriter
Why is filewriter crying in orange?
Do try with resource
Probably want a buffered one too
And please don't create that gson instan every invocation
How can I apply a cached PNG file as a player's skin using Spigot API?
ok guys so when a player places an itemstack in an inventory... WHAT EVENT IS THAT. I swear to god man I can't figure it out. It's not in this list, so what is it?
It's an inventoryinteractevent but like, what is the action, how do I capture it, what is it called
PLACE_ALL
Only if there's an item of that type in the slot already
💀
InventoryAction action = e.getAction();
p.sendMessage(String.valueOf(action));
There's nothing when I place the stack in an empty slot
But say I have 32 grass blocks in a slot, and 32 on my cursor, when I then place all of those on the grass block slot, it says place_all
Which is why I am losing my mind at this, I can't figure out how to capture the specific action of a player placing an itemstack into an empty slot
Does anyone know if there's a different event or something I can do to detect this?
cant u just check for place_all and an empty slot?
like u have the slot clicked dont u ? or am i misunderstanding
I know what slot is clicked, since it's always the same. But when there's nothing in the slot already, and the player places any itemstack in that slot, there's no action printed from my code above
It's basically just this:
public void onMenuClick(InventoryClickEvent e) {
Player p = e.getPlayer();
InventoryAction action = e.getAction();
p.sendMessage(String.valueOf(action));
}
let me just test that real quick
random q but: what version are you using ?
for me it prints place_all fine
may have broken in latest ?
i am on latest
may have broken in older version, but is fixed on latest ?
I am on latest as well
well then it should work for you too
make sure you have quotes around your api version string
for 1.20
wait it was actually broken in some version ?
Yes it seems so
ok lol
Glad that helped :D
Frustrating lol
hey @smoky anchor (hope the ping is ok)
so I am running the plugin on a spigot server now, however, it does not seem to find a net.kyori dependency...
so not sure, if I can test that on a spigot server
You’ll need to shade adventure
ping is not ok unless we had a convo before
just ask, ppl who know/can will answer you
thats I assumed, but we did talk earlier, so in this case i hoped its ok
well yes, but this is a separate issue that I would not have been able to answer
fair
Do you have a plugin called "Adventure"?
no?
Oh, so it's a paper problem then? 💀
oke this explains it :)
Help?
you can change the skin of a player
but the png has to be uploaded to mojang servers first iirc
Hi, I am having an issue with the smithing table custom items, I am getting the result and its modified correctly but I cant pick it up, like when I click the result it get picked up and placed down instantly
recipe registering: https://paste.md-5.net/qobujexovu.cs
modify the result ItemStack: https://paste.md-5.net/boqiwayepo.cs
I have a problem with my PrepareGrindstoneEvent
i want to remove my custom Enchantment i set the name of the enchantment with a lore.
but the problem is that i want to see if one of the two enchantments are applyed or if both are applyed. and want to remove them the problem now is that i have som infos in the lore as attackdamage. and the enchants are applied at the top. Here is my code pls help me...
https://mclo.gs/xzsramb
In 1.8 there is no Custom Model Data for items, what could I use to identify Items from my plugin instead?
NBT
@sullen marlin please can you help me please.'
anyone can help me out? why my plugin doesn't load?
" 16.06 15:33:20 [Server] [ERROR] [DirectoryProviderSource] Error loading plugin: Directory 'plugins/SimpleLevels-1.0-SNAP.jar' failed to load!
16.06 15:33:20 [Server] [INFO] java.lang.RuntimeException: Directory 'plugins/SimpleLevels-1.0-SNAP.jar' failed to load! "
Bruh don't tag md_5
bro tagged the admin for assistance
I've been trying to fix this for almost 2 weeks no one helped me I have no choice
I just wish md comes here and says "And I have no choice but to ban you"
This is not how you ask for help here..
can you read? I've been asking for help for almost 2 weeks this is the first time in my life tagging him
anyways I am not here to argue
return;
}```
Anyone think of a way to do this check without the inventory holder?
I'm going to guess you are cancelling an inventory click event
Send the whole log, this tells us nothing of value.
Also stay in the correct channel
What are you trying to check
thats literally what its made for
We've been over this...
It may very well be what its "designed for" but its also snapshotting the entirety of a player's inventory every time they click...
In this case I believe it is a check to see if the inventory is of a type that is applicable to logging (this is an event in core protect).
For the sake of clarity, yes... this is something worth changing as, utilising the paper boolean they added to onHolder, it (i shit you not) took the the thread utilization down from 12% to 0.5% under heavy loads involving custom items
But I want something that would be spigot compatible too before I make a pr
please guys, who can help with GSON?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
dont create a new one on every invocation too, i already told you
Whom? Me or MrTvist?
Gson?
Code works fine
How do I have a permission node that is only given when a player explicitly has that permission node, and not when they are just OP?
Tested on 1.12.1 and I replaced SmithingRecipie with SmithingTransformRecipe
OP has all permissions
https://paste.md-5.net/pofokoheqa.cs
when saving, information is added, but when the server is turned on, nothing happens, the files become empty
Ive seen plugins be able to have a permission node that isnt given when a player is OP
i.e. they have to actually have that specific node, and not just OP
I just don't know how to do that.
I suspect itll be something in the plugin.yml, but maybe not
Yeah you can set the permission default in each permission in the plugin.yml
Do you mean PermissionAttachment?
I'm not sure.
I use Vault for permissions, via this extension function: ```kt
fun OfflinePlayer.hasPermission(permission: String): Boolean {
val permissionManager = Bukkit.getServer().servicesManager.getRegistration(Permission::class.java)?.provider
?: throw IllegalStateException("Could not find valid permissions plugin to use!")
return permissionManager.playerHas(null, this, permission)
}
And if I have a permission that, for instance, exempt's the player from some sort of logging that my plugin does, I don't want OPs to be exempt, only players who explicitly have that permission.
Thanks, I will
thats what i said
Anyone know how I can properly cancel the event when players move items to/from their off-hand?
I've gone back and forth on this so much. It seems that when I do event.setCancelled(true) it only "half" cancels it. Meaning when a player moves an item from any slot to their off-hand, the item is duplicated. But when they move something away from their off-hand, the item is just deleted. Anyone know what makes it act like this?
The PlayerSwapHandItemsEvent should cover your need.
Thank you
It doesn't seem that it covers it, as this event only triggers if I am outside of an inventory
is there a potion expire event
I suspect there might be an issue in my code. I'll investigate further
I'll test with an older version
InventoryClickEvent should be fired if you're in an inventory
What version are you on?
It seems the issue persists on 1.19.4. When trying to cancel the InventoryClickEvent after a player moves an item to or from their off-hand, the event is not properly cancelled.
@EventHandler
public static void onLeftClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
p.sendMessage(String.valueOf(e.getAction()));
e.setCancelled(true);
}
This means that, if the player moves an ItemStack to their Off-Hand, and the event is cancelled, the item is now duplicated. If an item is moved from the off-hand to an empty slot, the item is deleted. And when an attempt is made to swap the off-hand slot item with a slot that is not empty, the item in that slot will then replace the item in the offhand, and be duplicated (while deleting the original item in the off-hand). Tested in 1.19.4 and 1.20.1
Event works fine
three events can be fired when messing with the offhand. Swop hand, inventory click and inventory drag.
I've been printing them, while in an inventory, like a chest, inventory drag will not fire. PlayerSwapHandItemsEvent never triggers. InventoryClickEvent does fire.
drag fires when you are not precise with your click
It's a keyboard button (F by default) used to swap an item to off-hand
if items are duplication/deleting its your code doing it. all three events work fine
It's literally just e.setCancelled
declaration: package: org.bukkit.event.inventory, enum: ClickType
I'll give ClickType another shot if I didn't test properly before.
Regardless, the issue here is that when I cancel the event, it's not cancelled properly
are you sure it is really duplicated and not just a ghost item?
I feel you should probably do updateInventory()
I haven't seen anything suggesting it's a ghost item, but I will check again to be certain
ghost item is an item that exists in the inventory but disappears upon trying to remove it
so it never existed to begin with
only the client sees it essentialy not the server
but invoking an inventory update should cause the client to clear out any ghost items
is there an event for when a dispenser dispenses an arrow? I know of BlockDispenseEvent but that's mainly for dispensing items
I executed the dupe and I have relogged, the items are still there.
my friend is programming custom arrows
blockdispenseevent doesn't let you get any spawned entities
?paste some code, there is no dupe effect from cancelling those events.
if a dupe existed with cancelling an event in 1.19 someone would have mentioned it by now lol. There is obviously something flawed about your code and it probably doesn't necessarily exist in your listener code. But have you tried invoking an inventory update?
Right now this is literally all I have
@EventHandler
public static void onLeftClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
p.sendMessage(String.valueOf(e.getAction()));
if (e.getClick() == ClickType.SWAP_OFFHAND) {
p.sendMessage("SWAP_OFFHAND click-type triggered");
e.setCancelled(true);
}
p.updateInventory();
}
Without the p.updateInventory(); it seems that it will always dupe the items if it is executed correctly. I will test again.
relogging isn't really a fix for anything. If client and server are out of sync, the server will listen to the client in what it thinks is right
not the other way around
and you are not in creative?
I just realized 💀 Must be because of creative
creative overrides stuff and causes some events to not fire
so there is your issue right there
I never knew Creative could make ghost items actual items lol
Is there a way to change the tool used break a certain block and the block breaking speed? Preferably with specific instances of blocks rather than all of the same type, so I can make multiple custom blocks with something like noteblocks
in creative, the server listens to the client
if the client is in creative and says this item is real
the server just goes ok, well you are in creative so it don't matter
I see, that is some good knowledge to have. Thank you
The more you know, I suppose? Now I don't have to have this frustration again since I'll already know
Well at least we got to the source of the problem 
I will cherish this knowledge for the next 5 minutes and then forget about it entirely only to stumble upon it sometime in the future
lol
Or more realistically I will take much less time troubleshooting in the future because I know one thing I need to test for is if it's a creative specific issue
yeah, creative causes a lot of problems
and is why it isn't really advised trying to combine survival and creative for example
It is what it is
I'm not sure I understand what you mean by that
the server behaves differently when players are in creative vs when they are not. Some events don't get fired because the client doesn't send the relevant information or vice versa
because some things are deemed unnecessary in creative
so, when you combine a player who isn't in creative in the same world as someone who is
you start encountering issues such as preventing duping. Cause according to the server, if you are in creative this is fine
I think I get it. Regardless, letting Creative and non-creative players interact is just goofy, and not something I plan on doing
These ghost items are quite frustrating, though. updateInventory doesn't seem to fix it either
not for someone in creative no
you have to actually delete it
because it is treated as being real for the one in creative
doesn't seem to properly update survival players inventory either
well it should because updateInventory() if I recall literally resends the inventory packet
listen to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryCreativeEvent.html not just InventoryClick
Its teh best you'll get
However it's creative so you will not be able to control a player in creative.
The client is always trusted in creative
I double-checked. The item is still a ghost item, and client doesn't seem to care about the updateInventory()
Still a ghost item, so it doesn't really matter. It's an edge case and has no real impact on gameplay
I'll keep InventoryCreativeEvent in mind in case I do anything actually needing to relate to Creative, thank you
== is correct in that instance
that is going to equate to true even if the player has no inventory open
The event that launches a projectile (ProjectileLaunchEvent?). Use getShooter to get the thing that launched it, then check if it is instanceof Dispenser.
Why not use getOwner?
your logic always fails here p != player && player.getOpenInventory().getTopInventory() == p.getInventory()
do not compare objects with ==
if p != player then theres no way p inventory is going to be players inventory
instance checking is fine there as inventories are unique
i doubt that getTopInventory() returns the same object as Player#getInventory()
but I haven't checked
just check if the InventoryHolder is the player
how will an inventory holder equal a player
https://paste.md-5.net/qevolowora.cs
when I loading all is fine, but when I am saving it gives me that
hi everyone, how could I make a LivingEntity (e.g: Zombie) walk to some Location? I was thinking about spawning an invisible entity to that specific Location and make the LivingEntity attack the invisible one. What do u think about it?
I was thinking do it that way but I though it woudn't work cuz let's say the distance between the first entity and the invisible one are about 500 blocks, idk if it would work lmao
Easiest way is nms
even then 500 blocks is quite far
but I think it's not possible to use nms with the original spigot jar right?
I mean, I'm using Minecraft Development plugin for IntelliJ and I never was able to use nms
idk if I'm doing something wrong
Hi! Need help with custom HP for entity.
It doesn't work for some reason:
entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(50D);
entity.setHealth(50D);
Spigot 1.20
P.S. setMaxHealth doesn't work either.
nms will not be able to support 500 blocks?
did u tried something like maxHealth?
setMaxHealth or something like that
not with that attitude
you gotta set the tracking distance to 500
also ideally all the chunks would be loaded
It doesn't work.
not really easy supporting 500 blocks haha
I had to do something like getBukkitMob().getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(400);
anyways the 500 blocks was just an example, actually I'm doing a test project to practice some AI things and I wanted to make my Zombie to walk to some coordinates
custom AI's still better done with nms
just grab the mob's navigator and play with it
yeah but by AI I mean in general, like now I will practice some AI related things with Spigot and then practice with other things than Minecraft u know?
algorithms
ah yeah normal ai
those are only algorithms and that's what I wan't to practice everywhere
just to train my brain
then I will continue with machine learning
everything went well till i begun with optimal uniform costs
for (String uuidString : npcUUIDs) {
UUID npcUUID = UUID.fromString(uuidString);
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(npcUUID);
if (npc != null) {
data.addNPC(npc);
}
}
Bukkit.getLogger().warning(data.getPluginNPCs().size() + " NPCs loaded.");``` how to load npc? list size is always 0
anyways this is not the right channel to talk about this, so to continue with my issue do u think it would be better to use an invisible entity to make my zombie walk on short distances or should I use nms 100% sure? if i should use nms then how could i implement the base of nms in my project?
dunno how my A* went
couldnt finish half the exercice cuz it was with timing 💀 those bastards
wait come to #general
I still need help.
share full code please
...
Location loc = conf.getLocation("mobs."+id+".loc");
LivingEntity entity = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.fromName(conf.getString("mobs."+id+".type")));
entity.setCustomName(ConfigHandler.improve("mobs."+id+".name")
.replace("{lvl}", conf.getString("mobs."+id+".level"))
.replace("{hp}", String.valueOf(conf.getDouble("mobs."+id+".maxHP"))));
entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100D);
entity.setHealth(100D);
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000*20, 1, false, false, false));
Even tho I have icon, and particles set to false, they are still showing. Is there something I am missing?
setMaxHealth
@Deprecated
void setMaxHealth(double health)
Deprecated.
use Attribute.GENERIC_MAX_HEALTH.
Sets the maximum health this entity can have.
If the health of the entity is above the value provided it will be set to that value.
Note: An entity with a health bar (Player, EnderDragon, Wither, etc...} will have their bar scaled accordingly.
Parameters:
health - amount of health to set the maximum to
Try removing the effect and then adding it again
try using the setMaxHealth, if it still don't work then add next to that line setHealth with the same value
If you want to modify the entity you should do so in a consumer and use the spawn method instead
That will ensure the entity is modified before it's spawned
it still does it.
What version are you on?
Works fine for me on 1.20.1
latest
could it be because they are getting these effects on server join?
Then why is it not working for me
well particles dont show no more its just the icon now
icon in the inventory?
yeah
You can't hide that one
thats dope. now people can see horrible effects with a time 277:23:21
As the docs say use -1 for infinite effects
Also you don't even need potion effects to keep the player fed
does anyone know how to use the wagon-ftp plugin to upload my jars over sftp? i know it can do it with ftp but I get a unrecognized sftp error
what could I do instead besides a loop for setfoodlevel?
You could just mount it using https://github.com/winfsp/sshfs-win
and what if i’m on unix 😅
It doesn't work.
loc.getWorld().spawn(loc, Slime.class, slime -> {
slime.setCustomName(ConfigHandler.improve("mobs."+changedMob.getId()+".name")
.replace("{lvl}", conf.getString("mobs."+changedMob.getId()+".level"))
.replace("{hp}", String.valueOf(conf.getDouble("mobs."+changedMob.getId()+".maxHP"))));
slime.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100D);
slime.setHealth(100D);
});
Then regular sshfs
But what If I wanna do it through maven
that way other people on my team have this?
Hey there! I'm currently working on a RandomTP plugin, but I'm encountering some issues. Sometimes it works perfectly, but other times it doesn't seem to function correctly. I'm quite new to this, so it's my first attempt at creating such a plugin. Could you lend me a hand and help me figure out what might be going wrong? Your expertise would be greatly appreciated!
public CompletableFuture<Location> findSafeLocation(World world, int x, int z) {
return CompletableFuture.supplyAsync(() -> findSafeLocationRecursive(world, x, z))
.thenComposeAsync(loc -> loc != null ? CompletableFuture.completedFuture(loc) : findSafeLocation(world, x, z));
}
private Location findSafeLocationRecursive(World world, int x, int z) {
int maxHeight = world.getEnvironment() == World.Environment.NETHER ? 120 : world.getMaxHeight();
for (int y = maxHeight; y >= 0; y--) {
Location loc = new Location(world, x, y, z);
Location belowLoc = new Location(world, x, y - 1, z);
Location aboveLoc = new Location(world, x, y + 1, z);
boolean firstCheck = !unsafeBlocks.contains(belowLoc.getBlock().getType()) && belowLoc.getBlock().getType() != Material.AIR;
if(!firstCheck) {
continue;
}
boolean secondCheck = loc.getBlock().getType() == Material.AIR && aboveLoc.getBlock().getType() == Material.AIR;
if(!secondCheck) {
continue;
}
boolean thirdCheck = TeleportDelay.getLastLocation(player) == null || TeleportDelay.getLastLocation(player).getWorld() == loc.getWorld() && TeleportDelay.getLastLocation(player).distanceSquared(loc) >= 1000;
if(!thirdCheck) {
continue;
}
return loc;
}
return null;
}
What's the error?
and have you seend this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getHighestBlockAt(int,int)
declaration: package: org.bukkit, interface: World
Works just fine for me on 1.20.1
The first few attempts seem to work flawlessly, but after that, it starts failing consistently. In fact, It attempted finding the location over 100,000 times with no success, before. It's quite perplexing
It works 50/50 lmao
declaration: package: org.bukkit.event.entity, class: FoodLevelChangeEvent
I am writing on Spigot 1.19. Server on Paper 1.20.1 #27
?whereami
wdym
It tested on Paper. It works just fine
I don't think so, there are times when it simply can't find a suitable location anywhere in the entire world. It's quite challenging, to say the least
You can log where you the checks keep failing.
Yeah it got deprecated in Java 11
and removed in 15
It's not dead
It's just not bundled anymore
thats why my js eval() was not working 💀
You can readd it if you need it
https://openjdk.org/projects/nashorn. Contribute to openjdk/nashorn development by creating an account on GitHub.
Dart > JavaScript
someone is clearly into dart now
Maybe
Can you send your code?
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Location location = event.getPlayer().getLocation();
location.getWorld().spawn(location, Slime.class, slime -> {
slime.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100D);
slime.setHealth(100D);
slime.setWander(false);
});
}
setWander is just to stop it from moving
Works just fine without that
Well, it doesn't even work now
public CompletableFuture<Location> findSafeLocation(World world) {
CompletableFuture<Location> future = new CompletableFuture<>();
CompletableFuture.runAsync(() -> {
findSafeLocationAsync(world, future);
});
return future;
}
private void findSafeLocationAsync(World world, CompletableFuture<Location> future) {
Random random = new Random();
int x = random.nextInt(25000);
int z = random.nextInt(25000);
Location loc = new Location(world, x, world.getHighestBlockAt(x, z).getY(), z);
Location belowLoc = new Location(world, x, world.getHighestBlockAt(x, z).getY() - 1, z);
Location aboveLoc = new Location(world, x, world.getHighestBlockAt(x, z).getY() + 1, z);
boolean firstCheck = !unsafeBlocks.contains(belowLoc.getBlock().getType());
boolean secondCheck = loc.getBlock().getType() == Material.AIR && aboveLoc.getBlock().getType() == Material.AIR;
boolean thirdCheck = TeleportDelay.getLastLocation(player) == null || TeleportDelay.getLastLocation(player).getWorld() == loc.getWorld() && TeleportDelay.getLastLocation(player).distanceSquared(loc) >= 1000;
System.out.println(tries);
tries++;
if (firstCheck && secondCheck && thirdCheck) {
future.complete(loc);
} else {
findSafeLocation(world).thenAccept(future::complete);
}
}
I have the same thing, but it doesn't work. Now I will try to run it on the server without unnecessary plugins.
Error?
hi, I want to generate an Image file (.png) of a custom Minecraft chat.. what i mean by this is that you enter a text as an argument and an image will be generated with the same text you said but in a minecraft chat... something like this but without the playername... it should just contain the text that is provided
I started the server with Spigot 1.20.1, moved the plugin to Spigot 1.20, removed all unnecessary plugins. Does not work. Can you send your plugin?
Do you plan on doing this with a spigot plugin, because that's the wrong approach.
This is simple image maniuplation
the thing is that i dont know what other discord server i could ask this...
wdym?
It's very strange.. I put "slime.getAttribute" and "slime.setHealth" above "slime.setCustomName", and everything worked.
Anyone know how I would grab the player that placed a certain vehicle?
is there an api i can use?
Does spigot have event for map creation?
so how could i acheive what i wnat to do?
yes
also with a minecraft background
like this
Then you need to look into image manipulation
what is that?
..
not a spigot thing, rather its changing an image to what you want it to be
Like photoshop, but you could code it yourself as you have very specific rules in mind.
i see...
How to make sure that slime does not share after death?
What do you mean share?
Think he means split.
declaration: package: org.bukkit.event.entity, class: SlimeSplitEvent
You can listen to this event and use #setCount(1)
@full glade ^
Thx!
print both data in map and id
inline records
is it System.out.println("Cached " + cache.get(id)); or System.out.println("Cached " + id);
Hi, any tutorial for using BlockDisplay ?
Is there a way to check when an item drops?
Like when a crop is mined
or a mob is Killed
Alright so I just have to use multiple
got it
will blocks still hold PDC data if they are placed down?
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
okay, something has to be off with my google. this link should've 100% came up.
https://paste.md-5.net/erapipuyel.java
I am trying to get item generation after checking if player is doing an action.
I am exactly trying to copy information from ConfigUtil class i made is here: https://paste.md-5.net/opunisitar.java
hello, how can I set custom model data on a BlockDisplay ?
You aren't placing blocks. You're using itemstacks, and blocks are changing type. That's how you have to think of it in order to understand the why behind the code.
are there any useful tutorials on text display entities?
I'm either not looking hard enough or blind
Ohhhhh okay.
You can't. Blocks don't have custom model data
You'll have to use an ItemDisplay instead
cc @cinder abyss because I didn't ping in my reply out of habit
Could someone explain this a little better for me? is this talking about the lapis that has to be in a enchantment table, or the 2nd item in the anvil ? because an anvil can be used to enchant as well with the books.
whch class is that on
EnchantingInventory
Then it's the lapis
how can i get the enchants that are presented in the enchantment table?
How do I add custom enchants? I extended the enchantment class and have all the lore stuff done
🤣 Im working on the same thing.
is there a single function im missing to convert a chatcolor (bungee) to a hex string in the format of like #ffffff? I know I can use String.format but I was wondering if there is a builtin way, since you can also create them using ChatColor.of(hexString)
Nice just started on this like half an hour ago
wdym by adding?
Like do I have to register them or anything? I skimmed through a tutorial but it was ehh
you kinda cant for enchantment tables
you can add them
but you cant have them display, its a very odd limitaiton all ae plugins have
you cant put the enchant in a enchantment table?
you can like part of the way display them
Make a /ce command for your enchantment books and add your Enchantment to the enchantment container of the book
of course you can
its an Enchantment extending class
so it will act like one if registered as so
If I depend on a plugin (i my plugin.yml) that lists a library in its plugin.yml, are the classes of that library visible to me at runtime?
So how do I add it to the enchantment table then?
https://www.spigotmc.org/threads/adding-custom-enchants-into-an-enchanting-table.378581/
See here, this also goes over the limitation i talked about
Alright
thank you
Yes but what about its libraries at runtime?
PrepareItemEnchantEvent -> add your enchantment to the list if the conditions (enchantment table levels) are sufficient
Libraries loaded with the library feature are only visible to the plugin that loads them
If your plugin also needs that library you should declare it too
Afaik
Alright, thanks
hello i want to create a backpack plugin. But i've question what is the must ? create Json file or SQL database to storage the backpack items of players?
How would I make villagers be able to sell it/add it to their loot tables
You can do either
You can also technically use PDC
Use MerchantRecipe
Thanks
i rly need to make a ce plugin
PDC ?
oh to use MerchantRecipe btw use this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/Merchant.html
check if entity instance of Villager/WanderingTrader first ofc
How would I make it random like the other trades?
I'm a little confused
Wouldn't that just overwrite the existing recipes that a villager has?
What I want to do is to make randomly spawning villagers be able to do that trade
yeah on villager job change -> check if enchanting villager -> if chance <= percentage -> add
Got it
i keep forgetting that villagers have jobs now
Are all recipes pre determined or would I have to listen for when they upgrade
Can AnvilInventory#get(First/Second)Item return an ItemStack of material AIR?
If the method does not return null
if merchant . get Level <= level add your enchantment if villager level suffices
or colls ^
youd prolly use getLevel either way in acquiring new tradew tbf
I believe it’s VillagerAquireTradeEvent
Alright thank you
yep
god i hope this developer api gets used 
?
Also, how would I 'cancel', or do something similar to an AnvilPrepareEvent
Set the result to null iirc
Do I need to update the player's inventory afterwards?
if your setting the result of the event you shouldnt have to
but if your directly setting the slot in an inventory, i believe so yes
Ah, alright
can I put null in a string and itll just be ""?
depends
Because I have a function in some string canconation that could be null
isnt like String.empty a thing
like " " + mayBeNull() + " is hot!"
couldnt you use that when passing null
would a registered enchant show up in the /enchant command? one that i would have made.
well
uhmmm
ok
so this one maybe
No
you might have to inject into the enchantment map, but no promises it will work
so i added a config to my plugin, but when i set just 1 value and save it everything gets replaced by that value, and everything else dissapears... anyone know how to fix this?
You would need to inject into the enchantment registry
i dont even think that one re-syncs with the client like the command one does though
i vaugely remember that being some issue some years back
would it just be easier to make my own /enchant command?
Yes
hmm alright
enchantment plugins are lots of work ong
yes bruh
and code base behind all of them are dodgy asf 
i just use a library i cant be bothered
^
i reaaally wanna make one now that ive seen how kinda bad all of them are but meh
you able to show any code & how the configs saving before and after?
wtf did you do
yes one sec
haha
Redempt left a while ago
Hey does anyone know how I can get rid of suggested commands that I havent explicitly given permission for?
1: The Default Config
2: The code where I set a value
3: The code that loads the config (in the onEnable())
4: What the config turns into after setting the value
Doesn't seem to work
when you are calling getConfig are you calling saveDefaultConfig beforehand?
seems like your getConfig is empty
hence why when you save it only the spawns there
when the plugin loads it creates a config.yml with the default values
and look at img 3
.copyDefaults() does nothing
i never even knew options() was still a thing haha
but how do i fix it then?
just saveDefaultConfig()?
alr, well it didn't delete the other values now but it still deleted the comments
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
yeah
And when you add values to your config after an update, use getString(path, defaultValue) (can be getWhatever)
This makes it so if the config value doesn't exist in your config, that it gets created with the default value you provided, the config only needs to be saved afterwards for it to write the new value
like getConfig().getWhatever() right?
Like this?
don;t get until you need them
for the enchants key, is that just a namespaced key? i see someone people before using just number eg 101 but that was a few years ago and i get errors if i just a number.
comments will only be deleted if you are on an older spigot or you completely replace a section
im on 1.19.4
then you have to be deleting sections to lose comments
im so confused rn
We can't advise without seeing actual code. Not tiny window snippets you show us
this is my code
or do you want code snippets?
ElgarL
enchants key for the enchantment orrrr
theres a bunch of keys so not sure specifically what key your questioning about :p
Could you please take a look at my RandomTP code? It's not working at all/properly
I understand it's poorly structured and hardcoded, don't worry, I'll fix it. Thanks for the help
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
scaryjava while (true) {
lmao
there's a return, it should stop at some point
random TP's are really tricky to get without lagging
And why while true lmao
Make it a max x amount of tries instead of while true
This method can return negative valuesjava private int getRandomCoordinate(World world) { return (int) (Math.random() * world.getMaxHeight()) - (world.getMaxHeight() / 2); }
wtf essx has a rtp
Exactly
its all good. i figured it out.
you have to test if negative is allowed not just assume half teh height can be negative
wait isnt /tpr the tp request one xD i cant remember lol
what exactly dym?
what i said is only when your getting/needing the value
there is a min heigh value
i reccomend a seperate method for getting max y
That’s tpa
i still don't know how to fix the issue of the comments dissapearing
?
all these years and i never knew this....
punching myself rn
Wha
i cant tell you how many rtp plugin ive made/downloaded throughout the years wtf
Which is the command?
getMinHeight()
It’s newish
like this is before
onrespawn: true
#Comment
spawn: null
and this is after
onrespawn: true
spawn:
==: org.bukkit.Location
world: world
x: -61.511026447244134
y: 96.0
z: -42.18768670486722
pitch: 16.205576
yaw: 107.56201
and im like so confused why tf the comment is dissapearing
Code:
// setting the location
plugin.getConfig().set("spawn", location);
plugin.saveConfig();
i bet /randomtp would work
Someone please help
like elgar said were gonna need to see more code than just snippets try the entire class youe manipulating the config in
Comments dont override with saveDefaultConfig() on modern mc
I'm sorry but I don't quite understand where I went wrong, negative values are valid, the height I always go for the highest one in the position
so your either overwriting the section the configs in, or using some other saving method thats not right
int randomNum = ThreadLocalRandom.current().nextInt(world.getMinHeight(), world.getMaxHeight() + 1);```
there's nothing else about config but sure:
package nl.mnrkaas.elitespawn.commands;
import nl.mnrkaas.elitespawn.EliteSpawn;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SetSpawnCommand implements CommandExecutor {
private final EliteSpawn plugin;
public SetSpawnCommand(EliteSpawn plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (sender instanceof Player p){
Location location = p.getLocation();
if (p.hasPermission("elitespawn.set")) {
plugin.getConfig().set("spawn", location);
plugin.saveConfig();
p.sendMessage("§e§lElite§2§lSpawn §7§l| §7The spawn location has been §aSuccessfully §7set to your current location.");
}else{
p.sendMessage("§e§lElite§2§lSpawn §7§l| §cYou don't have the correct permissions to perform this action.");
}
}else{
Bukkit.getLogger().info("[EliteSpawn] This command can only be ran by players.");
}
return true;
}
}
and you are saving the default config onEnable?
Also ChatColor.translateAlternateColorCodes() exists :p
what does that do?
allows you to use & color signs
and yes im saving the default config
OMG TY
ye i know but i didn't know how to do it
reguarding comments deleting though - no idea your doing something funky somewhere or your server is old af like 1.8 or smthn
Can't find a suitable location... 🙁
its 1.19.4
like this is all the code in the onenable for the config
saveDefaultConfig();
using a random like that it coudl go for hours without finding a safe location
while true -> max amount of attempts
server crasher 3000
even better import the static method directly
and you can just colorize("")
Well, it's a RandomTP plug-in I guess
or be even lazier, make abstract classes for every possible use case and extend it
(joke for legal reasons)
You are also looping until the teleport delay expires. If thsi is not async it will freeze your server
no it needs to stop after not being able to find a safe location after x attempts instead of a while true or ^
async would be fine but youll still be in the inifinite loop boat
- need to use chunk snapshots
✅ Limit applied
So i've got this code for making overhead nametags. And it's working alittle strange. When Player A joins, he is unable to see his nametag customized. When player B joins, Player A is able to see Player B's name customized, but still not his own. and Player B is still unable to see both names customized. Here's my code but I thought I already fixed this? https://paste.md-5.net/ragijawili.java
lastly, pick a random x,y,z, then do a block search upwards until you reach max height. Then fail
Chunk#getHighestYAt forgot its name exactly
Exists now, but only is good if hes in end/overworld
loop from y to maxHeight looking for a safe place
he doesn;t want highest block at
just a safe spawn
ah so caves allowed then
I'd assume
Loop up the the highestY
No reason to go all the way to the world limit when most of it is air
oh yeh true
pick random x,z then java for (int y = getRandomCoordinate(world); y < world.getMaxHeight(); y++) {
if he removes cave rtp's he wouldnt even need to calculate for y tbh
untill you find a safe spawn or the loop ends
but myeh
true
What about something like this?
public Location findRandomSafePlace(World world) {
Location loc = null;
for (int i = 0; i < 1000; i++) {
int x = getRandomCoordinate(world);
int z = getRandomCoordinate(world);
for(int y = world.getMaxHeight(); y > world.getMinHeight(); y--) {
Block block = world.getBlockAt(x, y, z);
Block belowBlock = world.getBlockAt(x, y - 1, z);
if(TeleportDelay.getLastLocation(player) != null && TeleportDelay.getLastLocation(player).getWorld() == world) {
if(TeleportDelay.getLastLocation(player).distanceSquared(block.getLocation()) < 1000.0) {
continue;
}
}
if (isSafePlace(world, block, belowBlock)) {
loc = block.getLocation();
return loc;
}
}
}
return loc;
}
pov: you find that line of code you wrote at 3am
you are going to drop players to their death, unless you are checkign the block under their feet
isSafePlace does that
ok
bump camel hump thump
ElgarL, do you have an idea to avoid doing (getMaxHeight() - 10)?
to fix that problem
fix what problem?
.
sorry i lowkey have no idea :c
if it's the nether - 10
in the nether you might wanna change your y scanning maybe
since theres only a small area you can ever actually rtp in logically
just do - ( 10 * (enviroment == NETHER))
and going lower than 40 you likely put you in a lava lake
in the nether its 128?
The nether is 256 blocks tall
then do 128 *
But 128 of that is just air above the bedrock
huh ngl i thought the nether went as deep as the overworld
Nope
guess they skimped out on it when they added new height limits
The nether never got changed past 128
nether ? 127 : maxHeight
worked
also consider using ChunkSnapshot for block checking on the y axis when your scanning for the material type
Also consider starting at World.getHighestBlockY(x, z)
i think he might want cave tps so we didnt go that route
oh wait starting at
nvm
how can I apply the frosty vignette you get from being in powder snow, to a player?
packets will be the cleanest way more than likely
isn;t it just a particle?
No
other players dont see it tho do they?
It’s a screen overlay like the jack O lantern
ah ok
You can either set their freeze ticks directly or use packets to set them client side
hmm okay.
Solved, thank you so much!
Thank you ElgarL
Thank you Burchard37
And now, I can finally go back into hibernation
Oh yeah mb on that, misclicked channel
no
fuck
you can create many scoreboards but you can only display one to a player at a time
yeah
Can you use &4 inside components or do I have to do the chatcolor thing?
can I get a scoreboard anonymously?
and add on to it?
color/fromLegacyText
anon?
like without the object
players join a scoreboard, a scoreboard doesn;t belong to a player
the one that player has active
Player#getScoreboard
If you create a scoreboard but don;t hold a reference or assign it to a player it will be gc'd (I believe)
There is no method to get a reference other than when created or from an assigned player/team
is there an insert or replace in mongodb?
Hello, how can I spawn a BlockDisplay who is a note block with a specific instrument ?
Does the annotation handler EventHandler contain something like ignoreCancelled?
Yes
Pretty sure it does
Exactly that in fact
Then why am I gettting annotation value not of an allowable type for this @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
show the entire class
anyone know how can i hide this? Adding the itemflag HIDE_ATTRIBUES doesnt seem to work
wtf alright thanks 
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onClick(InventoryClickEvent e) {
if (!(e.getWhoClicked() instanceof Player)) {
return;
}
Player player = (Player)((Object)e.getWhoClicked());
if (player.getOpenInventory() == null) {
return;
}
if (player.getOpenInventory().getTopInventory() == null) {
return;
}
InventoryHolder holder = player.getOpenInventory().getTopInventory().getHolder();
if (holder instanceof AntiClickHolder) {
e.setCancelled(true);
}
if (!(holder instanceof GuiBuilderHolder)) {
return;
}
GuiBuilderHolder builderHolder = (GuiBuilderHolder)holder;
GuiBuilder builder = builderHolder.getBuilder();
if (builder == null) {
return;
}
builder.handleCommandClick(e);
}
and yes its implementing the Listener
by the hilarious off chance did it import the java websocket listener
if not maybe try revalidating your project files, should be fine from the looks of it
i did not
also tried that
also getting cannot find symbole class EventPriority for some reason
your still getting Player and stuff though?
Sounds like your just missing the import
Do alt + enter while clicking on EventPriority
Does not do anything
forgot to mention that feature is intellij only but i figured your using it
Am not
Eclipse is CTRL+SHIFT+O
oh neat
Not using eclipse im using the recaf thing
I want to make that on certain action from player it take cosmetic id line from config to string and then if in this string there is a word "backpack" eg. "woodcutter_backpack" then run rest of code but it's look like it doesn't give a F and even if there's no world like that then it runs it🤔
if (CosmeticUsers.getUser(player).getCosmetic(CosmeticSlot.BACKPACK) != null) {
BackpackOnBackString.add(CosmeticUsers.getUser(player).getCosmetic(CosmeticSlot.BACKPACK).getId());
if (BackpackOnBackString.toString().contains("backpack")) {
player.getInventory().addItem(backpack);
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "cosmetic unapply BACKPACK " + player.getName() + " -s");
player.playSound(player.getLocation(), "backpack.unwear", 100, 1.0F);
event.getPlayer().swingMainHand();
}
}
Any idea guys?
Are you still able to help?
I have a question why did I change all the file management and spigot libraries in 1.20.1?
?
i thought it worked fine as is tbh didnt know it needed changing
Is there a prize if we guess correctly?
you also live in teh far distant future, 1.120.1?
Does Soft dep mean its requireD?
Sorry, I was referring to version 1.120.1 of spigot
no, optional
regular dependency is required
Version 1.120.1? That wont be released for many many years.
your decompiled jar has no knowledge of what its provided dendencies are
If that amount is reached, yes, but I got the wrong number, sorry
they're talking about inthe plugin.yml
not maven
oh my bad
Should i get rid of the Label class and just make a .setText, .setColor, .setTextShadow and so on, directly on the Element itself?
Need some opinions, i wanna make it as easy to use as possible :D
How often are you needing to set labels
well, there can only be one per element. and that depends on if you want text in it or not
so basically you can make a rectangle and if you want you can put text in it
its a gui library
My suggestion would be, if you're calling .setLabel a lot, then use the builder, but if you're only calling it like once or twice, then just do without
I can see you've got LabelBuilder atleast 5 times there, so would be better to keep it probably.
the alternative would be to have code like this
Element title = new ElementBuilder(-1,-1, 128,14)
.setBackgroundImage(obsidianBackground, false)
.setBorder(1, BLACK, false)
.setText("Multiplayer XP")
.setTextShadow(true)
.setColor(WHITE)
.build();
So to have it direcly on the element
xD
But that gave me an idea, maybe i should just check out how existing GUI libraries like QT do it.
The only ones i know are HTML+CSS and Tkinter (which sucks)
in html its all on one element. text, backgroundcolor, border, textcolor, etc.
so that would be this
JavaFX
AWT
Or actually, LWJGL, write your UI using OpenGL

my itemframe map lib looks like this
how fun!
tfw you don't have original ideas
So you remake java swing
lol
not bad either, hmm
does anyone know how i can tell java that the second questionmark has the same type as the first questionmark?
for example if the key is a WindowObjectProperty<Byte>, the value must be a Byte
or is my only option to use <WindowObjectProperty<?>, Object> ?
in functions you can do it like this...
you can just define the bounds on your method
and do a weird cast
I have some projects where I do some cursed generic types
ah i see
Generics are pain
You're a pain >:I
:0
How do I remove decorations from lore?
whats a decoration
Italics
which ones and for what items (link your spigotmc so you can send pictures)
§f
The default lore that gets added is purple and italic
I just want to reset it
maybe im dumb but idk what you mean :c
Use ChatColor.reset
still can just wrap the string in that
then pass it through the component
prolly not the right way but it does work
for ((enchant, level) in enchants)
lore.add(enchant.displayName(level)
.color(TextColor.color(170, 170, 170)))
How do you combine 2 components?
Man
Map.Entry in the entryset
Also isn't chat color deprecated?
i forget, what's the method for getting an item's nbt data
its for 1.19
there's a method for it now
Are you talking about PDC by chance
ye
?pdc
also that doesn't work
ty
ofcofc
I hate how clunky it is
Oh ur on paper
ye
paper discord is so dead
Everyone there just asks questions and nobody responds
Use NamedTextColor
It's more active earlier in the day
clunky? idk feels a lot better than adding remapped jars and reflection and whatnot
- its use for entities is godsend
Maybe just a personal preferance for me but since 1.13 ive rarely touched nms cause of it:p
true
That doesnt have reset
oh yeah the long name bothers me
Also, default lore color is purple, so you need to set it to white or something
yep for my plugins i normally make some type of wrapper for em as well
I hate seeing getPersistantDataContainer spammed throughout my main codes logic 
Color isn't the issue
Its that it's italic
ngl that modify meta consumer is pretty smart
definatly stealing that one
So I can just
EntityPDCWrapper pdc = new EntityPDCWrapper(plugin, player);
pdc.setString("joe", "mama");
pdc.has("joe") -> true
surprised no ones just made a straight up lpublic wrapper for modifying PDC containers
like ik they exist in libs ofc
This is java gotta make an IFactory
i stg some class hierarchies have me ctrl + clicking for 20 seconds
How do I add stuff into the enchantment table loot pool idrc if it shows up just need to add it
I know you linked something earlier but I can't find it
Reminds me of Spring

How do I check if a villager is a enchanter?
where is the book from
val book = ItemStack(Material.ENCHANTED_BOOK)
book.addEnchantment(Replanting(key), 1)
Custom enchantments won’t work automatically
you want stored enchants and item meta
Also you need to add it as a stored enchant
also yeah custom enchants arent a thing
Still doesn't work with it as a stored enchant
This is my replanting class
package atk.plugins.dusk.enchantments
import io.papermc.paper.enchantments.EnchantmentRarity
import net.kyori.adventure.text.Component
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.Tag
import org.bukkit.enchantments.Enchantment
import org.bukkit.enchantments.EnchantmentTarget
import org.bukkit.entity.EntityCategory
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.inventory.ItemStack
class Replanting(key: NamespacedKey) : Enchantment(key) {
override fun translationKey(): String {
return "Replanting"
}
@Suppress("OVERRIDE_DEPRECATION")
override fun getName(): String {
return "Replanting"
}
override fun getMaxLevel(): Int {
return 1
}
override fun getStartLevel(): Int {
return 1
}
override fun getItemTarget(): EnchantmentTarget {
return EnchantmentTarget.TOOL
}
override fun isTreasure(): Boolean {
return true
}
override fun isCursed(): Boolean {
return false
}
override fun conflictsWith(other: Enchantment): Boolean {
return false
}
override fun canEnchantItem(item: ItemStack): Boolean {
return Tag.ITEMS_HOES.isTagged(item.type)
}
override fun displayName(level: Int): Component {
return Component.text("Replanting $level")
}
override fun isTradeable(): Boolean {
return true
}
override fun isDiscoverable(): Boolean {
return false
}
override fun getRarity(): EnchantmentRarity {
return EnchantmentRarity.UNCOMMON
}
override fun getDamageIncrease(level: Int, entityCategory: EntityCategory): Float {
return 0f
}
override fun getActiveSlots(): MutableSet<EquipmentSlot> {
return mutableSetOf(EquipmentSlot.HAND)
}
}
How would you disable your plugin in code?
JavaPlugin#PluginLoader#disablePlugin()
Any other way?
I mean, you could make a boolean and use it everywhere. Although that's a bit of a pain.
package org.ecucraft.slimebobplugin;
//import com.mysql.cj.jdbc.MysqlDataSource;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Objects;
public class SlimeBob extends JavaPlugin implements CommandExecutor {
private JDA jda;
public String dbAddress = getConfig().getString("dbAddress");
public String dbUsername = getConfig().getString("dbUsername");
public String dbPassword = getConfig().getString("dbPassword");
@Override
public void onEnable() {
this.saveDefaultConfig();
Objects.requireNonNull(getCommand("debugDiscord")).setExecutor(this);
getLogger().info("slimebob is here");
String discordBotToken = getConfig().getString("discordBotToken");
try {
jda = JDABuilder.createDefault(discordBotToken).build();
} catch (Exception e) {
e.printStackTrace();
}
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUser(dbUsername);
dataSource.setPassword(dbPassword);
dataSource.setServerName(dbAddress);
try {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("ERROR");
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onDisable() {
if (jda != null) {
jda.shutdown();// Plugin shutdown logic
}
}
private class ReadyEventListener extends ListenerAdapter {
@Override
public void onReady(ReadyEvent event) {
getLogger().info("Discord API Connected");
}
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//return discordBotToken in chat
String discordBotToken = getConfig().getString("discordBotToken");
if (command.getName().equalsIgnoreCase("debugDiscord")) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage(discordBotToken);
} else {
sender.sendMessage(discordBotToken);
}
return true;
}
return false;
}
}
When I try to build it is saying it cannot find the symbol "MysqlDataSource". I have a feeling I have imported sql wrong but im not entirely sure how
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Objects;
should be all the imports i need right?
I have got the connector in the build path, and I believe ive set up the class path correctly
You don't need the connector at all, spigot includes it
And jdbc is built into java
it does :O?
how could I bounce a player back. I want to make it kinda smooth
so I should be able to delete the conectors I have
Custom enchantments won’t work automatically
So how should I handle it? Since someone earlier said to extend the enchantment class
I wonder could you register Enchants with the server registry?
tysm
so when I write in the imports, as soon as I write the line it is dissapearing from the IDE? any idea why this would be happening
it ocmes up as an option
but as soon as I write the line is vanishes
Don't tell me you manually import.
im new to java gimmie a break 😂 Im a c# boy haha
plus, every guide ive followed has told me to manually import, so im not sure what you're saying
all the above imports I didn't do manually though
Ahh, well pro tip. Write the name of the class, then while your cursor is at the end or somewhere in the middle of the text, press ALT + ENTER and then select the option to import.
cheers. Im using this module too, is that a good way to do things?
There's nothing wrong with using it. People say that it uses a lot of memory though although I haven't ever had that issue.
that did all the spigot imports automatically
Don't know why the import would be disappearing though.
so, if I have everythign configured correctly, this shoudl auto detect what im doing right?
Typically when you start typing, you'll also get suggestions.
ngl im so lost, i know this should be simple but ive spent so many hours with no luch
luck
this is what im not getting
your IDE did not index shared libraries then
you may have declined the prompt on accident
google how to enable it
aight, ill give that a go
so I dont have the plugin installed and its asking me to pay. could this be because im using the community edition? I did read something a few days ago about JDBC integration only being on the full version
No you don't need either of those
Oh the fuck it is a paid plugin
Okay I guess it's not needed that
There's no way intellisense is not included in community
You don't have to pay to use the JDBC. What you pay for is the Database Tools that IJ provides.
They do make life a little easier if you have them though.
Don't have to download extra tools.
if a player/mob die for charged creeper, DamageCause will be ENTITY_ATTACK right?
my issue with MCDev plugin is that its almost completely useless outside of Fabric development 
for me at least, the only thing i ever use in it is Mixin autocomplete

