#development
1 messages Β· Page 139 of 1
so the taskID
is a field variable that is not dependent on the player's name
What you should do is make a runnable class
or just store all taskIDs to a list if you wanna do this
I personally would make a runnable class that does everything at once
so one runnable that goes every 20 ticks, doing all the ability stuff
ah okay, could you possibly make a small example of how that would look? using a runnable class instead?
gives armor, removes armor, etc.
I would also change your items to be created only once
okay
create private field variables, initialize them in the constructor
instead of every right click
gotcha, okay
public class MinerRunnable extends BukkitRunnable {
private static //counter map
public void run() {
}
}
I'd say make a map per ability if you have multiple
and just add the player to it then they first activate
but that runnable should run every 20 ticks no matter what
Ahhh alright, i'll see if i can get that to work
How can I create a system to hides players' nametag but only visually to certain players? I want to hide the nametag If the player e.g: behind a block, sneaking, etc.
I think there is a packet for that?
Regarding threads when its done how can you get the results?
poobacks
Imagine you have List<BlockPos> of different positions. What is preferable the best method to figure out which of all those locations are the closed to the player?
a loop?
When a player is kicked, is the playerquit event called?
yea
pdc?
Cause I am having issues with pdcs where if I leave when the pdc is getting changed, it resets it
PDC = PersistentDataContainer
ic
So....
Well it means that by the time it changes, I am not online anymore
that might be ugly details of the implementation - if the event is called after the player data is saved, changes to it when handling the event won't be written anymore
Seems really hacky lol
all that versioning stuff is basically just a strategy pattern
what if getTag would be a Map<ServerVersion, String> getTagMethod?
Cause then I have to create a map entry of each version instead of specific ones.
there's getOrDefault
True. Wanted to stick with enums though but doesn't look like its possible in the way I want.
Ah... My thought process was if I do it as maps I still have to do multiple methods to check the version and add the input to the map so might as well use enums since it was basically the same. ("basically the same" in this case not all)
My issue is really just not being able to variablize as enum lol (Ex; Enum variable;)
?
Since I couldn't do Enum current; I went with trying to nest and use interface
I mean, you still need an interface for enums, how else would you be able to call that extra getMethod() on just Enum?
why don't you just write a strategy-pattern like implementation for each version?
^
it's the typical approach for a reason
Such as?
you have a common interface, e.g. Adapter, with methods that do what you need to do version-specific. Then, you have one implementation of that interface for each version
Cause I didn't wanna multi-class it
?
Just got rid of having a class per version xD
Is either what ywell suggested or reflections, there's no in between
what's the problem with that?
and what's the advantage of anything else?
I don't like having the same code in 17 different classes lol
Cleanliness...
so you rather write more code, less understable in one class?
Less code and to the point in 1 to 2 classes yes.
have fun debugging that mess ig
Haven't had a problem with it. Just have to add the method names for new versions but wanted to clean it up by using enums
I mean its cached so...
Might not even do enums cause its still a bunch of them spammed with getMethod() xD
so... you create one class per method with n objects each instead of n classes and one object at runtime
I wanna say not at runtime as I create the instance of the class async when its ready to be loaded.
Please don't tell me you use white theme
Of course I do.
burn the heretic.
I don't have weak eyes π
man, this is anything but clean
Read the message above that one lol
Still
Is that eclipse?
Yes
may i introduce you to my good friend extends
Try using extends on enum classes π
Read the conversation you necro posted too lol
necro posted? is this a forum
I mean that's literally what happened, you shared something and you literally asked for suggestions, then you proceeded to ignore every single response
Best term for the situation
your first message is 3 hours old
lol
Yeah convo ended over an hour before lucyy made a comment.
well it is a public chat, i can't imagine that you only wanted one person to respond
private static void createExample() {
ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "EXAMPLE");
List<String> lore = new ArrayList();
lore.add(ChatColor.translateAlternateColorCodes('&', "&7EXAMPLE LORE"));
meta.setLore(lore);
meta.hasItemFlag(ItemFlag.HIDE_ATTRIBUTES);
item.setItemMeta(meta);
Pole = item;
}```
Why does the ItemFlag.HIDE_ATTRIBUTES not work here?
The item still has attributes
"has"? You need addItemFlag
Yeah but posting long after a conversation ended... Meh
π€¦ββοΈ
its one c and two ys damnit >:(
I wonder how young one must be to still quantify 3 hours as long... I mean I know time seems to speed up as you get older, but....
I mean you can kill 2+ hours easily by watching a movie or 45m-1hr TV episodes
Time in that case just β¨vanishesβ¨
edited π
Luccy pronounced like cappuccino
oh god please no
IHaveARazor. Not sorry for necroposting.
i'm trying to get better at working with npcs and such, and i looked for some threads and found out how to add the top layer of a skin for example. they used this resource to figure out the id's: https://wiki.vg/Entity_metadata#Player
thing is because its updated for 1.19, and i'm working on 1.8, the index's aren't the same
so if anyone could help me understand how to get the old index from different versions that would be helpful
for example i know that this changes how the skin is displayed, and i understand this function fully, with 10 being the value to modify and the (byte 127) corresponding to which parts to display, but i'm not sure where the 10 is from, i know it's correct, but i can't find a page showing its value
DataWatcher watcher = npc.getDataWatcher();
watcher.watch(10, (byte) 127);```
for example here : https://wiki.vg/Entity_metadata#Player to change the same value i would do index 17 instead of 10
One option is just go to Entity -> EntityLiving -> etc -> EntityPlayer and count the order they register to the datawatcher
i don't understand...?
The index represents the order in which it is registered to the datawatcher
i'm not exactly sure how to do this though
So for example (this is 1.16.5) this shows where they register each part of the datawatcher for Entity
You can see that the second is at least named so you can tell what it is
idk if this is relevant but 1.8 doesn't have a DataWatcherRegistry
Yeah, it's a bit more manual
wait so this is in the Entity class?
I'm just helping you understand the general idea
Yes
And if you look on the wiki.vg for Entity, you can see it lines up (at least ignoring the newer stuff)
It's a bit less terse with 1.8.8
yea i saw that
i can't find anything like that in the EntityPlayer class though
am i doing something wrong?
It's probably EntityHuman
lemme check
yup
yea you're right
wait so
sec
wait so okay i can see the methods now
but how can i figure out what each of them actually does
like with an older version of the wiki...?
You might be able to look at an archived version, yeah
But I meant the current one
This might help as well
This was for 1.16
wait what class is this
It's from my own library I made once
well this has been really informative, thank you
No problem! I looked deep into this for 1.16 because I made npcs that worked with pathfinders but looked like players (and weren't EntityPlayer)
I'm trying to create a sell GUI where players place their items into a gui then click the sell button to sell them. I've come across this problem:
if (e.getView().getTitle().equals(ChatColor.DARK_GRAY + "Ore Merchant")) {
//if they inside of sell gui
if (e.getSlot() == 49) { //if they click sell button
player.updateInventory();
for(int i = 0; i<=53; i++) {
if (!(inv.getItem(i) == null)) {
Bukkit.broadcastMessage(inv.getItem(i).getType() + "");
if (isGem(inv.getItem(i))) { //if its a gem
inv.setItem(i, new ItemStack(Material.AIR));
Bukkit.broadcastMessage(i + "WORKED");
}
}
}
}
}```
When they place the items inside the GUI and click the button it this acts like the items don't exist and are skipping over them like they are air blocks.
Its ugly but gets the job done :/ (visually)
not sure how I could clean it up
you should probably actually send the isGem function
public static boolean isGem(ItemStack item) {
if (item != null) {
if (item.getItemMeta() != null) {
if (item.getItemMeta().getLore() != null) {
if (item.getItemMeta().getLore().size() >= 0) {
if(item.getItemMeta().hasLore())
if (item.getItemMeta().getLore().get(0).equals(Ores.FineAmber.getItemMeta().getLore().get(0))) {
return true;
} else {
return false;
}
}
}
}
}
return false;
}```
All the items hold the same first line of lore
why do people keep identifying items with lore...
use nbt tags :/
I would if I knew how to but havent learnt that yet
So i am trying to get "exampleCategory" from my json file but when i try this is gives a null value,
here is my json file: ```json
{
"categories": {
"exampleCategory": [
"avoir/hebben",
"etre/zijn"
]
}
}
This is what i have tried so far but gives the null value:
`JSONArray jsonArray = (JSONArray) jsonObject.get(JsonObject.get("exampleCategory"));` & `JSONArray jsonArray = (JSONArray) jsonObject.get("categories.exampleCategory");`
if (!(inv.getItem(i) == null)) => if (inv.getItem(i) != null)
JSON is not yaml, you can't use .
try getting the categories object first then get the exampleCategory array from that
ty that makes it look nicer
I'd recommend trying that
with this code
The brackets were from me testing debug messages
The debug messages just skip over all the items I place in the GUI and just print out the glass and player heads
public static boolean isGem(ItemStack item) {
if (item != null)
if (item.getItemMeta() != null)
if (item.getItemMeta().getLore() != null)
if (item.getItemMeta().getLore().size() >= 0)
if(item.getItemMeta().hasLore())
if (item.getItemMeta().getLore().get(0).equals(Ores.FineAmber.getItemMeta().getLore().get(0)))
return true;
return false;
}```
oh my
size() >= 0
this will always be true tho
either the list is empty or it isn't
I see what you were saying about the brackets
but not what I was referring to
this is my most recent sellmenu class https://paste.helpch.at/ziqigesezi.java
the way you're opening the inventory now, you will run into the problem that it's the same inventory for everybody
Your one is very pretty but I dont understand it
Its just all GLASS and HEADS but the items I place in it are COAL
so it never said WORKED right?
Yea never said it
add more debug messages back to isGem
When I put in Bukkit.broadcastMessage(inv.getItem(i).getType() + "");
It doesnt notice the items I place in the GUI at all
So it never accepts isGem because all it is checking is the Background items and the button itself
where do you have room to put items?
Inside of the GUI where I place AIR
On line 48
I guess I dont need to put anything there since nothing is air anyway
Bukkit.broadcastMessage(e.getCursor().getType() + "");
take a look at mine
final Player p = (Player) e.getWhoClicked();
if (e.getRawSlot() >= 45 && e.getRawSlot() <= 53)
e.setCancelled(true);
if (e.getRawSlot() >= 45 && e.getRawSlot() <= 48) {
p.getOpenInventory().close();
} else if (e.getRawSlot() >= 50 && e.getRawSlot() <= 53) {
double totalValue = 0; //items to sell
double totalAmount = 0; //value of items
for (int i = 0; i <= 44; i++) { //loop through inventory
ItemStack currentItem = e.getClickedInventory().getItem(i); //Current Item in the slot of the CLICKED inventory
if (currentItem == null) {
continue;
}
String itemName = currentItem.getType().toString().toLowerCase();
if (!allItems.containsKey(itemName)) {
continue;
}
double sell = allItems.get(itemName).getSell(p); //gets the sell price
ItemStack blankItem = new ItemStack(Material.getMaterial(itemName.toUpperCase())); //retrieves a blank copy of the item I'm checking
if (currentItem.isSimilar(blankItem)) { //checks if the current item is the item to compare to
int amount = currentItem.getAmount();
e.getClickedInventory().setItem(i, null);
DeluxeShop.getEconomy().depositPlayer(p, sell * amount); //sells the item
totalAmount += amount; //adds item amount
totalValue += (sell * amount); //adds sell value
}
}
if (totalAmount == 0) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8Nothing to sell!"));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&6Successfully sold &a" + totalAmount + " items &6for &a" + DeluxeShop.DECIMAL_FORMAT.format(totalValue)));
}
p.getOpenInventory().close();
you see I get the actual inventory the player is using, from the event
instead of the field variable
no, I guess I sent a lot
How does your one work?
Mine works by loading all the items into the GUI then clicking the sell button
Then it for loops through all the slots, checks if its a gem then if it is it broadcasts WORKED
I cant visualize yours, that is what is making it difficult for me to understand what is does or how it works
I added some comments
The big difference between me and you
ItemStack blankItem = new ItemStack(Material.getMaterial(itemName.toUpperCase())); //retrieves a blank copy of the item I'm checking
if (currentItem.isSimilar(blankItem)) { //check
is this
because I compare it to another item
you use an isGem(currentItem) method
basically, just try changing it to #getClickedInventory and use that
just see if it works
if you're confused still send your class
I understand yea
if (e.getView().getTitle().equals(ChatColor.DARK_GRAY + "Ore Merchant")) {
//if they inside of sell gui
if (e.getSlot() == 49) { //if they click sell button
player.updateInventory();
for (int i = 0; i <= 53; i++) {
ItemStack currentItem = e.getClickedInventory().getItem(i);
Bukkit.broadcastMessage(currentItem.getType() + "");
if (currentItem == null) {
continue;
}
if (isGem(currentItem)) { //if its a gem
Bukkit.broadcastMessage(i + "WORKED");
}
}
}
}```
It says worked now
Thank you for your help
and thank you for being patient
SellGUI gui = new SellGUI();
gui.openInventory(target);```
this runs when they do the cmd
also try some for loops for items vs 1 for loop and a bunch of ifstatements
oh that's not what you wanna do
when do you register the listener?
ohhhh\
I think I know why it wasn't working earlier
In onEnable()
with a new instance of SellGui
every time you run the command, you make a new instance of it
which is NOT the listener
instead you should store it when you register it, then just use gui.openInventory(target)
I use to do that but when two players had the same GUI open they could see what each other were putting in it
exactly what I said
earlier
so what you want to do is make a new inventory in the openInventory part
not make a new SellGui in the command
my sellmenu for reference: https://paste.helpch.at/ziqigesezi.java
basically just gotta move the itemsetup to the openInventory part
I have it set up with init() then init() is inside of openInventory
public void initializeItems() {
createSell(0);
createBackgroundItem();
createInformationBook();
for (int i = 0; i <= 53; i++) {
if (i == 49)
inv.setItem(i, SellItem);
if (i == 4)
inv.setItem(i, InfoBook);
if (i == 0 || i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 12 || i == 13 || i == 14 || i == 17 || i == 18 || i == 26 || i == 27 || i == 35 || i == 36 || i == 39 || i == 40 || i == 41 || i == 44 || i == 45 || i == 46 || i == 47 || i == 48 || i == 51 || i == 52 || i == 53 || i == 54 || i == 50) {
inv.setItem(i, BackgroundItem);
}
}
}
// You can open the inventory with this
public void openInventory(final HumanEntity ent) {
initializeItems();
ent.openInventory(inv);
}```
Wait really I've been doing it wrong all this time
so the create part i put in open as well
remove the field variable inv
inv = Bukkit.createInventory(null, 54, ChatColor.DARK_GRAY + "Ore Merchant");
yep
if you remove the field variable first the IDE will start yelling at you
easy to see where you have to make other changes imo
So what do I put int SellGUI()
public class SellGUI implements Listener {
public ItemStack SellItem;
public ItemStack BackgroundItem;
public ItemStack InfoBook;
//(X/100)x15 MINING FORTUNRE EQUATION
public SellGUI() {
}
// You can open the inventory with this
public void openInventory(final HumanEntity ent) {
Inventory inv = Bukkit.createInventory(null, 54, ChatColor.DARK_GRAY + "Ore Merchant");
ent.openInventory(inv);
createSell(0);
createBackgroundItem();
createInformationBook();
for (int i = 0; i <= 53; i++) {
if (i == 49)
inv.setItem(i, SellItem);
if (i == 4)
inv.setItem(i, InfoBook);
if (i == 0 || i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 12 || i == 13 || i == 14 || i == 17 || i == 18 || i == 26 || i == 27 || i == 35 || i == 36 || i == 39 || i == 40 || i == 41 || i == 44 || i == 45 || i == 46 || i == 47 || i == 48 || i == 51 || i == 52 || i == 53 || i == 54 || i == 50) {
inv.setItem(i, BackgroundItem);
}
}
}```
And do I still use:
SellGUI gui = new SellGUI();
gui.openInventory(target);```
Inside of my command?
no, do not make a new SellGui
you have to use the one you originally create in onEnable
all you do is gui.openInventory(target) (probably plugin.sellGui.openInventory(target) or something similar)
And what do I put in onEnable?
Since SellGUI() is completely empty in the SellGUI Class
I use an API for Command Class
Startup Function which is called in onEnable()
https://paste.helpch.at/fiyezukesa.java
Sell GUI Class:
https://paste.helpch.at/afegocegin.cs
idk how to help you man
it's honestly all over the place
idk why you have a StartUp class and a startup method outside of your main class and outside of onEnable
basically you should be instantiating the command class with an instance of your plugin that you can later call back to to access the SellGUI listener instance you create
Please do if (i > # && i < #) instead of checking each one
better than my idea
so right now i'm trying to create custom pathfinding npcs for 1.8. basicly the idea is that they can follow and fight eachother. https://www.spigotmc.org/threads/tutorial-creating-custom-entities-with-pathfindergoals.18519/ i tried to follow this tutorial, but i don't believe EntityPlayer has pathfinding goals, and i don't know how to get around this other than creating my own pathfinding logic, which would be difficult and most likely inefficient. could anyone help? thanks
Question, so i have this command and im making a bitcoin farm type thing. But when i add it to the players inventory it doesnt do anything. im in 1.8, but that shouln't matter as i add stuff to inv multiple times elese where.
System.out.println(args.length);
if(args.length < 2) {
new FarmGui().makeGui(player);
} else {
if(args[1].equalsIgnoreCase("give")) {
org.bukkit.inventory.ItemStack gpu = new org.bukkit.inventory.ItemStack(Material.matchMaterial(main.getConfig().getString("farm.gpu.material")), main.getConfig().getInt("farm.gpu.amount"));
ItemMeta im = gpu.getItemMeta();
im.setDisplayName(Utils.color(main.getConfig().getString("farm.gpu.name")));
im.setLore(Utils.color(main.getConfig().getStringList("farm.gpu.lore")));
gpu.setItemMeta(im);
if(args.length == 2) {
System.out.println(player);
System.out.println(gpu);
player.getInventory().addItem(gpu);
} else {
if(Bukkit.getPlayer(args[2]) == null) {
player.sendMessage(Message.INVALID_PLAYER.getMessage());
} else {
Player t = Bukkit.getPlayer(args[2]);
t.getInventory().addItem(gpu);
}
}
}
}
} ``` Everything souts as it should
Try with Player#updateInventory after adding the item
i tried that but that didnt change anything
I'm having a really bizarre issue where some entities won't spawn unless the world has been loaded by a Player since restart (using Bukkit.getWorld.spawnEntity) Anyone know why this might be the case?
you sue that the chunk you are spawning the entity in is loaded?
Does it have to be?
Yes
Because I have other entities closer to the world's spawn point that load in fine
Either way, there is no player in the world
Thats strange, I guess I'll force load it
@NotNull
Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type, boolean randomizeData)```
Creates a new entity at the given Location.
loc - the location at which the entity will be spawned.
type - the entity type that determines the entity to spawn.
randomizeData - whether or not the entity's data should be randomised before spawning. By default entities are randomised before spawning in regards to their equipment, age, attributes, etc. An example of this randomization would be the color of a sheep, random enchantments on the equipment of mobs or even a zombie becoming a chicken jockey. If set to false, the entity will not be randomised before spawning, meaning all their data will remain in their default state and not further modifications to the entity will be made. Notably only entities that extend the Mob interface provide randomisation logic for their spawn. This parameter is hence useless for any other type of entity.
the spawned entity instance.
Wow, that was really the solution to the bug I've been tearing my hair out about for 2 days
I really appreciate that
That's slightly embarassing
i'm following this tutorial for 1.8: https://www.spigotmc.org/threads/tutorial-creating-custom-entities-with-pathfindergoals.18519/
and it's working fine, but i'm trying to make it go to a set location with this: ```java
public class PathfinderToLoc extends PathfinderGoal {
private double speed;
private EntityInsentient entity;
private Location loc;
private NavigationAbstract navigation;
public PathfinderToLoc(EntityInsentient entity, Location loc, double speed)
{
this.entity = entity;
this.loc = loc;
this.navigation = this.entity.getNavigation();
this.speed = speed;
}
public boolean a() {
return true;
}
public void c()
{
PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ());
this.navigation.a(pathEntity, speed);
}
}```thinig is, this just isn't working. the zombie just isn't moving to the position at all
it's implemented in the actual custom class and all: java this.targetSelector.a(new PathfinderToLoc(this, new Location(world.getWorld(), 0, 82, 0), 1.0D));
π₯΄
how about just
Set<T> backgrounds = new HashSet<>(Arrays.asList({0,1,2,3,5,6,...}));
if (backgrounds.contains(i) ) {
inv.setItem(i, BackgroundItem);
}
(you would actually want the list of backgrounds as a final static variable but you get the gist)
can anyone help w/ this?
anyone?
Idk
Hello everyone, I recently started developing plugins, so I still donβt know much, so I immediately apologize for the stupid questions. Is there any way to keep track of when a mob enters and exits (this must be checked) from a certain player radius? When the mob enters the radius (you can check .getNearbyEntities) and when it leaves it. I want that when a mob enters the player's radius, he was given a glow effect, and when he left, the effect was removed. And the radius values are static
Right so you basically can just make a simple runnable which loops through all online players. Then you can get the playerβs location inside that loop, and getNearbyLivingEntities with whatever radius you want, loop through those entities and give them the glow effect for like 3 seconds
You are genius
Far from it, just simple problem solving!
how do i get the BaseComponents part for Player.Spigot.sendMessage()?
it doesnt have a constructor and in documentation says its only for internal classes
is there another way to give a String into Player.Spigot.sendMessage()?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.Spigot.html#sendMessage(net.md_5.bungee.api.ChatMessageType,net.md_5.bungee.api.chat.BaseComponent)
https://javadoc.io/doc/net.md-5/bungeecord-chat/latest/net/md_5/bungee/api/chat/BaseComponent.html
found it!
had to use TextComponent.fromLegacyText()
?not-discord
Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.
yeah, the camera is on, but my friends can't see my video, my video just buffering
Read what the bot sent.
okay thanks
i've been trying to get this to work for 2 days, and it's just not working. anyone know why?
like the zombie just isn't doing anything
omg i just got it to work
let's fricking go!
So in 1.18.2 I used ChatComponentText but it looks like it was removed in 1.19 Any one know its replacement?
Seems like before you had IChatBaseComponent, but now it's just Component as the interface and MutableComponent is the only class that implements it
They probably changed things up because of the whole preview thing
Saw that but can't figure out how to get text -> IChatBaseComponent which is still used to set an entities custom name
I was using setCustomName(new ChatComponentText("Entity Name"));
I was comparing non mojang mappings to mojang mappings, hold on a sec haha
π I could use IChatBaseComponent.ChatSerializer.fromJson(String) I think but what was the component changed to if not {TextComponent=}
Huh, it looks like there really is only one class that implements that interface now
Oh okay I think I get it now
(I'm back in mojang mappings for this explanation btw) So Component has getContents() which returns ComponentContents which is where the text lives
It seems a bit different than before though, as the interface ComponentContents doesn't have methods to interact with the innards
You'd have to get the implementation to do that
LiteralContents seems to be what you're looking for though
fuck up
it's "to.fuck"
presumably that is more of an active action rather than a casual expletive
Do I need to constantly update my placeholders within a task or something or are they automatically updated by papi
Like if I have them in a scoreboard and the value updates from my plugin, will papi automatically detect the change
that is not papi's responsibility
it's the responsibility of whatever's using the placeholders
So then run a task to update?
yes...?
to <Blank> or not to <Blank> ... Something alot of people quote
lol
@winged pebble
// 1.18.2
setCustomName(new ChatComponentText("Text"));
// 1.19
// Unmapped
setCustomName(Component.literal("Text"));
// Mapped
setCustomName(IChatBaseComponent.a("Text"))
Hmmm, interesting I didn't see a static literal method
Weird, it's there now
Maybe I was looking at the wrong version lol I've got like 4 pulled up
Its in the unmapped Component class
Yeah I must have pulled up the 1.18 on accident
Yeah took me a few hours to find xD
Does anyone have any idea what would cause this exception to happen? Somebody reported it for one of my plugins and I've never seen anything like it before https://paste.helpch.at/yafokujuda.sql
I'm somewhat inclined to blame AuthMe for not relocating their custom mysql driver
you could ask them to remove authme and test without and then if it does work just blame authme :))
They have my plugin on another server and it's working fine so I asked them if AuthMe is also installed on that one. I'll have them try that if they're willing, ty for input
yes very useful input from me. I am very useful. ||I know I'm not||
I wonder if I could just put a loadbefore for authme 
sigh Gotta new issue.... IChatBaseComponent removes hex color
Any ideas about this? It works on spawned armorstands but not packet based armorstands
Would prefer to not have to go into editing the DataWatcher
You shouldn't have to because setCustomName() and getCustomName() interact with the datawatcher I thought
They do but I might have to set the string instead of the IChatBaseComponent
Looking into it
Hmmm.... Actually it might be reflection
If a class has multiple methods named the same and have the same parameters but return different types which does reflection use?
public String a(String s) {}
public IChatMutableComponent a(String s) {}
public void a(String s) {}
thats not possible lol
you cant have 2 methods with the exact same name and signature
π±
Tell that to mojangs mapping
There is something similar that happens when you try to extend an EntityInsentient
And intellij throws a fit about it (rightly so)
Thanks BM
yw
I get that but spigot mapped it like this so IDK what to do xD
god knows lmao
Cry
something like that
I would
Might have to edit the datawatcher directly then...
I mean that's definitely valid at class file level, just not in source lol
yeah true
Not finding any, does reflection have any way to get a method based on name and return type?
well not in Java, but for the jvm only the descriptor matters
MethodHandles π
mm i realise that
i guess it's a decompiler error then?
those are spigot mappings π₯΄
if you just change the mappings of the jar, it's still a valid class file but you can't decompile it to correct java code anymore
i dont know nor care what mappings are
but you can also mess with most decompilers by just writing something like
class A {
static {
class B {};
new B();
}
static {
class B {};
new B();
}
}
fiend
(this is art)
I'm just gonna search the methods and cache the right one.
Welp even when its using the right method hex colors are removed...
are you shoving legacy codes into components?
because legacy formatting never supported hex colouring, that's a spigot invention that happens only in legacy -> component deserialisation
#084cfb-#2165fb-#3a7efc-#5297fc-#6bb0fc-#84c9fd-#9de2fd-#a9eef6-#9bdee0-#8ececa-#80bfb5-#73af9f-#659f89-#588f73-#547f72-#556f7a-#565f82-#574f8a-#583e93-#592e9b-#5a1ea3-
// 1.18.2
setCustomName(new ChatComponentText("Text"));
// 1.19
// Unmapped
setCustomName(Component.literal("Text"));
// Mapped
setCustomName(IChatBaseComponent.a("Text")) //<---------- This
that still isn't showing how you're actually deserialising it
because if you're just shoving that text into that method then it will show the text literally as-is
I'm not understanding what you're asking then.
oh like how I color it π€¦ ?
How are you turning that literal text you sent above into a component
not what method you're using
the actual code
the actual process
That is the actualy code xD
no it's not
Then I'm still not understanding...
you're doing .a("Text"), not .a("#084cfb-#2165fb-#3a7efc-#5297fc-#6bb0fc-#84c9fd-#9de2fd-#a9eef6-#9bdee0-#8ececa-#80bfb5-#73af9f-#659f89-#588f73-#547f72-#556f7a-#565f82-#574f8a-#583e93-#592e9b-#5a1ea3-")
because that will print that exact text
the actual real code you have written right in front of your eyes
how are you turning this literal text
#084cfb-#2165fb-#3a7efc-#5297fc-#6bb0fc-#84c9fd-#9de2fd-#a9eef6-#9bdee0-#8ececa-#80bfb5-#73af9f-#659f89-#588f73-#547f72-#556f7a-#565f82-#574f8a-#583e93-#592e9b-#5a1ea3-
into a component exactly
well see?
that's different
I asked you if you meant the coloring
and yes you're shoving legacy shit inside components, which is confirmed the client will one day stop supporting, and which again that thing never worked with hex codes
I mean you don't "colour" a component but sure
So what would you suggest?
Deserialize from legacy in the CraftChatComponent class I think it's called
Found it (I hope)
yes fromString/fromStringOrNull
So right now i'm attemping to use PathfinderGoals with npcs. I got it to work with zombies and right now i'm not doing any navigation but just trying to turn the npc's head. here is the npc's code: ```java
public class Bot extends EntityPlayer {
public Bot(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super(minecraftserver, worldserver, gameprofile, playerinteractmanager);
}
}
}``` with the zombie i could just create a new CustomZombie and bam, that works, but that doesn't work with this, probably because it's an EntityPlayer. could anyone help with spawning this entity in? would i have to do it with packets or some other way
i haven't gotten to adding the pathfinding goals yet because i'm still trying to spawn a bot in like this
You can't use pathfinding goals with EntityPlayer
At least not any existing ones
unless u git gud
just tryna get this to spawn first tho
You're most likely going to have to use packets btw
yea i figured it out
i'm obviously doing something wrong but i can't figure out what. here is my bot class rn: ```java
public class Bot extends EntityPlayer {
public Bot(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super(minecraftserver, worldserver, gameprofile, playerinteractmanager);
PathfinderGoalSelector goalSelector = new PathfinderGoalSelector(this.u().methodProfiler);
goalSelector.a(0, new PlayerGoalLookAtPlayer(this, EntityHuman.class));
}
}``` and the PlayerGoalLookAtPlayer is this: https://www.toptal.com/developers/hastebin/uroyufagun.kotlin
thing is in the goal not even the system outputs are printing anything, so i'm obviously doing something wrong with the goalSelector, but i can't figure out what
Doesn't seem like you're storing it as a field or anything to be used later
You have to add the logic that cycles through goalSelectors too
wait storing what as a field
the goalSelector
You're just creating a local variable and then it goes away basically
i mean i'm using it in the line right after that
Yeah you're adding a goal, but then right after that, they both go away
i see what you mean
goalSelector doesn't do its job on its own, it needs to be told what to do basically
Look in EntityInsentient for the method that actually handles that logic
You'll have to reimplement that
alright thanks
hmm.. the thing relating to goalSelector in EntityInsentient are these 3 lines:java // in constructor this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); and ```java
//in the doTick() method
this.world.methodProfiler.a("goalSelector");
this.goalSelector.a();
goalSelector.a() just returns true or false, not void. also methodProfiler is used quite a bit but looking at the class it's just an abstract class with empty methods, so i'm not really sure what to make of that
remind me what version you're in?
1.8
i'm trying to figure out how EntityInsentient handles the goals and navigation and such but i'm struggling
In 1.8.8 it's eN()
can i ask how you figured that out
Well I found it on 1.19 and when I opened it on 1.8.8 it took me to the exact same place luckily π
is that in the EntityInsentient class?
hmm i gues 1.8.8 is slightly different thatn 1.8.9. anyway, i still don't understand where the logic is being handled in this method
this is doTick() in 1.8.9
Here is the mojang mapped version from 1.19 (makes it easier to parse)
i'm looking at the method profiler class, and obviously it's being overriden somewhere because all i see is this: ```java
public class MethodProfiler {
public boolean a;
public MethodProfiler() {
}
public void a() {
}
public void a(String s) {
}
public void b() {
}
public List b(String s) {
return null;
}
public void c(String s) {
}
public String c() {
return null;
}
}```
It shouldn't be anything you'd need to implement yourself, is it?
I see, but you're just trying to understand what it does
i'm confused why a is being called when a doesn't do anything
Ignore this btw, I was opening the unmapped 1.19 version on accident
Took me too long to notice haha
i understand why my code isn't working but i don't understand why mojang's code works and how it works
It's probably just a decompilation issue tbh
It's also possible that it was a work in progress thing
That they hadn't finished implementing it
Long story short, the profiler seems to be more of a monitoring thing, than a behavior thing
I don't think you need to worry about it too much right now
then how does the goalSelector work
The doTick() is run every tick
And it calls the .a() method on the goalSelector which is basically it's tick method
isn't .e() supposed to be the tick method?
so could I solve this by having a runnable that calls a method to properly update every custom npc?
Potentially, yeah
Another option you could do is actually just make your class extend EntityInsentient and fiddle with a few things to make it look like a player to the client
I don't know how to do this in 1.8 though
i feel like adding a tick method is a lot easier than looking through 900 lines of code, though i might have to do it anyway
anyway i'll try to implement this, thanks for the help!
i wonder how i'll make that work with Navigation though...
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/bukkit/craftbukkit/bootstrap/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Someone can help? i keep receiving this trying to run my local server (Spigot 1.18.1), i changed the java env path, tried to run it from java 8 folder, nothing worked so far
you can't run 1.18 with java 8
is there a library or something to parse a formatted string like 1k to an int like 1000?
If what you want to do is not complex, you can just do some simple string replacements on the string before parsing it with Integer.parseInt
So i'm trying to work with Navigation and Pathfinding and all that right now, and i'm trying to figure out how this all works (1.8.9 btw). I've been staring at this code for hours now and i just don't understand how Navigation causes entities to move. i have a test custom goal right where inside the e() method this is run: ```java
PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ());
this.navigation.a(pathEntity, speed);
Does anyone know what the best way to handle enabling and disabling worlds for a plug-in?
you want to disable plugins in a world?
wouldn't you just have an if statement or something checking the name of the world?
Just disable events in my plug-in.
like disable code being runwhen an event happens?
just add an extra check in your event handlers to check world. at least for those events that are world based
Ahhh okay Iβll try that
Could you give a small example? Iβve tried a few ways and itβs not working for me
I mean it really depends on your event really.
can you send one of your event handler methods you want to do this for in a paste bin?
if enabledWorlds !contains world, return / if disabledWorlds contains world, return
anyone?
just get the player that clicked, check their world and return if its not in the world you want it to work in.
ah okay, thank you
if ((plugin.getConfig().getStringList("blocked-worlds")).contains(e.getPlayer().getWorld().getUID())) return;
^ is this done correctly?
oh should i getName()
well depends how you want the config list to work
with world names or with world UUIDs
if you want it to work with world names then yeah change it to getName
kk
if ((plugin.getConfig().getStringList("blocked-worlds")).contains(e.getPlayer().getWorld().getName())) return;
so like this?
@torn heart https://minidigger.github.io/MiniMappingViewer/#/spigot/server/1.14.4/NavigationAbstract
Idk if have looked at something like this but it might help demystify a little of what is going on. I know it's 1.14.4 (Pretty much the earliest I could find for mojang mappings) But I often used this to help me make sense NMS
Some of the names will be different because it uses the Mojang Mapping name, (ie Mob -> EntityInsentient, Level -> World) but it should help a little bit
i already looked at it
ill check again but not rn, but when i was checking i still didn't really understand how it caused movement but it's 31 C rn and opening intellij causes my hands to start sweating because of this mac and i just wanna take a break
The MoveController is what actually moves the mob
does MMV work? 
It's not updated, no. Pretty much only reliable for 1.14.4 -> early 1.16's
I can read minidiggers a bit better
yeah and mini's is unmaintained and outdated lol
Half the time I just need to know the Mojang class name anyway lol
which may have changed in newer versions
ss is up to date, maintained and also has other mappings too
Yeah, but I also don't use it often at all anymore
umm anyone else having the issue of glow on items not showing up in 1.19?
well 1.19 isnt ready for production yet so imma assume its just a bug thats gunna be squashed at some point
yea but like
i'm looking at the class
it's just changing its own values
meaning that something else is calling it every tick or something like that, and idk what
The tick method probably
wait where is that
like in EntityInsentient?
because the tick method in that just calls a method inside The ControllerMove, but i'm not exactly sure what that does
the solution for this that i can think of is to write an entirely new movement controller for the entity but that would be really difficult, and i would much rather understand how the current ControllerMove works and then modify that to suit my needs
Anyone know why custom enchantments aren't appearing on the pickaxe, and they get removed on server restart?
Here's the code in onLoad: kt val field = Enchantment::class.java.getDeclaredField("acceptingNew") field.isAccessible = true field.set(null, true) for (enchant in Enchants.values()) { Enchantment.registerEnchantment(enchant.getEnchantment()) // A new NamespacedKey gets created in getEnchantment and is stored in memory } field.set(null, false) and the code to enchant: ```kt
pickaxe.addUnsafeEnchantment(enchant.getEnchantment(), newLevel)
And the enchant code: https://pastes.dev/CjqNVmnMPd
I'm pretty sure custom enchantments don't show on items. you have to add a lore line yourself for that. I remember having to deal with this a while ago
oh. that I couldn't tell you. is this for versions lower than 1.13?
lol. anyways check pinned messages. bm made a pretty nice example for custom enchantments on 1.13+ which I've used before.
π
If I have to drop a huge amount of items I saw that the best way is splitting it in multiple synchronized threads. How can I do it?
If you have multiple threads, they aren't synchronous
Idk, I found it here https://www.spigotmc.org/threads/making-this-async.342604/#post-3184424
Do you know another way to do it without causing lag?
Anyone know if theres a unicode placeholder for Β§
that's not correct. FAWE does most of the work on different threads (it splits up the work, but to do work in parallel). Other than AWE, which splits up the work and runs in synchronous over multiple ticks
\uA007 if you need its code
Yeah I tried that, It didnt like it
Oh Wait
I was using aa07
\ua007 returns whatever this is
κ
Cancel creeper being ignited by flint and steel? (1.8.8)
PlayerInteractAtEntityEvent#setCancelled(true) doesnt seem to be working
Did you register the event?
declaration: package: org.bukkit.event.entity, class: ExplosionPrimeEvent
Try this, idk
ofc i did
That prevent entities from exploding
not from igniting, sadly
(afaik)
yeah, confirmed
ExplosionPrimeEvent#setCancelled
make it stop before explode
but it's (ofc) white and about to explode
where is the target entity there
Debug? Check if when the event is ran if the creeper is primed and after canceling see if it's still primed.
Do creepers even have that?
why does everyone work in 1.8.8 instead of 1.8.9
There is no 1.8.9 server
The version was client side only, even though there is a Mojang server jar all it does is change the startup message, so there is no Bukkit for 1.8.9

