#help-development
1 messages · Page 2129 of 1
How?
Every EntityInsentient has 2 pathfinder controllers
one for movement and one for attack IIRC
they're basically a fancy list<WrappedPathfinderGoal> which consists of:
- The pathfindergoal
- The priority
so yeah just wipe that list
Okay, i will try, thanks
if i wanted to save a list of items to an items nbt, how might i go about doing that?
store an entry for each slot, and give it a value as to what is in it?
im used to having compoundNBT but that's not in spigot
this.goalSelector.removeAllGoals();
like this?
try it and see
@chrome beacon any idea how to make the command switching work
for item storage i can think of using persistant data with each slot having an entry. could be a thing i could do
also is there any downsides to using persistant data containers?
Use mfnalex’s API for data types .. there is an ItemStack_Array data tyle
maybe check for your uniqueid instead
how do i use the filter function on get nearby entites
seems good. says its a tiny library, but this isn't something that would have to go alongside my plugin on a server is it?
hi folks! looking to get a concept of the resources people use when developing plugins... I know for Forge Mods it's pretty typical for mod authors to use some standard libraries written by others... outside of the Spigot API itself, are there "plugin libraries" that are commonly used? or do most people build everything from scratch?
No it isn’t
there are certainly libraries that people use, but it's not necessarily standard
Packet libraries such as ProtocolLib use is commonplace because working with packets is miserable
@EventHandler
public void onRightClickAxe(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR && event.getPlayer().getInventory().getItemInMainHand().getType() == Material.STICK) {
List<Entity> entList = event.getPlayer().getNearbyEntities(30, 10, 30);
if (entList.size() >= 1) {
for (int i = 0; i < entList.size(); i++) {
entList.get(i).getVelocity().add(new Vector(0, 10, 0));
}
}
}
}
any ideas why this isn't worknig
how can i remove spawning items on essentials
are you sure getNearbyEntities is returning what you expect?
whut?
a list of entites right?
seems like it. but are you sure?
well im pretty sure because when i do entlist.get(i) i can perform various entity operations intelijsense lets me atleast
i meant what it actually gives you. try logging the list
entList.size() could be zero for all we know, but if its not then you know what your problem isn't.
ok, perfect. narrowed that down
maybe applying velocity in that manner isn't right?
i think your right
lemme try some operation on the entites to see if its just the velocity
sounds good.
yes i can do that
so it works fine now?
no change
getVelocity().add() doesn't do anything.
no errors just has no effect
You want to get velocity, change it, and setVelocity()
Vector velocity = entity.getVelocity();
velocity.setY(velocity.getY() + 10);
entity.setVelocity(velocity);
i guess getVelocity() gives a copy. the more you know
remove the kit
in general, i can't seem to get my head around when you get a reference vs when you get a copy. lol
usually when there's a set method as well, thats the sign
the sign of a copy getter, i see. sort of, but i meant more on a java level
yeah
ill go search around. got something to look up now :)
if you have a setter along with a getter that usually means the getter provides a context/snapshot object
if not, then it probably implies that getter returns a modifable (or sometimes unmodifiable) view
Well-written Javadocs tend to state whether or not its mutable, immutable, or a copy
that too
In this case it doesn't, getVelocity() is very old (probably 11 years old at this point). Though most modern methods will state mutability
hm. ok, i guess a method as simple as getVelocity() doesn't need to change too often, so the docs don't get updated. interesting.
so this extra nbt type is cool, but the toString is lackluster at best
contents=[B;-84B,-19B,0B,5B]
what does that even mean
B = byte presumably
The first entry in that array is just denoting array type, suffixes on the numbers reinforcing that
Minecraft does something similar. Their array types are zero-indexed with type. e.g. UUIDs are stored with [I; first_int, second_int, third_int, fourth_int]
iirc
hmm. ok, so its printing the bytes of the itemstacks. oh yeah thats supposed to be an array of itemstacks
container.set(new NamespacedKey(SpigotTools.getPlugin(), "contents"), DataType.ITEM_STACK_ARRAY, holder.getInventory().getContents());`
...
PersistentDataContainer container = backpackItem.getItemMeta().getPersistentDataContainer();
inventory.setContents(container.get(new NamespacedKey(SpigotTools.getPlugin(), "contents"), DataType.ITEM_STACK_ARRAY));```
i don't know what good pasting this here does, but whatever
why would UUIDs be represented as 4 ints given that they're 2 longs internally 🤔
List is an interface. There are different implementations. The one you'll likely want to use is ArrayList. List<Entity> entities = new ArrayList<>();
mojang doing some weird things to represent uuids
reinventing the wheel
presumably segmenting the long's bits into 2 ints?
why not use a long long at that point? do it all in one variable. lol
they use 2 longs in some parts actually
huh
but yeah not everywhere
I believe for the optional uuid for entity data sync 2 longs are used
?services @uneven dock
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Thanks!
Well, guess I can't post there... I have never posted on the Spigot forums in the like 5 years I've had the account 🤣 Thanks anyways
because Java doesn't have long longs
Nothing. It still exists. Just depends on what mappings you're using
If you're using Mojmaps, it's CompoundNBT. If you're using CraftBukkit mappings, it's NBTTagCompound
hm. i have neither one of those it appears. investigation time
Suppose it depends on the .jar you're depending on as well. The one provided by BuildTools is a bundler jar so it doesn't have any NMS in it
i think i used the intellij plugin for this one
Mmm. Don't know how that one works and what it depends on
could i find which jar i depend on in the pom.xml?
spigot-api?
If you've run BuildTools for that version, you can remove -api and it should pull from your local Maven repo
Yeah
alright, well thatll do it
ill look into the build-tools thing
dont think i did that
?bt
Bear in mind that only the names of classes are CB mapped. Method names are pretty much entirely lost. There's some info on that on the forums to use Mojmaps if you want. Sec
so changing to spigot-api ill lose a bunch of information about spigot methods?
No no, I mean just NMS
spigot-api contains just API classes from Bukkit and Spigot
derp i mean spigot
spigot includes Bukkit, Spigot API, CraftBukkit, Spigot Server, NMS, and all its dependencies
i guess ill just try removing the -api and see if ive run build tools that way
you do you man
well i got all the nbt stuff
Can someone explain to me what the three parameters in Player#getNearbyEntities(double, double, double) mean? Is it just the distance in X, Y and Z coordinates where it should look for near entities and not outside?
how do you reverse the exponential growth equation trying to find the Y value from an X value and I haven't gone far enough in math for this shit
return (int)(baseCost*Math.pow((1.0+(increaseCostModifier/100.0)), sampleLevel));
not sure what exactly you mean
like this?
need the reverse of that equation instead of getting the Level value which would the in the Y position on the graph I need the X aka the Experience value. Its based off the exponential equation f(x) = a(1+r)^x I found a semi-reliable way with logarithms, but I couldn't nail anything down as I don't quite understand those mathmatical concepts
so like a formular to reverse the level to its experience form
yes
any basic reversal of the a(1+r)^x exponential growth equation will work
I tried google but it was full of a bunch of people not knowing how to do an exponential growth problem not really what I need
wait i got confused. so rn you have the formular for level to experience but now you need the vice versa way
First reverse the pow
im shit in math as well
By doing pow(num/basecount - 1, 1/sampleLevel)
afaik the propper way to do this would be a logarithmic
I'll probably keep looking because the logarithmic I had was only slightly off
yea
Just a random question, is java better or kotlin?
Whichever works better for you. At the end of the day it's java bytecode
depends
ive found a promising thing about the MorePersistentDataTypes lib
when i save then load my array of ItemStacks, the loaded array is of the correct length
got it
yaay
how do i check if an armor stand's equipment is empty
besides individually checking every slot
I mean... could get creative with ArrayUtils.isEmpty(armorStand.getEquipment().getArmorContents())
Though I don't think that checks hand slots
I'd personally opt to just create a method
public static boolean hasNoEquipment(ArmorStand armorStand) {
EntityEquipment equipment = armorStand.getEquipment();
for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemStack item = equipment.getItem(slot);
if (item != null || !item.getType().isAir()) {
return false;
}
}
return true;
}```
wouldn't it be air, not empty?
No. getArmorContents() returns null in slots with no armor
ah
Bukkit inventories are very inconsistent
but using the method I wrote above would check for nullability and air
(I think getItem(EquipmentSlot) returns both lol)
still doesnt work
Then I probably wrote it wrong 😛
lol
That or you're doing some other weird fuckery that is preventing it from being called
can you cast an ItemStack[] to an Inventory? since Inventory extends Iterable<ItemStack> or is that not allowed?
that would be a no
is there any documentation available for LightAPI? i'm trying to workout how to make an object 'glow' (have the light move with them, and with this, also set the light level to 0)
there is some documentation here https://www.spigotmc.org/resources/lightapi.4510/
no i don't unfortunately, but i do know thats something im going to end up needing someday :)
i'd assume you'd just use the api with the player's location in a PlayerMove event or something though
right. well i think that api physically changes the data of the blocks somehow
so its not actually setting light "sources". it more like simulating them in a way. i doont understand it well enough to say 100% though
how would i update the block after cancelling BlockFromToEvent
trying to make it not work at certain times, but work after
i feel like a queue data structure would be useful for this. not sure though
lol im making an antilag plugin but when i try to test this thing that triggers at low tps, i cant even get the tps to lower
ive tried everything
like all the types of lag machines
antilag plugins are placebo
what do folks usually use for the backing DB for their plugin? spigot doesn't provide like an sqlite or anything, right?
it does sqlite afaik
but you really arent limited, you can just get drivers / add dependencies
Lol just saw my mistake
I'd rather just use sqlite provided by spigot if it's built in... do you know of any good examples of that use?
just found that off of a google seartch
what does the "cannot resolve method" error mean
ive invalidated caches and restarted intellij, still there
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-adapter-bukkit</artifactId>
<version>3.0.6</version>
</dependency>
they didnt provide a shade, but the thing is only happening with the TextDecoration enum
nvm im dumb
does anyone know the best way to force the player's client to reload an entire chunk?
forgot to relocate xD
anyways, how do i get the key for an environment/world?
like minecraft:the_end
Is there any alternatives to check player is on ground? I just read that on the javadocs Player#isOnGround is deprecated and I just want to know If there are any alternatives.
Can one load .json loot_table files into a plugin?
Could you? Yes. For what purpose that a regular config wouldn't suffice? Idk
I have a datapack with pretty complex loot tables pre-made that I'd just like to load into my plugin.
Quick question as a begginer. How do I create a maven dependency? Like for example from my github or something...
how would i accomplish this
By loading and parsing the config(s) in a class.
Many guides out there. Some people use jitpack but it has its issues
I've looked but get lost I don't find a clear answer.
Is there any way to get the NBT data (for custom NBT usage) of an ItemStack? If so, how would I accomplish this?
how can i set an items durability on 1.16.5
I think u should use the Damageable class
how can I make it like it gives the helm to a specific player
like /spacehelm <player>
for exmaple - /spacehelm lol123
anyone can help me?
check if the Bukkit.getPlayer(arg) is null
where arg is the first argument
if it is null that means its not a real player
if it isnt then it is a player
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
It's an array
if (args.length >= 1){
String playerName = args[0];
Player targetPlayer = Bukkit.getPlayer(playerName);
return true;
}
so I add the code?
if (targetPlayer == null)
not with just that code
please just learn how to make basic plugins
plenty of youtube tutorials
and then come ask us how to make specific stuff
You need to learn Java arrays before you continue
any specific video recommendations?
If the quality of YT Tutorials are still as Bad as I remember them I would Not bother
atleast u learn the basics
whats the reason for PlayerPreLoginEvent being deprecated?
Read the deprecation note
is it possible to open a custom prompt like the resource pack one?
could also be a resource pack prompt in disguise, i just need the option for a forced yes/no dialogue box
can we set position of blocsk
u could maybe try opening a book and quill
with clickable text kinda like how hypixel does it
yea but then i could also just make a custom UI for that purpose
i was looking for the ability to force a simple yes no button prompt tho
open a gui with those 2 buttons every second tick or so until they accept or decline
Does anyone have a good tutorial for MongoDB and Spigot
Hello !
I have a little Java question:
If I do something like
Material.valueOf("ITDOESNTEXIST");
What will it return ? "null" ? Or will it handle this error by himself ?
Ty
probably null
valueOf() throws an illegal argument exception when the name does not exist i believe
hover over the method and read the doc
Ah, I've forgot this feature, ty !
np
Hello. Does anyone know why my dependency not working? I want to use NMS.
It says this:
Thanks
np! Your problem was that you didn't run BuildTools. but please read the full blog post, because you definitly should use mojang mappings if you use 1.18 NMS, so yeah, it's all explained in the link I sent 🙂
ive been stuck on this issue for a solid day now and i was wondering if anyone knew how to solve this
DROP PROCEDURE IF EXISTS addColumnToTable;
CREATE PROCEDURE addColumnToTable()
BEGIN
IF (NOT EXISTS(
SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tableName'
AND table_schema = DATABASE()
AND column_name = 'test') )
THEN
(ALTER TABLE BANKS_PROFILES ADD COLUMN test SMALLINT DEFAULT 0;)
END IF
END;
CALL addColumnToTable();
i got this sql query to add a column to a table if the column doesn't exist, but I get a syntax exception at the ALTER TABLE line and i really can't tell what's wrong with it
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ALTER TABLE tableName ADD COLUMN test SMALLINT DEFAULT 0' at line 9
here's the error, not really helpful
i know there's a simpler query available for mariadb, which works, but i'd like this query to work for mysql in general for accessibility
But it says Unresolved dependency again and I don't know why bcs if I use spigot-api it works but when I try to use spigot it doesn't works. :(
did you run BuildTools with the --remapped parameter?
I don't know how
?bt
download buildtools, then put it into some folder
then go into that folder and run
java -jar BuildTools.jar --rev 1.18.2 --remapped
this link explains exactly how to run buildtools
okay
Hi, can I ask something?
?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!
Is this a way to get decompiled version of the vanilla minecraft too?
no
Just decompile it yourself
Otherwise, BT also decompiles mc for patching, you can use that. But there isn't really a neat automated way of getting the decompiled version
Though given that spigot only uses a lightly patched fernflower, it is more advisable to use your own decompiler
so BT just give me the source code for the patch, am I right?
It probably does not do it automatically, you will likely need to configure your IDE to use the source
And at that point, I recommend using a decompiler that produces "nicer" output like forgeflower or quiltflower
Also if you are using intelliJ your IDE should automatically decompile classes with no attached source
Guess I'll give Eclipse a try
For eclipse you'll need to have the decompiler plugin and it isn't that great to be honest
eclipse needs a ton of extensions to match with intellij
not even a proper projetc wizard
I generally prefer using Recaf over it - it is much nicer
if i tempban a player using the banlist java Bukkit.getBanList(Type.NAME).addBan(p.getName(), banReason, banTime, ((sender instanceof Player) ? ((Player)sender).getName() : "Console")); and that player logs in first time after the ban expired, there is a null error like ```txt
07.05 09:22:13 [Server] INFO java.lang.NullPointerException: Cannot invoke "net.minecraft.server.players.GameProfileBanEntry.f()" because the return value of "net.minecraft.server.players.GameProfileBanList.b(Object)" is null
p is an instance of OfflinePlayer that is prior confirmed to be existing
reason and time are parsed correctly
It downloding PortableGit
And I don't know if it is okay
yep, that is working as intended
JDK 17
[
{
"uuid": "25ec173a-0c50-4bd9-848f-67676b531533",
"name": "TheTimeee",
"created": "2022-05-07 09:21:35 +0000",
"source": "TheTimeee",
"expires": "2022-05-07 09:21:45 +0000",
"reason": "Because that"
}
]
```just to confirm whats in the banfile
Ok but what I have to do now with that?
Also if you are using the git CLI, make sure to reconfigure git afterwards, buildtools is a bit stupid and overrides your git config
hm?
Hello. Why doesn't this method find a command? It exists on the server.
public static void initializeCommandDistances() {
for(String command : Main.getInstance().getConfig().getConfigurationSection("Commands").getKeys(false)) {
PluginCommand cmd = Bukkit.getPluginCommand(command);
if(cmd != null) {
double distance = Main.getInstance().getConfig().getDouble("Commands." + command + ".Distance");
int targetArgumentNumber = Main.getInstance().getConfig().getInt("Commands." + command + ".TargetArgumentNumber");
if(targetArgumentNumber <= 0) targetArgumentNumber = 1;
commandDistances.put(cmd, new CommandParameters(distance, targetArgumentNumber));
} else {
Main.getInstance().getLogger().warning("Couldn't find the command with the name " + command + ". Skipping it...");
}
}
System.out.println("commands: " + commandDistances);
}
Output:
[12:35:18 INFO]: [CommandDistance] Enabling CommandDistance v1.0
[12:35:18 WARN]: [CommandDistance] Couldn't find the command with the name ru. Skipping it...
[12:35:18 INFO]: [CommandDistance] commands: {}
how do you kill every entity of 1 type like /kill @e[type= pig]
maybe you didn't define it in the plugin.yml
or the main
/minecraft:kill @e[type=pig]
that's what I do 👀
i meant in spigot...
...?
it's defined
I can use it on the server
i meant how to make my spigot plugin kill every entity of 1 type but not the vanila command
oh
Wdym it can’t find a command
I want to find a command on the server by it's name or alias
And save it to a Map
ok
https://paste.md-5.net/widuzevuxi.sql can someone help me?
in spigot
With /kill
Oh
Wait
I’m dum
Idk
Loon througb every entity
Check if ping
Pig
@spare prism
Make some checks
Have them print stuff to the console
See where exactly the problem is
Cause it could find the command
for(World w : Bukkit.getLoadedWorlds()){
for(Entity ent : w.getEntities()){
if (ent instanceof Pig){
ent.remove();
}
}
}
But one of your checks could be wrong
ok, lemme do it real quick
Oh
L
That took me like a whole day to fix
I don’t remember how
I think I just had to update my java version or something
Make sure the java version you are using on your computer
Is the same java version your using in IntelliJ
For your project
Player p = (Player) e.getWhoClicked();
if (!e.getInventory().getName().equalsIgnoreCase("Kits")) return;
e.setCancelled(true);
p.sendMessage("1");
if (e.getCursor().getType().equals(Material.STAINED_GLASS_PANE)) return;
p.sendMessage("2");
String itemname = e.getCursor().getItemMeta().getDisplayName();
String kitname = itemname.replace("§d§lKit ", "");
p.sendMessage(kitname);
}``` it sends 1 and 2 but it doesnt send the kitname
Any errors?
[12:54:37 INFO]: [CommandDistance] Enabling CommandDistance v1.0
[12:54:37 INFO]: [CommandDistance] cmd: null
[12:54:37 WARN]: [CommandDistance] Couldn't find the command with the name ru. Skipping it...
[12:54:37 INFO]: [CommandDistance] commands: {}
this is the one i have in intellih
Is RU the alias?
yeah
how can i check the one i'm using in the pc?
ok
can I make my plugin use a vanila command through the console?
Look it up, idk the full command but you go to command prompt and type I think it’s just ‘java -version’ actually
String kitname is line 18
btw
rankup:
usage: ''
description: ''
aliases:
- 'lestrankup'
- 'lrankup'
- 'ranku'
- 'ru'
- 'rup'
One sec @harsh totem
I’ll figure out how to find aliases in a sec
is that the same?
It's the basic command now:
[12:57:11 INFO]: [CommandDistance] Enabling CommandDistance v1.0
[12:57:11 INFO]: [CommandDistance] cmd: null
[12:57:11 WARN]: [CommandDistance] Couldn't find the command with the name rankup. Skipping it...
[12:57:11 INFO]: [CommandDistance] commands: {}
Idk check your project structure
how to get higest possibley blocks
.
fixed it
@midnight shore what version are you using
Nice
World.getHighestBlockAt(Location)
Wa
16.0.2.7
ok
Mc version
1.17 server version
Then idk what to tell you
It took a lot for me to@fox it
Fox
Fox
Fix
Try uninstalling other java versions
I did that
Idk how tho
It was a while ago
Look it up
i only have that version 😐
@somber hull, any ideas bout that? 😦
Check your java folder
Send the code in a paste in rq
?paste
but i think the problem is something else. it says noclassdeffoundexception
like it the class doesn't exist
but it does
I'm making a minigame map system, and I have an abstract class for a game type, e.g. skywars. I have a class, GameMap, which loads a world from storage. For each type of game however I want to extend this GameMap class, to store specific information needed. For example, for skywars I may need to store a list of possible chest locations as well as player spawning positions, where as it will be different information for each map for a different type of game
Oh wait
I was thinking of a similar one
But that’s class version
The question is that if all my game types extend some abstract game type, how do I make it so that they'll only take the specific type of map?
Are you using any frameworks @midnight shore
how can i check?
sorry ... : (
Have you put anything into maven
Are you using anyone else’s code ig
yeah of course
Generics
and for a boat racing game I only want to take BoatMaps rather that any map
Other than spigot
I’m not understanding
You want to have a way to make sure that the map is the subtype that you want?
Like instanceof?
Send the error again
so I want to make it so that a Boat racing game has to take a sub-class of GameMap in the method
specific to that type of game
abstract class X<T extends GameMap> {
public abstract void startGame(T map);
class Z extends X<BoatMap> {
public void startGame(BoatMap map)
Ye you need to shade the mongodb dependency @midnight shore
Idk I’m on mobile
And can’t show you rn
Also it’s 3 am
Look it up
so i have to put the jar file?
Shouldn’t be too hard
No
ah of course, thx
generics
You have to add another thing to your Pom.xml
I just don’t wanna go and find it rn
Mongodb probably has a tutorial
I haven’t forgotten
I think that’s got your answer
Idk why what your doing isn’t working
@spare prism
Actually
Bukkit.getCommandAliases
Then get the key being your main command
Only@problem
Hello team ! I have this error : java.lang.NoClassDefFoundError: org/bson/conversions/Bson do you know how to solve this ?
Is you don’t actually get slides with that
Why dependencies are you using
What*
No ! How did i do that ?
ty, I'll try that
Mongodb probably has a tutorial where the maven stuff is
why do tempbans result in a null error unless i get the ban entry in the AsyncPlayerPreLoginEvent event first?
I will check so, thanks u, but i have one question, what is the shading ?
Wdym
same error
@somber hull got a few secs?
I’m not 100% sure Ngl
^^
Anything other than mongodb?
Whats@up
wdym?
if i tempban a player using the banlist
yes
Such as
Bro says yes and leaves
Anyway I have to go to sleep
Goodnight
like vault
why dont u just share the pom
how can i create a custom mobs with its speacial armor and summon it on a specific command
special armour?
and wdym custom mobs
u can only change the names of minecraft mobs and show them or the max, change their texture
with custom amour and tools
Custom Armour?
Is it good idea to create the maven/gradle dependency only for personal use? I want to use some same classes in the multiple projects, but idk what will be the best way.
yea id do that
Still is rather okay, 3 or more generic types are more than normal
ok, so how can I use normal java project as the dependency? I heard about jitpack and nexus, but I don't get it how it works.
kk, good to know
when using ProcessBuilder, what is the default directory on Ubuntu/Linux? system default directory or location of Spigot/Paper jar?
I basically wanna go into my plugins folder and access a file
how can i remove a plyer from a list after a certain time
use a scheduler
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
by learning java ^
does anyone know how can I display a line below an entity's name using packets?
i can't really use the api since i'm working on npcs
i know you are supposed to send scoreboard packets but i'm not having much success
You can create an armor stand move it down a bit make it invisible give it a name
Or also an area effect cloud
if you do it that way, i would have to teleport the entity if the npc moves and if the server lags it would desync pretty badly and also there is not enough space between the npc's name and head
You can also use scoreboards but that would implicate that you only add one line
Just make the name itself an armor stand so you can move it up and down
private void setBelowNameLine(int value, String string) {
ScoreboardObjective objective = new ScoreboardObjective(NMSHelper.getNMSScoreboard(), string, IScoreboardCriteria.b);
// 2 is belowName
NMSHelper.getNMSScoreboard().setDisplaySlot(2, objective);
ScoreboardScore score = new ScoreboardScore(NMSHelper.getNMSScoreboard(), objective, entity.getName());
PacketUtils.playPacket(new PacketPlayOutScoreboardObjective(objective, 2), canSee);
PacketUtils.playPacket(new PacketPlayOutScoreboardDisplayObjective(value, objective), canSee);
PacketUtils.playPacket(new PacketPlayOutScoreboardScore(score), canSee);
}
that's the code i wrote
i just need a single line below the name
NMSHelper.getNMSScoreboard() just returns the nms version of the main scoreboard and playpacket just sends the packet to every entity in canSee (canSee is a list)
im quite confused indeed
Does anyone know how to get a list of the advancements a player has?
Hi! I'm still getting that same error of the class not found https://paste.md-5.net/kitebuqudi.xml this is my pom.xml https://paste.md-5.net/widuzevuxi.sql and this is the error
Hi I can make fork of bukkit with changes from spigot or paper?
i am trying to say that i have created a timer which sends hello , how can i put my player list in it and remove a specifc player
Yes you can. If you want to fork Paper they have a guide for it (not specifically for it but for creating patches)
use the playerlist variable?
i want to make a fork bukkit
With my additions
hello can anyone help me? I have this error!
/storage/emulated/0/PLUGIN/src/main/java/io/kettra/plugins/belly/Belly.java:[71,103] cannot find symbol
[ERROR] symbol: method isEmpty(org.bukkit.entity.Player)
[ERROR] location: class io.kettra.plugins.belly.Belly
code:
for (Player p : Bukkit.getOnlinePlayers()) {
check.setString(1, p.getName());
ResultSet rs = check.executeQuery();
Well that's not the error for that code
it appears it can't find your isEmpty method
does getData, setData include the durability of the item
not rly
its still simple imo
YOURE CODING A PLUGIN IN MOBILE
??
Now i get this error https://paste.md-5.net/yizoyenuvo.nginx and i have the dependencies directly into intellij idea into the global libraries ( i tried also normal libraries [same error]) could anyone help me?
When I add ingredients to a recipe like this recipe.setIngredient('N', Material.NETHERRACK); is there a way to make this ingredient be more than just 1 netherrack? like 32 or 64?
nah
please
i'm just becoming crazy
are you sure there's no way?
nope not using the bukkit recipe api
in 1.8
does anyone know?
Orby already answered you
he said no and then said that he doesn't know
If you want quantities you have to manually handle the matrix and crafting
he said no, and then not using the Bukkit API
Hey, I have such a problem that I did the check for available updates according to the tutorial. My current plugin version is 1.0.2, and when I check the version from the link (https://api.spigotmc.org/legacy/update.php?resource=), I can still see 1.0.
Can someone help with this?
i said no
never said i didnt know
oh
here i meant like
"no, theres no way to do it"
How can I detect if player collides with an entity?
ty for helping me with the recents thing
one more thing
can I make it like the edition updates
after giving each player 1
?
Listen player move event and check if there's any entity under 1 block radius
Ah okay, I hope it doesn't affect performance that much, thanks!
You need to track the edition number yourself
yes save previous edition number to config and +1 every new edition
how tho?
Simple loading and saving into a file configuration.
^^
any example?
is there some way to make a specific Anvil not fall? For performance reasons I don't want to cancel the gravity event every few ticks, I want it to just never be considered to be able to fall.
Spawn a block and then change it to anvil i think, if there's any method to place with no update
any idea what event fires when player clicks an item in their inventory? cuz InventoryClickEvent doesnt work for me
are you sure that will never even trigger the gravity event?
The println doesn't got fired?
my other events work fine, its just this one
no
Are you sure you have registered the event?
are you sure you registered the event and recompiled the plugin and properly restarted the server?
bruh my other events in this same class work just fine
these work
and some others
idk then, but I can only assure you that you want to use InventoryClickEvent for that.
Oh
Sorry i misunderstood
Yes, I do anything on my cell phone, since I can't afford to buy a computer!, But I wanted help 🥺
really?
Estudos
by cell phone too
You can run Minecraft on your phone 🙂
java edition?
Yes
never heard of this
Salute
Pojav Launcher, its in the play store.
If you have Bedrock though you can just use Geyser to connect to your bukkit server
Java is cross platform is runs just fine. If you're on android you can use the Pojav Launcher
welp apple is just cringe i guess
use Geyser
For those who know how to program and study, you can do everything from your cell phone!
You can always use the GeyserConnect instance ( us.geyserconnect.net )
Yeah
but you really don't want to tbf
;-:
That's right?
for (Player p : Bukkit.getOnlinePlayers()) {
yes
Still though that determination
people like you deserve a computer more than anyone imo
List<String> yrequests = DataManager.getFriendsConfig().getStringList(player.getUniqueId() + "_friendrequests");
yrequests.remove(Bukkit.getOfflinePlayer(args[1]).getUniqueId());
DataManager.getFriendsConfig().set(player.getUniqueId() + "_friendrequests", yrequests);
DataManager.saveFriendsConfig();``` for some reason it isn't removing their UUID from the list. I ofc made sure the uuid id of the player I am trying to remove is actually in the list.
Ahh so the error here ,-, I don't know how to solve it ahhh hate
if (getConfig().isList(product + "commands")) {
// Verificar se é necessário estar com o inventário vazio
if (getConfig().getBoolean(product + "empty-inventory") && !(isEmpty(p))) {
p.sendMessage(getConfig().getString("msg-inv").replace('&', '§'));
continue;
Yes, it would help a lot in studies because it's not to do gambiarra!
If your error is the same from earlier, isEmpty(p) does not exist
you have no method with that signature
This to be Player p : Bukkit.getOnlinePlayers() because in this if it would check the player's inventory and what if it was full and sending a message!
I removed the If it worked ,-, puts without an if
I couldn't solve
You do not have a method called isEmpty which accepts a Player object
well
You should learn english and java
you need both of these if you wanna code spigot plugins lol
you're trying to remove a uuid from a list of strings
uuid.toString();
yes
How can I launch player upwards? I've tried this but nothing happened.
player.setVelocity(new Vector(0, 10, 0));
hey, is there a way to set the worldborder color to i.e. yellow or orange or is it only possible to set red, green and blue?
Try a lower number than 10, that's probably just too fast
Same thing, I put 8.
Still too high
try 1 or 2
Even 2 is gonna be really fast
i think u can as i saw somewhere
I want it fast anyway but let's try lowering the value.
Bruh, I even tried 1 and it doesn't launch player upwards.
I triggered it in PlayerInteractAtEntityEvent
But, when I do this, it works
Vector vector = caster.getLocation().getDirection().multiply(1.8);
vector.setY(7);
well then just use that i guess
The thing is I only want to launch upwards, so I'll try to set the multiply to 0
Yeah not working, I need to add a little bit x and z too I guess.
I've tried too with new Vector(0, 7, 0)
try player.setVelocity(player.getVelocity().add(new Vector(0, 1, 0))) maybe
Okay found new progression, apparently I cannot cast it to other player.
So I have like an item skill when you left click to player, it will do something to the left clicked player.
bruh
This might help
legit just launches blocks and players up whenever you click with the item
I hooked that same code to an iron golem
player.setVelocity(new Vector(0, 7, 0));
target.setVelocity(new Vector(0, 7, 0)); // Doesn't work in this part
probably because your target is null or something
or your target has a NoAI tag or NoGravity associated to it
Is it possible the velocity is directly modified because the target is getting knockback?
you can modify knockback too
cancel the event, apply the damage manually and calculate kb
Like I want to launch the target if the target got hit.
Try instead of setting that velocity, get their current velocity and add the new vector to it, then set it
Alright, will try that.
Using Vector#add of course
will likely not work given kb is set after the event
yeah true
In what situation do you need to apply two velocities to one entity at the same time
Would delaying by 2 ticks or so will solve the problem?
Sounds like you need to combine the two
Unless it explicitly needs to be a delayed action
Might
you can also do it within the same tick if you cancel the event, apply the damage and the modified knockback
sure, but I don't want to cancel the event
Error: Asynchronous command dispatch!
Guys, I was creating a plug-in of banknotes and I was looking for a way to recognize them since you can make an infinite amount of them by default from the config. Do you have any ideas? I was thinking about saving the PersistentDataContainer String in the item of the note but thinking about it, maybe generating a lot of banknotes would be a small problem with this?
I don't see any problem that will happen from this, using pdc is the ideal idea here.
I mean, if I generate 80000 items of banknote X, it'll generate also 80000 strings of pdc
I think that this could be a little problem in the future
how much do you think 100k strings weight in ram/disk compared to a single world's data
close to nothing
np
depends what kind of strings do we have
what type of encoding do we use
i am aware that it is more complicated than how i said it but the point was that adding pdc to items is not a concern
- chances are that the JIT compiler + JVM can optimize it a bit by using the internal string pool for instance
code to make an knockback stick in spigot 1.8.8?
martin1000 I'm sorry to tell you but we rarely spoonfeed people here
however I can reassure you there are snippets on how to do this if you'd google that question of yours
look that is my code for now
window.setItem(23, new GUIItem(createEnchantedItem(Enchantment.KNOCKBACK, 1, new ItemStack(Material.STICK)), "Knockback stick", buyer(new ItemStack(Material.GOLD_INGOT, 5), createEnchantedItem(Enchantment.KNOCKBACK, 5, new ItemStack(Material.STICK)), p), ChatColor.GOLD + "5 gold ingots"));
and the exception:
What Api is that even
^
their own presumably
also all in a single line
Caused by: java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:440) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at com.martin.shop.VillagerShop.createEnchantedItem(VillagerShop.java:98) ~[?:?]
at com.martin.shop.VillagerShop.createWeapons(VillagerShop.java:93) ~[?:?]
at com.martin.shop.VillagerShop.lambda$defaultLook$2(VillagerShop.java:48) ~[?:?]
at com.martin.gui.GUIItem.invokeClick(GUIItem.java:30) ~[?:?]
at com.martin.gui.GUIListener.onInventoryClick(GUIListener.java:23) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_322]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_322]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_322]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_322]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8.jar:git-Spigot-21
unreadable
my own
and its just some functions
Yea
but that is not the problem
k
or whatever the name was
Any Idea why this won't set the zombie pigman targetted to be angry? It just doesn't I have it running on a timer every 10 ticks
something like that? ```java
public ItemStack createUnSafeEnchantedItem(Enchantment e, int i, ItemStack stack) {
stack.addUnsafeEnchantment(e, i);
return stack;
}
Have you tried setting the target too?
thats what Ive done now. setting the target every 30 ticks should be sufficient
but yeah it works with the target setting
Alright :)
just one more question
lol
how can I get the first slot in the inventory here
is it getContents...
getItem(0)
oh p.getInventory().getItem(0).getType()
Guys, one last question, in your opinion why the latest version of Vault makes me an override of Spigot/Paper putting its version of bukkit 1.13?
It doesn't do that
Alright :)
@EventHandler
public void onSnowballHit(EntityDamageByEntityEvent event){
Entity damaged = event.getEntity();
Entity damageEntity = event.getDamager();
Snowball snowball = (Snowball)damageEntity;
if(damaged instanceof Player) {
if(damageEntity instanceof Snowball) {
LivingEntity entityThrower = (LivingEntity) snowball.getShooter();
if(entityThrower instanceof Player) {
Player playerHit = (Player)damaged;
//if (entityThrower != playerHit) return;
playerHit.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1, 10));
playerHit.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 3, 10));
}
}
}
}```
why won't that work
?notworking
"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.
sorry
there is no error although it doesn't apply the potion effects on snowball hit
add a print statement then after every if statement
and see where it gets up to
also you're casting the snowball before you check if it is an instance of a snowball
which will exception everytime the damager isnt a snowball
get the shooter
so wait
LivingEntity entityThrower = (LivingEntity) snowball.getShooter();
yes
alright thanks a lot
be sure to fix this as well
alr
Im having issues detecting an inventory on click it send me a regular placed chest inventory but not the player's internal inventory or the custom one i open to the player
@EventHandler
public void onInvClick(InventoryClickEvent invEvent) {
Player player = (Player) invEvent.getWhoClicked();
ItemStack clickedItem = invEvent.getCurrentItem();
Inventory invClicked =invEvent.getClickedInventory();
player.sendMessage(invClicked.toString());
}
Is there a way to load a schematic for each player? A bit like Hypixel's Limbo?
hypixel's limbo isn't even a spigot server
I know
The way to do it on spigot is to just paste a single schematic and hide everyone else
proprietary server
I've messed with it on the past, you gotta reimpl the entire server running on minecraft's protocol
if they send a login packet, you gotta respond with whatever else
Hi, does anybody know how can i translate a number to a string with dots? Like if i have 1000 i want it to translate to 1.000
How can I get the ItemStack of the item that players trying to move in inventory with hotbar keys?
Ah, thank you so much
An out of context question, Java socket are blocking right?
Yeah of course
Socket and ServerSocket iirc are always blocking
Its possible to open a NIO on a free host?
idk
like a server socket?
theyd probably block the port and what not so I dont think so
but worth a try
Sockets can be open on host without knowing a open port
myes but Id imagine that they end up blocking undesired connections etc
A friend has tested opening a local socket for connecting lobby server to bedwars and worked
His goal is to do a simple local network, so he can sync his servers
Because he cannot pay a host for having redis
myes
Is a new american trend using "myes"?
tho genuinly Id stay away from javas socket lib
😂
is the hashcode of an int x; equal to the value of x?
because if so, you can lookup things in a map by hashcode
which might be useful for what im trying to do
We will use NIO (ServerSocketChannel, SocketChannel, Selector)
maybe the duration is too longn
orbyfield theres no notion of hashcode when it comes to primitive types
but if you mean Integer then yeah
yes that is still from Java but Ig
I think that NIO are better designed than plain Socket and ServerSocket
no my point is that Socket, ServerSocket, SocketChannel and ServerSocketChannel... all of them are still fairly underdeveloped in comparison to something like netty
Verano I should mention, ServerSocketChannel as well as SocketChannel still use underlying Socket and ServerSocket implementations
We would use netty but with my friends we get tired of trying to reflect spigot and bungee to get their netty instance
hm
@ivory sleet Because our first goal in a host was we cannot open port, so let try to catch current netty instance and register a separate handler to design our cross-server system
Somehow sometimes I can put the item on the inventory even tho it's cancelled, it's so frustating, only to normal clicks tho.
drag clicks allow the item to go through
yes
do scheduler operations definitely run on different threads? im getting issues where when a scheduler operation is made and that runnable locks, it locks the thread it was called from too
Alright thank you, is there any event that I should listen?
should be it
depends, if it's a sync task, it runs on the main thread
if it's async, there is probably a threadpool (might just be 1 thread) made for async tasks
its sync going async
that make sense actually, ill try running all of my redis stuff with an executorservice async call instead with more than 1 available thread
hopefully that gives me some luck
redis' subscribe method locks the thread entirely btw
depends on what redis lib they use
jedis
jedis
ah
so you're borrowing a connection from the pool and then invoke subscribe on it? I mean from what I've seen people just throw that in a daemon thread
no particular thread pool or anything
well ig single thread executor
I mean whats happening currently is that i've got a pubsub that sends 2 reqs every 30 secs which works fine, received fine, yay. I send a publish of something else, nothing happens (it locks), then when the thread that tries to handle those 2 repeating reqs tries to do it, the server permanently hangs and crashes when jedispool.getresource() is attempted
but that scarcely counts
how do you configure your jedis pool btw?
because iirc it allows a maximum of 8 connections concurrently
that might be the issue lol, all I do is new JedisPool(), it has no other conf options
yeah, the pool has 8 by default
but ive tried logging them, and there's always 6-7 free when the 3rd publish is attempted
oh okay
it'd be better if I could figure out what is actually causing the issue
mind sharing some code?
not easily, its too deeply routed in a big project
though, don't you keep your jedis stuff locked up in a package behind some interface?
I do not : 'D
ah rip
actually
fuck it
im going to recode all my jedis stuff and see if the issue persists
if you have the commitment to, Id suggest using lettuce instead
it has a better design and supports sync and async flawlessly
and with that, phase out the bukkit scheduler in it
lol
oh?
yes it has pub sub and pooling as well
interesting
adding a potion effect for 5 ticks won't be that apparent
llooks like a pyramid
also wtf is this
its the magic of java
ye
good luck :3
you do some very cursed lore checks too
How do i pass an arraylist containing players from my command executor to my listener ?
I don't want to put event handlers in my listener
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
uhh
barely
don't do lore checks btw
just like
nbt
or an isSimilar check also works
Hello! How I can get list of serializable objects?
Use section#getList(string), stream it and map, or how?
If they're all configurationserializable, you can just cast the objects from the list
PDC
something like ?
MySerializble object = (MySerializble) section.getList("coolObject").get(0);
You're casting a list to MySerializable
No need to use the list, just do get()
is there any way to get the type of entity and if it's a player get the name of it when ur getting a palyer's last damage cause and seeing if it's entity_attack
What did the MojangsonParser get changed to in the remapping's on 1.18?
why can't addEnchant add knockback 3 on an item ?
if you want to have something on the damage just use a EntityDamageByEntityEvent event listener.
Idk why having item meta matters
Try addUnsafe
but does addUnsafe also adds normal enchants ?
do people know that early returns exist?
it doesn't exist
wait
you can add enchants to the item and not the item meta
my bad
it does
o
sorry for pinging you btw
Np