How stupid would it be to call Location#distance every time a player moves (working with 8 players max, so not that many calls) but I'm assuming still a fairly costly operation?
Probably can avoid it
It's costly for a math operation, but you probably won't even notice a difference if it's only 8 players
yeah it's gonna be fine at that scale
Thought so
Guys is there a way to read a text and then check if it is or contains a java exception or is a minecraft log?
I mean, technically yes, but what are you trying to do?
if text.contains(minecraft) or text.contains(java)
Wanna make a bot that automatically uploads errors, java/kotlin code snippets and minecraft logs to a paste service
that sounds familiar
Yeah BM basically hit the nail on the head
Like, more nuance is required, but that's more or less the idea
I (and others) did this a while ago, just with a regex checking for the ```
or with files by file extension
thats smart, ill just check for files or '` ``'
π
Now last question, bot in python or kotlin
Kotlin bot is nice, never used py
But here's some examples of what we did:
Typescript: https://github.com/TheDeveloperDen/DevDenBot/blob/master/src/util/pastify.ts
Kotlin (outdated, lacks a few things): https://github.com/TheDeveloperDen/DevDenBot-old/tree/master/src/main/kotlin/net/developerden/devdenbot/pasting
ours is much more sophisticated, it'll convert each different codeblock into a single message, and the surrounding text
So
hello
Blah
Some more text
Blah2
Will become
Hello
Paste link
Some more text
Paste link 2
Do you delete the message the user has sent?
Yes
ah
BM is a tyrant
Brainwashed by the functional programming elites
BM is a godsend
paid for by BMTyrant.coβ’οΈ
I am the elites
where that
nono
kotlin compiler is too new
update the plugin lmao
Kt 1.7 is beta isn't it?
Oh yesterday, nice
What if the user adds 9 characters of code and fills the rest to the max limit, and the bot replaces it by a 10 long link, some text will be lost, won't it?
It doesn't convert blocks less than 15 lines long
Does anyone have any idea if it's possible to get a collection of all entities which are targeting a specific player?
Ohhhhhh
neverrrmind it is being reset :/
Anyone know why custom enchantments aren't appearing on the pickaxe, and they get removed on server restart?
Here's the code inonLoad:kt val field = Enchantment::class.java.getDeclaredField("acceptingNew") field.isAccessible = true field.set(null, true) for (enchant in Enchants.values()) { Enchantment.registerEnchantment(enchant.getEnchantment()) // A new NamespacedKey gets created in getEnchantment and is stored in memory } field.set(null, false)and the code to enchant: ```kt
pickaxe.addUnsafeEnchantment(enchant.getEnchantment(), newLevel)And the enchant code: https://pastes.dev/CjqNVmnMPd
The key used for the enchant is the same every time, so I don't know why it keeps resetting itself...
Okay well now it's not resetting
What
@winged pebble
π
@dusky harness you need to display the enchantments trough lore I believe
^
personally when i implemented custom enchantments i didnt go through adding enchants through the regular means, just created a custom compound tag with my data, and then in the compoundtag add another compound tag that has enchant_id:short
hey
i have problem on registering placeholders
%playercount%
not working
`` @Override
public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("playercount")) {
return "s";
}
return null;
}``
@topaz gust
let's not ping people randomly please
ok sorry
but a papi placeholder will be in the format of %identifier_placeholder%
so whatever uve put in getIdentifier() for the identifier
thx
Hello is it possible to get a list from my spigot plugin and use it on my bungeecord plugin??
yes
I know it is possible with Messaging channel but what sould i write on the data output stream to send a list ?
Can someone tell me why Bukkit#getScoreboardManager is nullable?
I'm trying to access them on onEnable method and I just got an NPE and I don't know how to solve it. This is the error message https://paste.md-5.net/lugomikiqe.sql
d;spigot Bukkit#getScoreboardManager
@Nullable
public static ScoreboardManager getScoreboardManager()```
Gets the instance of the scoreboard manager.
This will only exist after the first world has loaded.
the scoreboard manager or null if no worlds are loaded.
How do I copy data from a file included in the .jar to a file in the plugin directory? Files.copy only gives me a java.nio.file.AccessDeniedException:, also I'm on 1.8.
d;spigot Plugin#saveResource
void saveResource(@NotNull String resourcePath, boolean replace)
throws IllegalArgumentException```
Saves the raw contents of any resource embedded with a plugin's .jar file assuming it can be found using getResource(String).
The resource is saved into the plugin's data folder using the same hierarchy as the .jar file (subdirectories are preserved).
resourcePath - the embedded resource path to look for within the plugin's .jar file. (No preceding slash).
replace - if true, the embedded resource will overwrite the contents of an existing file.
IllegalArgumentException - if the resource path is null, empty, or points to a nonexistent resource.
Thanks :>
I am, but hasEnchantment also returns false (and when I update the lore, the enchants disappear)
Or at least it did used to do that, it randomly just started working π₯²
Hi, im trying to create a Car with 2 armorstands. 1 for the body with the model and 1 for the seat. I got the car to rotate but I can't get it to move.
Vehicle Class: https://paste.helpch.at/zadaholuci.cs
Vehicle Steer Class: https://paste.helpch.at/xatikoreza.cs
Is there anyone who could help me with this?
If you're justing using a texturepack use 1 armorstand for seat and model
Yeah but the player would still be high in the air. So the seat is lowerd into the ground
The only problem atm is that I can't get it to move.
the 2 stands work fine with rotating ect..
just not going forwards?
Yes, I got it to rotate.
I see backwards hasn't been tested yet
Doesn't work as well
figured
the forward value is showing over 0.0f, yes?
Yes, that works. I tried broadcasting it when I move forward and that works
hmk
It's just the armorstand not moving
I've found an older spgiot post saying that if the gravity of an armor stand is set to false you can't change the velocity
:))
sorry blitz is my alt
Ah
Well, if I don't set the gravity to false the seat wouldn't be at the correct hight
the same post was mentioning that if you set gravity to false using NMS instead of the spigot api, the velocity will work
you'll just have to deal with NMS tho
ohw god haha π
EntityArmorStand nmsBody = ((CraftArmorStand) body).getHandle();
EntityArmorStand nmsSeat = ((CraftArmorStand) seat).getHandle();
nmsBody.setNoGravity(true);
nmsSeat.setNoGravity(true);
Like this with NMS?
Or like creating a custom entity?
Show code
In text* (I don't click links)
public void applyNoClip() {
EntityArmorStand nmsBody = ((CraftArmorStand) body).getHandle();
EntityArmorStand nmsSeat = ((CraftArmorStand) seat).getHandle();
nmsBody.setNoGravity(true);
nmsSeat.setNoGravity(true);
Class nmsClass = net.minecraft.server.v1_16_R3.Entity.class;
try {
Field noClip = nmsClass.getDeclaredField("noclip");
noClip.setBoolean(nmsBody, true);
noClip.setBoolean(nmsSeat, true);
} catch (Exception e) {
e.printStackTrace();
}
}
Make sure its the mapped method
tbh, I found this on the internet I don't really know what that means π
Thats you're first issue then
Go check the remapped method names
The noclip works tho
Take a video of what happens then. Maybe I'm misreading what your issue is.
It's the correct method
k then yeah need him to take a vid
alr
oh this will come in handy π
I just open the mapped and unmapped versions xD
Field#setAccessible(true) maybe ?
@odd prawn ^^^ and debug it. Is it set to true?
Hey, so log/pillar/hay_block doesn't extend Directional or Rotational, how would i be able to set the axis using block data?
It uses Orientable my bad
You can check the Material entry in the enum to see what BlockData it "uses"
yep figured it out, thank you
Anyone know if there's a way to get the items dropped by a sweet berry bush or composter when it's right clicked? Obviously PlayerInteractEvent exists but I'd hope there's something more generic I could use for when one of those types of blocks drops an item so I can modify it. A Paper event would be fine if one exists
PlayerHarvestEvent might work for both
Is it way to prevent this happen? https://pastebin.com/EHzerbDU I know the issue. I think is the while loop some donΒ΄t get stopped as it should. is way I not like mess with while loop and use for loop (I know the compiler often make it to while loop but not get this issues).
I mean some way to check before it goo 100% bananas (if I can check if the loop start to run endlessly)?
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.
not really no. what you should do, is make sure your loop is running correctly instead.
ItemSpawnEvent or BlockDropItemEvent?
does anyone know if theres a way to loop through all players, whilst having a slightly delay between each player? (Im looping through 100 players tping them all to different locations throughout the map so am worried about lag)
this is what ive tried but no luck
for (Player p : Bukkit.getOnlinePlayers()) {
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(plugin, () -> {
// code
}, 20L);
}
You have the right idea, but I wouldn't schedule each player, but rather make 1 task to schedule on repeat and then cancel when the list is empty.
That looks like exactly what I need, thanks. Didn't realize that existed
could you give me a bit of direction on how i could do that? im fairly new to plugin development :p
can you set style using:
const span = document.createElement('span');
span.textContent = "a";
span.style.color = "084cfb";```
int delay = 0;
List<Player> players = Bukkit.getOnlinePlayers();
for(Player p : players) {
new BukkitRunnable() {
public void run() {
delay++;
//your code
}
}.runTaskLater(<JavaPlugin>, 1*delay);
}
Yeah the loop will run too a method return false (and seams the method get stuck and the while loop keep running or something like that).
thank u π
π
Anyone know why custom enchantments aren't appearing on the pickaxe, and they get removed on server restart?
Here's the code inonLoad:kt val field = Enchantment::class.java.getDeclaredField("acceptingNew") field.isAccessible = true field.set(null, true) for (enchant in Enchants.values()) { Enchantment.registerEnchantment(enchant.getEnchantment()) // A new NamespacedKey gets created in getEnchantment and is stored in memory } field.set(null, false)and the code to enchant: ```kt
pickaxe.addUnsafeEnchantment(enchant.getEnchantment(), newLevel)And the enchant code: <https://pastes.dev/CjqNVmnMPd> The key: `NamespacedKey(plugin, "enchant_${name.lowercase()}")` and only 1 instance is created (until the server restarts)
And sorry for keep saying that this is fixed and it isn't - I got confused sometimes and this time I recorded a video
The command /pickaxe test is just looping through Enchants.values() and running ItemStack#getEnchantmentLevel on them
I believe so
does anyone know how nms actually handles player movement? Only thing i've found is the ControllerMove but all it changes are some internal values, which doesn't really tell me much
Where can I add a permission so you can use the command cuz with the permission now you can only see the message
Fixed: After 8 hours it required a # before the hex code 
Am I getting some help or what?
use the player object and check if Player#hasPermission and provide the permission.
It'll return a BOOLEAN based response.
if (!playerObject.hasPermission("permission.name")) {
// send message of no permission.
return true;
}
// run stuff like checking arguments, etc.
Where should I set this line in my methode
Oke I fixed that
But there is another bug now
Shit man
shit-man
Test it and look up the documentation for it, as I am not home, or see if someone else knows
Are Ints and doubles supposed to take a number input?
Hello everyone, iv been stuck trying to figure out a way to do this, but yet i havent found one. If you have any ideas please let me know π
So im creating a scoreboard and i want to add a placeholder to display a players party. This is the api im using https://github.com/MrMicky-FR/FastBoard. So say i have the placeholder {party} i want to replace that with each player of their party. So if my config looks like:
- "&e&lParty"
- " &f{party}"```
I want to replace `{party}` with their party members, if they have none leave it empty, and depending on how many they have add a new line for each member. So if they have say 3 members it would look like:
```Scoreboard:
- "&e&lParty"
- " &fMember1"
- " &fMember2"
- " &fMember3"```
Anyone have any ideas?
while looping through the lines, make a simple check:
for (String line : lines) {
if (line.contains("{party}") {
// Loop through players and add to scoreboard lines.
}
}
Hmm
Since I can't find a reason why this is happening, what if I did this:
- Generate a random int value on server start
- If a PDC value on an item doesn't equal above, then set the enchants to what the pdc key has
- Every 10 ticks or so, add a PDC value to the item with that int value and enchants so that on the next server restart, it will be updated
π₯² Is there another option?
Tomorrow I'll check if making a new NamespacedKey also resets the enchant values π€· but I'm going to sleep for tonight
Any idea how to make it use the right components method? p.p
Edit: Solved, project.components
Was about to say yea, you could just break the loops
why are you doing that every 10 ticks
how often should I do it? Β―_(γ)_/Β―
why are you doing it 'often' at all π€
Wait where do I break it
why not only update it when the enchant updates
what event is it?
for(Block b : getNearbyBlocks(player.getLocation(), 15)) {
if(b.getType() == Material.NOTE_BLOCK) {
int distance = (int) e.getPlayer().getLocation().distance(b.getLocation());
if (distance <= 15) {
Bukkit.broadcastMessage("Distance = " + distance);
if (distance <= 12 && distance <= 15)
if (distance >= 8 && distance <= 11)
if (distance >= 4 && distance <= 7)
if (distance >= 2 && distance <= 4)
if (distance >= 1 && distance <= 2)
}
}
break;
}```
to be on the safe side
and plus, getEnchantmentLevel is just retrieving from a map
not sure if there is an event specific to enchants or not, but you can probably make your own with an inventoryinteractevent for whatever the player uses to enchant
when you find the block
It doesnt play the sound at that point
It does say the distance though
for(Block b : getNearbyBlocks(player.getLocation(), 15)) {
if(b.getType() == Material.NOTE_BLOCK) {
int distance = (int) e.getPlayer().getLocation().distance(b.getLocation());
if (distance <= 15) {
Bukkit.broadcastMessage("Distance = " + distance);
if (distance <= 12 && distance <= 15) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
}
if (distance >= 8 && distance <= 11) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.7f);
}
if (distance >= 4 && distance <= 7) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.2f);
}
if (distance >= 2 && distance <= 4) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.6f);
}
if (distance >= 1 && distance <= 2) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
}
break;
}
}
}```
In which cases is it better to use a database instead of PDC? Is it a good idea to use both? (For example I am making a generator plugin and I want to store generator data on the chunks PDC but I also want to be able to modify it and get all generators from a user where I would store the locations in SQLite for example. In this case I would store gen data with pdc and the location and owner of it in sqlite for easier sorting, etc.)
Hello btw lol
Oh sorry, you guys were already speaking
I will wait.
if you want to get PDC -> Chunk data, then you'll have to use a database
Or ig you can combine it
that would work yes
So, like I mentioned it before?
you could either have all the data in the database
or you can have the player and chunk in the database, then the rest of the data in the chunk PDC
Oh okay ye then its what I had in mind
Although unsure if its practical
Also, would it be too heavy to like loop through a list of locations of the generators and get their PDC? Unsure how heavy PDCs are
Are they even cached?
Hello everyone, can anyone help me with a problem that im having with WorldEdit?
Im trying to get a selection of the player using Selection sel = getWorldEdit.getSelection(); but it gives me a error that says that .getSelection() doesnt exist
The worldedit is "imported" perfectly, it just doesnt work.
Maybe the API changed, but on every docs/tutorial i find the same way being used
Is there anything in the Paper/spigot api that returns if a server is fully started?
except for ServerTickStartEvent
I think tasks start when the server is loaded
public class ServerLoadEvent
extends ServerEvent```
ServerLoadEvent has 4 methods, and 1 extensions.
This event is called when either the server startup or reload has completed.
np
Figured it out again I assume? :3
yer
I released it would take way to many resources
the server would be to laggy so I gave up
Not necessarily, what exactly are you trying to do?
Just find the nearest jukebox within a 10 block radius
On what event
Would the jukeboxes be underground or?
Yea
How deep
0 -> 256
You mean searching radius or where have I ptu them?
They are not spawned they are pre-placed
Ah shame
So resource intensive?
Well I mean doable but not really preferable
Was the way I did it a very bad way of doing it?
Didn't even fully see how you did it
Getting the lowest value of a hashmap was my only problem
public static List<Block> getNearbyBlocks(Location location, int radius, Player player) {
List<Block> blocks = new ArrayList<Block>();
for(int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
for(int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
for(int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
blocks.add(location.getWorld().getBlockAt(x, y, z));
}
}
}
return blocks;
}```
I cannot manage to sort it by distance
by distance how?
Distance from Player to the Juke Box
So that this can happen:
if (distance <= 15) {
Bukkit.broadcastMessage("Distance = " + distance);
if (distance >= 12 && distance <= 15) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
}
if (distance >= 8 && distance <= 11) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.7f);
}
if (distance >= 4 && distance <= 7) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.2f);
}
if (distance >= 3 && distance <= 4) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.6f);
}
if (distance >= 1 && distance <= 2) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 2f);
}
}```
I mean you could just add that into your loops
And what kind of distance is that, just x distance or
wdym? Distance as an int I guess
Which kinda distance
B
Honestly whichever is the easier one
OH
The first picture has X Y Z
It has to be A then
So you're only checking 15 within the player then?
Yea
Why don't you just loop in a sphere and get the blocks in there, instead of from 0-256
I tried that in the above function
Here
that'd work in a cube, but yea probably good enough
Then just loop through them, and get the Location#distance, however you might want to use Location#distanceSquared since performance
for(Block b : getNearbyBlocks(player.getLocation(), 15)) {
if(b.getType() == Material.NOTE_BLOCK) {
int distance = (int) b.getLocation().distanceSquared(player.getLocation());
if (distance <= 15) {
Bukkit.broadcastMessage("Distance = " + distance);
if (distance >= 12 && distance <= 15) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.5f);
break;
}
if (distance >= 8 && distance <= 11) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 0.7f);
break;
}
if (distance >= 4 && distance <= 7) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.2f);
break;
}
if (distance >= 3 && distance <= 4) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.6f);
break;
}
if (distance >= 1 && distance <= 2) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 2f);
}
}
}
}```
I tried that here but for some reason it would not return the closest block
Well you cause that'd loop until it find the first block, then stop
You'd have to get all the noteblocks, then sort them by the distance
Should I put them into a HashMap?
When you're looping through the blocks, you could have a map with an int for the distance and the block, and then just sort the map
This is a general java question but how do I get the first value in a sorted map?
Map<Block, Integer> unsortMap = new HashMap<Block, Integer>();
sortByValue(unsortMap).get(0)```
Returns the first in the list?
That will return the first element, but it may not be the first element that was inserted.
Nothing in it then
only 1 way to find out!
I tried to create separated inventories using this way, i think it works, somehow, but what can I do to open them using a command
that's my idea:
Inventory[] itemsMenuGui;
public ItemsMenu() {
itemsMenuGui = new Inventory[0];
createItemsMenu();
}
public void createItemsMenu() {
itemsListConfig = new ItemsListConfigFile(plugin);
Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
itemsMenuGui[Integer.parseInt(ID)] = Bukkit.createInventory(null, 36, "Β§8Β§oEditing " + menuName + " menu...");
});
}
public void openInventory(Player player, int ID) {
player.openInventory(itemsMenuGui[ID]);
}
command class:
itemsMenu = new ItemsMenu();
itemsMenu.openInventory(player, Integer.parseInt(args[0]));
if somehow I could give the size for Inventory[] itemsMenuGui; as the numbers of the inventories in my config like Inventory[] itemsMenuGui = new Inventory[inventories_list];
sorry for my bad english
Can I suggest using something like triumph gui
Brister, can I suggest you to go suck a chicken
tee hee
Try list or map
let me try
do u mean like this? List<Inventory> itemsMenuGui;
A map would probably best so you can keep track of which inventory is which
oke oke, let me try
yes.
Unless his object has an ID object
well.. i think im doing something wrong then
List<Inventory> itemsMenuGui;
public ItemsMenu() {
createItemsMenu();
}
public void createItemsMenu() {
itemsListConfig = new ItemsListConfigFile(plugin);
Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
itemsMenuGui.set(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "Β§8Β§oEditing " + menuName + " menu..."));
});
}
cuz i get this error
null
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.set(int, Object)" because "this.itemsMenuGui" is null
You're doing set instead of add.... If you want the ID either add it in your object or use map
ooohhh
i see
itemsMenuGui.add(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "Β§8Β§oEditing " + menuName + " menu..."));
but i get the same error
Again... if you want the ID use a map or add it to your object
or remove it from the method call
Np
A male chicken?
That'd be too vulgar, hence he can go suck a chicken
hey, can somebody help me with this question
how could I use the same inventory across all my classes, like, for example Inventory 1 is created in my class ItemsMenu from my config file:
public class ItemsMenu {
public ItemsListConfigFile itemsListConfig;
private final Map<Integer, Inventory> itemsMenuGui = new HashMap<>();
public ItemsMenu() {
createItemsMenu();
}
public void createItemsMenu() {
itemsListConfig = new ItemsListConfigFile(plugin);
Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
itemsMenuGui.put(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "Β§8Β§oEditing " + menuName + " menu..."));
});
}
public void openInventory(Player player, int ID) {
player.openInventory(getInventory(ID));
}
}
then i wanna open this same inventory it with a command
itemsMenu = new ItemsMenu();
itemsMenu.openInventory(player, Integer.parseInt(args[0]));
then i wanna get exactly the same inventory in another class,
so i did this:
@EventHandler
public void checkInventory(InventoryOpenEvent event) {
itemsMenu = new ItemsMenu();
Map<Integer, Inventory> inventoryList = itemsMenu.getInventoryList();
Inventory openedInventory = event.getInventory();
if (inventoryList.containsValue(openedInventory)) {
itemsMenuGui = openedInventory;
}
}
but the problem is with itemsMenu = new ItemsMenu(); wich creates a "new inventory" for every class
So, what i have to do to create a single inventory for all my classes, like a static one, but without using static keyword? π₯Ί
I hope I have explained what I meant, my english is not the best π
https://paste.helpch.at/hasakubitu.cs can someone help me set this up? Iβve tried multiple different ways of making it yet non work
rn i'm tryna spawn a villager facing a direction, problem is that i can set the pitch, but not the yaw. i'm doing this with just location.setYaw(), but it's not doing anything
Can villagers look up/down apart from specific behavior actions?
yes
i've tried setting it after by getting the nms Entity and setting the yaw like that but that doesn't work either
What if you set it after without nms? getLocation().setYaw()
you can't getLocation on a Villager
Are you trying to set the head yaw? I feel like I remember something when I messed with this
You'd need to do getBukkitEntity().getLocation()
head and body
it IS a bukkit entity
Every Entity has getLocation()
Location loc = new Location(Bukkit.getWorld("world"), -1.5, 114, 12.5);
loc.setYaw(90);
loc.setPitch(45);
Villager perks = (Villager) Bukkit.getWorld("world").spawnEntity(loc, EntityType.VILLAGER);```
perks doensn't have .getLocation()
i'm in 1.8.9 btw
wait
what
i swear it wasn't showing up earlier
getLocation() is from Entity and basically everything inherits from Entity
i know, but i wasn't seeing it for some reason
i guess i'm just blind
yea it doesn't work
.setYaw just doesn't do anything
i'm too tired, ill solve it later
Any ideas on this? Iβm so lost
What part doesn't work?
It reloads the config but it wonβt update the material change
What if you do it twice?
it changes the material like it should but non of my other classes register it so it's unusable
wym they don't register?
one of my events checks for the material, when i reload it gives me the new item with the corrected material, however now the event doesn't recognize the material until i restart the server and or rejoin
So the issue to me seems to be in those events listeners, not this class
ah okay, do i need to change priority possibly?
Show me the events
So what part in here doesn't work like you expect?
this is the event that isn't working after reloading
What part isn't working though?
the right click?
Where is sword defined?
e.getAction() == Action.RIGHT_CLICK_BLOCK) && isSimilarButNotNull(sword, e.getPlayer().getInventory().getItemInHand())
oh sorry my bad https://paste.helpch.at/oropowukoj.cs
Yeah, so when you reload the config, this event still holds the old item
You would have to reference the config more than just one time
Currently you're only looking at the config when you initialize that class
But in order to stay up to date, you'd have to look at the config every time you want to compare to that sword
okay
