#help-development
1 messages · Page 1412 of 1
Is it ok if I call the getLocation() from a player obj inside an async task?
the player is stored inside a synclist
the location may not be accurate
since the fields in Location that hold the position and direction aren't volatile or synchronized
ok thanks
it won't explode, but you might get stale data
it isn't very important for me so I'm fine with it
the material of the placed blocks and the items is different @summer scroll
make sure you're using the correct material
ProxyServer.getInstance().getScheduler().schedule((BungeePlugin) api.plugin, () -> {}, 0, TimeUnit.NANOSECONDS); @wraith rapids is this the way to do this in bungee?
i don't do bungee
Ok
Only async works without delay
Nevermind, I fixed it by creating a list of material and check If the list contains the broken blocks.
use a set
aight
@wraith rapids what's a stack trace?
You know Event to x+(1-9)?
what?
why when craftbukkit sends a packet that contains the yaw it is recalculated with this formula yaw * 256.0F / 360.0F?
You are not making any sense
Try asking a complete question
Do you mean is there an event fired when someone puts an item on the hotbar? or you want to put a bookshelf on the hotbar?
what now?
but my event doesn't work
why it doesn't work?
show me the part that starts with @EventHandler
? No one?
change authors to author
no
my computer crash
Should I test the plugin now?
yes
this
😦
I have no idea what you are asking. Creative inventories have their own events.
event to load "Saved Toolsbars" on creative
@quartz anchor it worked
so what else you want? commands? or other events?
anyone?
i want to learn how to make plugins
if you know java check this guide https://www.spigotmc.org/wiki/spigot-plugin-development/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
take a look at https://www.spigotmc.org/wiki/create-a-simple-command/
it will let you create your own command
There is no API method to swop hotbars
is there an event that runs every tick
you forgot to implement CommandExecutor
try to replace implements Listener to implements Listener, CommandExecutor
or you can just create new class
you see this part?
the reason why CommandKit is in red is because there's no class called CommandKit
but since your main class is also CommandExecutor, you can replace new CommandKit() with this
well actually it would be nice if you learn a bit about java and object oriented programming
how?
no you have to put this, not this()
Bungee: How can I now set the MOTD? They made it a bit difficult in their newest version with ModItem, and ModInfo
there's a video that's 2 hours long
or you know, just read some e-book about java
but ye look like you forgot to import some classes
in intellij if you hover on those red text, it will suggest an edit for you
in this case, it told me to import class
hover on CommandSender and find the "Import class" button
right there
now do the same with Command, ItemStack and Material
can we please not make this a java learning channel? thx
just ask
im making a factions server and every time i make a world for the factions server to be on theres just so much sea
like so much sea and for a factiuons server ofc you dont want the biggest hugest oceans ever i
oh ok
you forgot to import class for Material
almost there
Nothing wrong with teaching, if theres not other questions to answer.
how do i set up permission restrictions for individual command arguments? So that /mycommand foo requires a different node than /mycommand bar. I've tried a few ways but I'm not getting anywhere. Testing with LuckPerms btw.
...
permissions on args is up to you to manage in your onCommand and onTabComplete
OfflinePlayer sender = this.plugin.getServer().getPlayer(mail.getSender());
if(!sender.isOnline()) // line 160
{
sender = this.plugin.getServer().getOfflinePlayer(mail.getSender());
}
else
{
sender = (Player) this.plugin.getServer().getPlayer(mail.getSender());
}```
at de.cimeyclust.util.MailAPI.showMail(MailAPI.java:160) ~[?:?]
at de.cimeyclust.listener.CustomInventoryListener.onMailMenu(CustomInventoryListener.java:268) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor37.execute(Unknown Source) ~[?:?]```
What I can do to fix this error?
line 160
:(
I have no idea what you lilne 160 is
wait until you hear about js
string to boolean is a surprisingly common thing (truthiness)
why are you trying to get a Player when you don;t know if they are online?
I want to get the player and then want to check if he's online
Yes. The player name
Oh. Nice idea. I will try
then use getOfflinePlayer(mail.getSender())
if the returned OfflinePlayer still has a name then its a valid OfflinePlayer and you can check .isOnline()
if(sender instanceof Player)
{
sender = this.plugin.getServer().getPlayer(mail.getSender());
}
else
{
sender = (OfflinePlayer) this.plugin.getServer().getOfflinePlayer(mail.getSender());
}```
I will try this first.
But thanks for advice me
That won;t work
We'll see. I want to test out anything.
if (sender.getName() != null and sender.isOnline()) {
sender.getPlayer();```
you can get the player straight from the OfflinePlayer, if they are online
yeah just cast it
Use sender.getPlayer()
if you can you should try storing your mail using the players UniqueId rather than their name.
Yes. I have did that 2 minutes ago. xD
ok
depends on a few things. What you mean by "script" and how you are starting your timer
?paste you are going to have to show code.
ok a few things.
- Your
startSecondsCountdown()says it returns a Runnable but only returns null. - If you make a final local field for your player in your onCommand and start the runnable there it can access it.
Help me which is the best hosting 24/7 free
ok so it seems like player.hasPermission(String) isn't influenced by LuckPerms, how do i properly check if a player has a permission regardless of what permissions plugin is used by the server...?
kind of annoying that i even have to ask that here, but anything google turns up on this is so vague
how do i make something like this
{
success: true,
player:
stat1: 203
stat2: 304
name: "Need_Not:"
}```
i can't figure out how to add keys inside keys
using javalin which uses jackson
public class JsonData {
boolean value = true;
boolean success = true;
}```
app.get("/player/:uuid", ctx -> {
JsonData hi = new JsonData();
ctx.json(hi);
});```
Someone help me out please
How can I cancel the teleport event
Player player = e.getPlayer();
double cooldown = player.getCooldown(Material.ENDER_PEARL);
if(player.hasCooldown(Material.ENDER_PEARL) && cooldown > 1) {
return;
}
e.setCancelled(true);```
Wht is this
when a player is hit enderpearls go on a 15 second cooldown and I want to cancel it if the player threw the pearl before they were hit
yeah but it doesn't cancel
trying to get it to cancel if the cooldown is higher than 1
but youre returning if the cooldown is higher than 1
so get rid of the return?
so yeah, setCancelled will not be reached
@SuppressWarnings("deprecation")
public void set(Player p) throws IllegalStateException, IllegalArgumentException, UserDoesNotExistException {
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Objective ob = board.registerNewObjective("main", "dummy");
ob.setDisplaySlot(DisplaySlot.SIDEBAR);
ob.setDisplayName("§l" + p.getDisplayName());
Team money = board.registerNewTeam("money");
Team online = board.registerNewTeam("online");
ob.getScore("§fKontostand7: ").setScore(3);
ob.getScore("§d").setScore(2);
ob.getScore("§fOnline§7: ").setScore(1);
ob.getScore("§e").setScore(0);
money.addEntry("§d");
money.setPrefix("§e" + Economy.getMoney(p.getName()));
online.addEntry("§e");
online.setPrefix("§e" + Bukkit.getOnlinePlayers().size() + "§8/" + "§e20");
p.setScoreboard(board);
}
@SuppressWarnings("deprecation")
public void update(Player p) throws IllegalStateException, IllegalArgumentException, UserDoesNotExistException {
Scoreboard board = p.getScoreboard();
Team money = board.getTeam("coins");
Team online = board.getTeam("online");
money.setPrefix("§e" + Economy.getMoney(p.getName()));
online.setPrefix("§e" + Bukkit.getOnlinePlayers().size() + "§8/" + "§e20");
}```
I have problems with my scoreboard update. The set method works fine but the update don't. Here's the error:
https://paste.md-5.net/okidiponol.http
do you know what return does?
not really I just go in to coding
return; stops the codeblock within onTeleport from running after that point
which explains why your e.setCancelled(true); is probably never executed
oh ok I'll try to removing it and tell u if it works
anybody help?
it doesn't cancel still ;-;
this is what you say in set() Team money = board.registerNewTeam("money");
and this in update() Team money = board.getTeam("coins");
"money"
"coins"
👍
what's your code look like now?
public void onTeleport(PlayerTeleportEvent e) {
Player player = e.getPlayer();
double cooldown = player.getCooldown(Material.ENDER_PEARL);
if(player.hasCooldown(Material.ENDER_PEARL) && cooldown > 1) {
}
e.setCancelled(true);
player.sendMessage(ChatColor.RED + "You cannot teleport while binded!");
}
}```
is the cooldown on being attacked or your pearl landing?
do you have the @EventHandler?
yes player.hasPermission(String) is the correct test
put those last two lines within the if statement
within the { }
also this 😂
rightttt
could be
O.o weird
if(player.hasCooldown(Material.ENDER_PEARL) && cooldown > 1) { so the && cooldown > 1 should be a if statement?
what else
Hum guys. Just a quick question. Does anyone have a link for a good scoreboard tutorial. I don't know what are its usage. (I've read about storing data, player teams)
@eternal oxide
it cancels the event even if the enderpearl only has 1 second cooldown it's suppose to cancel if the enderpearl has a cooldown higher than 1
I've tried following this tutorial for SQLite integration https://www.spigotmc.org/threads/how-to-sqlite.56847/ but It can't resolve Main in the error class any Ideas?
Hello. Can i know how to play a sound correctly for 1.16, i tried but i failed and it prompts an error.
Uh does canceling the event affect it?
its probably in ticks. Usual server tickrate is 20 per second. So you should check for cooldown > 20 in that case
thanks
how can i ask if my inventory is the right inventory by the name in the InventoryClickEvent (event.getClickedInventory().getName() does not work)?
getView()
is getView the new getName?
no, it contains teh two linked inventories from that event
its better to check instances though
so java if (event.getClickedInventory().getView().equals("Name"))
no
but how can i get to the name of the Inventory?
getView().getTitle()
it works thank you you're a Genius ❤️
oh and that returns the name? @eternal oxide
yes
so i can .equals() it?
no problem 👍
what are teams used for?
nvm
and how can I ask if the Clicked Item in the Inv is for example dirt?
oh i know it
sry
Many things. But mainly to group things together
.equals on objects
I want to hide player names without hiding the player itself. Can I use teams or do i need to use the packet PacketPlayOutPlayerInfo?
then yes to compare to an Enum you getType() and ==
oh yes trueeeee thx
any Ideas here?
Yes, you didn't read the explanations the dev wrote. You just copy/pasted his code.
ElgarL
yo how do i add a dict to a config n get the value?
dicts in Java are Maps
Maps can be put straight into a config with config.set("path", map)
n getting it?
BUT you must save and reload the config for them to be correctly accessed
you access them the same you would with any config entry
send the error from console
how can I check for irl time
bujt timezones and stuff
how am I usppose to use that?
this checks for time where the host is located
Im trying to execute a command when its like 12AM
lemme give you example
Thanks!
should be smth like this https://paste.md-5.net/umuwobicij.cs
@stiff topaz whats at line 21 at Launch.java
oh so 0 is 12 am?
yea
ok pardon me my english is bad but isnt 12 am the one that its day?
i dont really know i have 24h format here but 0 is 12am and 12 is 12pm
also I put that in onLoad right
yeah you could bcz this is java stuff and not the spigot things
0 is midnight, 12 is middle of the day
Ok thats what I thought
yes should be but change the hour == 0 to hour == 12 if you want the middle day
yw
if you have no chestplate the returned object will be null so you can't use .getType()
?
w8
smth like this https://paste.md-5.net/equbobesim.cs
oh yeah thats allright
good job
dont mind it its only bcz the int hour is 0 but the 17 line changes it
o ok
also command executing is right
right
its suppose to send the command thru console
you didnt send any commandexecutor class
correct?
yes
yay
if an Object can be null you must always null check
if (obj == null) {
//handle
}
ItemStack item = inventory.getChestplate();
if (item != null && item.getType() == ...```
how can i fix this? https://paste.md-5.net/laficafiwu.cs
the error is causing the line 6
i = size - 1
arrays index from zero
can't access arr[arr.length]
if it says size is 9 then its 0 to 8
oh so i just do "for (int i = 0; i <= instance.getConfigHandler().SETTINGS_TABLIST_SORT_PRIORITY.size(); i++) {"
*<
and fixed ty
why is the team still null even tho i initialize it? https://paste.md-5.net/puminabupa.cs
line 13 shoudl be continue unless you want to stop at teh first null name
okay
and yoru name is not null
its owner
nowhere do you initialize team. You only loop teamName
at least not till after you output 5
i do
does anyone know how to fix this?
yes, when its initially null
okay how do i fix that then idk
have you created the team?
yes
you can;t get a team that you havn't created
debug your initializing of team
okay
your getTeam on the scoreboard is returning null so you can;t have registered your teams at this point
did this https://paste.md-5.net/gozonayaxo.cs
that just shows the code is running. Output some field values
like?
teamName, the index i. also why is 4 firing? If this is the first run though there shoudl be no team to unregister
instance.log("value: "+(team != null)); Output: [AstreansLobbySystem] value: true
the team name is 0_owner
shouldn't this be looping over the values no tthe keys? instance.getTabListSortPriorityTeams().keySet()
you added the names as the value not the key
im checking for the key
the key is whats in the config (owner) and the value is what the name of the team (0_owner) is
you are registering the team with teamName but you add that to your Map as the value not the key
in https://paste.md-5.net/gozonayaxo.cs you are regsitering the Team with teamName, then storing that name as the value in your Map
yes
in https://paste.md-5.net/irujotegaq.cs you loop over teh keys not teh values when trying to retrieve the Team
You seem to never use teh value in your Map again
wait i dont get it
im just trying to do sort priority in tablist but idk
whats the error with the team being null
how did 4 ever show in https://paste.md-5.net/irujotegaq.cs?
oh now im reaching getting the team.addplayer working
forgot to use value and not key in the "team = instance.getServer().getScoreboardManager().getMainScoreboard().getTeam(instance.getTabListSortPriorityTeams().get(teamName));"
but its not showing any kind of suffix or prefix
where are you expecting to see the prefix/suffix?
where are you expecting to see that? in tab list?
yes
Have you set the scoreboard for the player?
Look at the last spoiler section https://www.spigotmc.org/threads/tab-prefixes.277567/
spoiler section?
in that thread
like this ?
the very last spoiler section
yes
okay?
I see you adding the player to the team. I don;t see you setting the scoreboard for the player
I'm not sure you have to for teh Main board
but it seems to be the only difference other than you useing Main and not a new
this is my code rn : https://paste.md-5.net/akubejufek.cs
doesn;t addEntry take the players uuid as a string?
idk i saw it in the thread
ok, and still not in tab?
nope
then try using a new scoreboard instead of main
no clue then
hey, so I asked a few people about this, but they couldn't give me a good answer, but have you had an issue with entity location's printing not the same coordinates even if I teleport to the location with the correct ones? Like I know it rounds it up, but I don't know how I can stop it from rounding it up
for example, if my intended location is 121, 64, 128, and print my location and go to the intended one, I will get 121, 64, 129, it's rounding it up, completely messing my code up, how can I make it stop rounding it up?
getX() is precise location getBlockX () is rounded.
getX gives a milion numbers
accurate
I just tested this code and it works using Main or new scoreboard for tab prefix https://paste.md-5.net/uweyoqiyuq.java
how do i fix this ? https://paste.md-5.net/ucovoqefig.cs
How decompiler project with fernflower?
how do i get the prefix of the group player is in vaultapi im using chat
So if I have a mongoDB database im using in my plugin would I create a collection for every player?
Anybody know how I can set the direction of a sign?
Trying to make it face where the player is facing but casting it to a rotational and using .setrotation does absolutely nothing
did you set teh BlockData back on the Sign after rotating?
No, how does one do that? 🙂
block.setBlockData(data)
Ah ok cool. Didn't realize thats how it worked. Couldn't find anywhere that said that. I'll give it a shot. Thanks!
Eeyyyy it worked. Thanks a bunch.
Hello, I want to created a custom NPC.
When a player is login, I'm sending packets to displayed him the EntityPlayer. But the npc dissapear from player when the chunk is unload. Do you know if I need to resend the **PacketPlayOutPlayerInfo **and **PacketPlayOutNamedEntitySpawn **packets to the player please ?
Was about to say
hehe xD
;/
is there a way to when detecting for an itemstack to make it ignore the itemmeta
elaborate
What citizen is ? xd
A plugin for spawning NPCs
Well it's a plugin but can be seen as a lib in your case
i am tring to detect when a player makes a netherite pick but i want to ignore if it is enchanted
Ahh, i doesn't want to use an external plugin/lib :d
Just match material with getType
Why not
o ok thanks
Because I'm actually creating my own lib for my plugins
I guess? But you could look into how they do it since I'm not an nms expert myself https://github.com/CitizensDev/Citizens2
Another lib 😓
hey how could i make smth like server and client? server would be like a bungee server and if somebody writes command (ex. /hello) then the server would retreive something like memory status from all the clients?
hf doing that all the time
yeah people and libraries these days lol
Do you want a client side mod to fetch data from clients?? Elaborate
thx x)
no just plugin
ok thx, i'm gonna take a look
You can't fetch client info from the server
by server i mean bungee server and client spigot server
Is there a way to get nearby players to an entity without checking every player? If not what is the fastest way to do it
Oh use a plugin messaging channel
#getNearbyEntities
and check if the entity is a player
Sick thanks
or an another way
i dont really wanna use plugin messages channels for this
redis
Redis/Jedis
okay
Sorry for being dumb but I’m trying to find the source for entity and just can’t find it cause I’m on my phone and it sucks
Hey, is there any reason why this wasn't done before? https://github.com/SpigotMC/BungeeCord/pull/3078
how would i make an entity's customName be visible only from a certain distance
cuz rn i am making a mob levelling system
and i dont want to have to look down
and see like 100 name tags
but i also dont want to have to walk up to a zombie to see it's level
Hey, i guess that will be pretty easy for ya but i want to know how to create one itemstack for one item and can use it in different classes? i tried to make it static but i didnt know how. somebody will help me?
you could make the customnamevisible to false, attach an named armorstand with packets to the entity and just show it to a player if he is within a distance of X
by sending packets 🤔
i havent really used packets much
https://www.spigotmc.org/threads/i-want-to-learn-understand-packets-but.342524/#post-3183758
https://wiki.vg/Protocol
https://bukkit.org/threads/info-packets-nms-explained.177955/
Hey guys, I'm back with another post in the resources section!
This time it's all about packets and NMS and how to use them. Packets are relatively...
i have used packets before
@hybrid spoke can you help me please?
i dont know what packet to use and what to fill in
?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.
@hybrid spoke
what is the packet name @hybrid spoke
god cipher fr got it in for himself
I.. just sent you the website where you can look it up
you want to SPAWN an ENTITY which you want to ATTACH or even MOUNT on another ENTITY, right?
and you want to play that OUT via PACKETS
or am i wrong
i want to show a name if they are within 5 blocks
and you do that by doing this
Guys, is there an hacky way to hide a player from the tab list or do I need to use the PlayerOutInfo packet using Remove_Player?
if you just want to hide him from the tablist and not everywhere else, you will have to send packets
Ok, The packet that i must send is PacketPlayOutPlayerInfo right?
k
Why is it that when I use Player#setExp or Player#setTotalExperience that it doesn't change the player's level.
Does anyone know about this?
it doesn't automatically update the level of the player
already found a way to probably fix it
while(user.getExpToLevel() == 0)
user.setLevel(user.getLevel() + 1);
Why 👀
Because I'm trying to give a player a XP reward for something.
That's the most useless loop I've seen
there is xp and level. xp is distance to next level
there is a #giveExp. maybe that will update the level. but i am not sure
Okay I'll try and figure it out
Is there a method to delete a non-empty directory without first removing the files recursively?
no
😦
why ?
?paste
...
if is nul
Bukkit.broadcastMessage("Iniciando metodo de spawnar armor stand com a localização: " + local.getX() + " " + local.getY() + " " + local.getZ() + "com o item: " + item.getType().toString()); this debug work
If I remove the locks, what are the issues? Classes try to write after I've eliminated the files?
if you were running a fun version of java it would neatly tell you what is null xD
i dont know if is because i returned a armor stand
java 16 when
i'm using 8
when doing file access only one thread should be able to at a time
Consolidate all file access through one class
you can multi read but single write
this make sense
i cant understand how solve my problem
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Bukkit.broadcastMessage(getConfig().getString("messages.loot_resetar"));
LootManager.loot.stream().filter(e -> LootManager.roolItem(e.getChance()))
.forEach(e -> LootManager.spawnLoot(e.getLocation().setDirection(e.getDirection()), e.getItem()));
}
}, 0, 10 * 20L);
}```
setDirection() can be a problem ?
you are getting the direction and setting it. you are doing nothing with the direction
''setting it'' ? you mean setting a location for a direction ?
is your e.getDirection() supposed to give a different direction to the location?
what are you spawning?
your direction is near zero, so pretty much South
ooh,
i need spawn a location with pitch and yaw i think
i need spawn a armor stand like this understand
yaw is rotation. you don;t want pitch unless you are going to tilt it
just wondering is it possible to change the text that comes up when player switches a item
like the text just above the hotbar but below actionbar
not just that but
I have seen servers change that text
when the name of the item isnt there
maybe some protocol fucknuggetry, don't know
o well
#help-development message i still getting this error anyways
how do i fix
playerslist: "[CraftPlayer{name=Need_Not}, CraftPlayer{name=Ned_Not}]",
LootManager.java:67 is being passed null
We need more context.
i did
link it
String playerslist = Bukkit.getOnlinePlayers().toString();
What's the issue it's doing what it suppose too.
and then put it in jackson API to make it json
the issue is i want it to say
playerslist: "Need_Not", "Ned_Not"
Then write your own toString
^
how
Its not a difficult thing to loop over your Collection and build a string
how can i remove the craft player and { and [
Well .replace()
ArmorStand armor = local.getWorld().spawn(local, ArmorStand.class); line 67
local is null
i bet whoever implemented the helpful npe's in modern java versions has committed suicide
Why?
because nobody knows it exists
its great
and there are still millions of people screaming REEE WHY NPE
when the next LTS comes out everyone is gonna use it
i use java 16 for my dev servers already
Hey, just a little question. is there possible to change items display name randomly? By that i mean lets say you had 1 pickaxe in ur hand for like 5 mins, and if you right click on it the item meta changes?
so like just under interactevent or smthing
yes
Ok ty.
basically
i have to if statements
two*
if booktype is teleportationbook
set books display name to a certain name, and under that i have if book type is dashingbook, set the display name to a certain name
and im setting the itemmeta after both of the if statements
Is this the right way to do it or i should add them in both if statements?
Or how exactly setmeta is used?
In this case
If you are talking about client keyboard buttons, only those buttons that trigger an event, like movement
right clicking a stone button
for example
Then as Nuxoria said
where can i see the implementation of getNearbyEntities
in the source
won't that ignore stone button cooldowns?
yes
there's an event for it but I don't remember what it is
iirc levers share the same event
@wraith rapids i can only see the interface method
that's because you don't have the source
i been tryna find it for a while
you need to build it yourself
the sources aren't distributed publically because they include mojang source
and redistribution of that is a no no
so decompile the actual server jar?
java -jar BuildTools.jar --generate-source
oh
so instead you need to run buildtools and use it to build the sources from the diffs
thanks
@Override
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<Entity> filter) {
org.spigotmc.AsyncCatcher.catchOp("getNearbyEntities"); // Spigot
Validate.notNull(boundingBox, "Bounding box is null!");
AxisAlignedBB bb = new AxisAlignedBB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
List<net.minecraft.server.Entity> entityList = getHandle().getEntities((net.minecraft.server.Entity) null, bb, null);
List<Entity> bukkitEntityList = new ArrayList<org.bukkit.entity.Entity>(entityList.size());
for (net.minecraft.server.Entity entity : entityList) {
Entity bukkitEntity = entity.getBukkitEntity();
if (filter == null || filter.test(bukkitEntity)) {
bukkitEntityList.add(bukkitEntity);
}
}
return bukkitEntityList;
}
thank you i appreciate that
and the nms method it defers to
@Override
public List<Entity> getEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, @Nullable Predicate<? super Entity> predicate) {
this.getMethodProfiler().c("getEntities");
List<Entity> list = Lists.newArrayList();
int i = MathHelper.floor((axisalignedbb.minX - 2.0D) / 16.0D);
int j = MathHelper.floor((axisalignedbb.maxX + 2.0D) / 16.0D);
int k = MathHelper.floor((axisalignedbb.minZ - 2.0D) / 16.0D);
int l = MathHelper.floor((axisalignedbb.maxZ + 2.0D) / 16.0D);
IChunkProvider ichunkprovider = this.getChunkProvider();
for (int i1 = i; i1 <= j; ++i1) {
for (int j1 = k; j1 <= l; ++j1) {
Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
if (chunk != null) {
chunk.a(entity, axisalignedbb, list, predicate);
}
}
}
return list;
}
which?
How can I teleport armorstand to the player with every tick? I tried to create a bukkitrunnable in a new class and get armorstands from the hashmap, but that didn't work.
Code:
public static HashMap<Player, ArmorStand> armorStands = new HashMap<>();
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
ArmorStand armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getEyeLocation(), EntityType.ARMOR_STAND);
}```
```java
@Override
public void run() {
for (Player p : Bukkit.getOnlinePlayers()) {
ArmorStand armorStand = TestClass.armorStands.get(p);
armorStand.teleport(p.getEyeLocation());
}
}```
```java
Loop loop = new Loop(); loop.runTaskTimer(this, 0, 1);```
is chunk.a comprehendable?
what version?
i mean, you may have to check those out
nms is just a research project everyone should do
Ok just checking you registered the event right
hey, how can i spawn minecraft:item particles?
player.spawnParticle(/*insert smart things*/);
// /particle minecraft:item honey_block ~ ~1.5 ~ 0.3 0.3 0.3 0.000001 15
@raw basin check java docs
there are nothing(
I need a particle with some data /
there is NO minecraft:item honey_block
maybe you want step effect
ona block
you wouldn't need this at all
i think it's this
I already found the problem, I didn't add any value to the hashmap because of it, but thank you
Oh Ok
the solution:
player.getWorld().spawnParticle(Particle.ITEM_CRACK, player.getLocation(), 15, 0.3, 0.3, 0.3, new ItemStack(Material.HONEY_BLOCK));
im pregenerating my world
what is a good speed of chunks / sec
i am doing 50
and the tps is 20
no change
im using WorldBorder
because RWG recommends it
wrong channel
tps is a poor measure of performance
watch TPS but also CPU load
the actual metric you want to look at is mspt
Is it possible to add Persistent data to a block? eg add a String to a block, and it won't go away even after a restart?
if it is a tile entity, yes
use the persistent data container of TileState
if it's a regular block, you're fucked
if you were feeling it, you could try to use the Chunk PDC and kinda go from there
tho tbh, that is pretttyyy hacky and will fail the second a piston or something moves the block
that takes a lot of effort to get working properly
^ yea
with bukkit it's like borderline impossible to even make sure your data for a block gets removed when the block disappears
need to have an event listener with like 30 different event handlers
and there's still shit that is literally impossible to deal with, like plugins setting blocks
I am guessing a block of hay is not a tile entity, is there a non persistent way? eg something to add data to a block until the server is restart
it's not a tile, no
:rip:
tiles are things like furnaces and chests
and how can I more precisely refresh the height at which the armorstand is located so that it teleported over the player, because when I walk normally the armorstand moves behind the player without delay, but when I jump or crouch it changes the height a little with a delay
aww no custom emojis right
Is there a temporary data storage for blocks?
what are you trying to achieve with this hay block though
there's nothing
a block is just a few bits in some block palette in some chunk
there's no room or capacity for extra stuff to go in there
There is https://github.com/Flo0/PersistentBlockAPI which might work as long as you don't care about plugins placing blocks
you could try registering your own tile entities or something i guess
we are a RP Server, and we use a structure of 3x3 hay blocks for the fire department when a person wants to jump from a building. like a big cushion. and we want the firedepartment to be able to just break the center of the hayblocks, and using the data stored we know if its a structure for the firedepartment or just a normal block of hay
well
if you're rp enough, you probably don't have pistons or anything pushing these hay blocks
^ then chunk pdc might be a valid option
you can probably just store the Block in a map or a set somewhere and associate data with it, or go with the chunk pdc
former being transient while the latter is persistent
does anyone have a ressource that explains chunk pdc
also a few youtube tutorials out there for PDC if you are more of a visual learner
at least on paper, i'm guessing spigot has pulled that from downstream since you're talking about it here
Chunk PDC ?
yeah
okay so once the blocks are moved the pdc is gone right? or atleast the data I added
really? i vaguely remember people raving about it in the paper discord a good while ago
no, the pdc is part of the chunk
the chunk doesn't give a shit about your blocks
you'll have to track them manually
which is the hard part about this 😅
but yeah, paper had a PR open for it, then someone implemented it incorrectly on spigot and it broke every world it touched for a commit lol
average day in the bukkit ecosystem
tru 😄
Not sure what ecosystem you're in but I don't recall the last time there was a breaking change in CraftBukkit beyond that most recent one
and it was because of an untested PR
pretty sure it wasn't even too breaking 😂 paper broke, spigot just kindly doubled your chunk size on the disk
damn those optimisations paper 😦
Yeah it was hardly "breaking"
Yeah, sorry got it mixed up with the paper merge of upstream which just kindly corrupted all them worlds
how do I set the item for a custom item as a custom head?
like the material
I want to make a guardian helmet and I want to use a guardian head
how to use skullmeta?
cast it to a playerhead material item's item meta
Is aternos best?
so i read up on nms and want to get started with it, seems pretty scary to get into but do you guys think just a small scale npc entity dialogue/quest system would be a nice start? already made a working mob arena with normal spigot
Maybe, but you can already do that with citizens
Or the citizens API
It’s easier to start with small things the API doesn’t have access to
But generally you don’t need NMS that much
yeah but i dont want to use citizens, its partly a learning experience for me to get into nms and it's flow
What would you use nms for mostly? custom entities like skeletons shooting 2 arrows and such?
Mob AI, packet manipulation, a few things here and there the API doesn’t cover
and also yeah im planning on using just spigot and using nms for things i can't use spigot for (i was about to add a boss mob to my arena but found out i'd need nms for more customization so that's how i got into it)
i'll get working on it!
Help, I've never seen this error before lol
Line 17 in onenable:
getCommand("donationwebhook").setExecutor(new DonationWebhookCommand());
Is donationwebhook a command in your plugin.yml?
I just accidentally clicked build project instead of build artifacts while saving my pluigin, wl that do something bad?
🤦♂️ I am an idiot. Happens every time 😂
🤦♂️ I am an idiot. Happens every time 😂
@woeful moon haha, happens to everyone... I hope
Do we have to check for e.isCancelled() when doing event handlers?
by default it ignores cancelled
False
so it will never be called if a previous handler cancels it?
ignores cancelled events, no?
ignoreCancelled is false by default
i don't think that's true
I have if(e.isCancelled()) return; at the start of all my event handlers and im just wondering if I need it
make an annotation and put (ignoreCancelled=true)
Just add ignoreCancelled = true to the annotation
aaa ty
is there an alternative to the deprecated InventoryClickEvent#setCursor? it says the reason it's deprecated is because This changes the ItemStack in their hand before anycalculations are applied to the Inventory, which has a tendency tocreate inconsistencies between the Player and the server, and tomake unexpected changes in the behavior of the clicked Inventory.im thinking i should just setCursor in a delayed task...
seems to work
?paste
Hey guys! Do any1 of y'all know how to get a player skull in 1.16.5?
I used to know it in 1.8 but I don't know how to get it in 1.165
How can I detect if a player opens a crafting table?
What event would basically be in this category
with a PlayerInteract event
^
then check if the block, which gets clicked is a crafting table
ok thanks
No problem
can someone help me now with this?
Ah I see e.getClickedBlock()
yes
Or this
or that
but if he wants to make an own crafting menu of something he has to use the interact event
to cancel it before it opens
Create an item with Player Skull material
Then cast the item meta to SkullMeta
well setOwner takes an OfflinePlayer
player.getMaxHealth is deprecated, should I use something else. Or is it ok to use.
you mean after a server crashed or if as example a bedwars game is over?
like
if i do /stop
or they get kicked
they are put in the hub
or kicked (if they are already in the hub)
Did you code before?
wdym
are you a developer?
How can I check if a player has a crafting menu open?
@EventHandler
public void kick(ServerKickEvent e) {
ProxiedPlayer p = e.getPlayer();
if (!e.getKickedFrom().getName().equals("lobby1")) {
p.connect(GlobalMessage.getPlugin().getProxy().getServerInfo("lobby1"));
p.sendMessage(ChatColor.RED + "You have lost connection to the server you were on, so you have been put in the lobby.");
}
}```
YES
caps
oh I see
just check when a player right clicks on a crafting bench
but like this could be a while after, is there no other way?
Do you get some kind of error?
no
it only works when ur disconnected while joining the server
like if u have wrong version
Override the /stop commands and/or any other commands you want (/kick) to send them to the lobby then execute their respective function
player.getOpenInventory().getType() == InventoryType.WORKBENCH
assuming you mean the 3x3 crafting menu
yea but
@opaque mango Thx
what if the server stops by me pressing the X on the bat file
instead of /stop
ik its not good
or another reason
that isnt a command
https://beginnersbook.com/2013/12/how-to-serialize-hashmap-in-java/ will this method work with ItemMeta? i.e. is ItemMeta serialisable and deserialisable in a standard way
i am programming bungeecord anyway
you can look at how this plugin does it https://www.spigotmc.org/resources/movemenow.17/
yes
alright
both ItemStack and ItemMeta implement Serializable
they implement ConfigurationSerializable but not standard Serializable, should I just assume it's a superset of it?
or subset ig
built-in java serialization sucks
ConfigurationSerializable basically means you can serialize it as YML
and YML is for configs, not for data storage, so...
I would ideally serialise it as a byte array
and it sucks even for configs, but we are stuck with it
how does java serialization suck
I want to save to file a class, representing a chunk, who's only non-transient field is this:
protected Map<LocCoordinate, CustomBlock> blocks = new HashMap<>();
where LocCoordinate is 2 bytes and a short (for local x,z and y) and CustomBlock is fully represented by an ItemMeta field
so LocCoordinate should serialise fine
I'm just worried CustomBlock will serialise ItemMeta as a reference
my other option is to serialise as text but that is space inefficient
ig u could use ServerSwitchEvent
?javadoc Fireowrkl
package index
?javadoc firework
bruh
whats the default firework velocity
Hello! Anyone help me how to make class that work like Player class? I mean it syncs to every stored player variable. Example if a function contains Player parameter(public void changePlayerName(Player player){...}), if we edit player name vai the variable in parameter, it will affect to the original Player instance right? So, why it does so. And how can I do like this in my own custom class? You understand me?
are you asking how to change a variable?
No
(almost) everything in Java is passed by reference
If so, first, where do Players store?
in a heap
changePlayerName takes a reference to your player and sets some values in the memory that the reference points to
Eample it store in a list, then where is that list?
all objects separately are stored in a heap
if it works as c++
which i think it is
No, I just mean, store in somewhat class(and a variable that hold player collection)
ohh
yeah
it's stored in multiple locations actually
you should be careful what'u doing
one singular player is stored in only one location no?
it is just referenced in multiple locations
yes it's stored in heap with an address
nothing else holds but a reference to it
a pointer
the heap is simply stored when you do
new Object();
even if it's not asigned
I think Sivann thought when you pass player to a function it receives a duplicate
which isn't the case
But, I try a string it does not work. I just initialize a String variable in User class(for example) and I collect that string in contructor. Then when I modify string in User class or in that original string from class, it doesn't affect each other.
modifying a String creates a duplicate I think
strings usually are cached but don't relay on that
either that or you are reassigning your string reference
if you do:
String s = player.name;
s = "aaa"
Ohh
then that will just reassign s to a different memory location (that of "aaa")
it'll make the cheap check
if it's cached
otherwise it'll go deeper to check it
i think modifying a string will give you a new String() which is no longer supported by caching
Yes, it looks duplicate, you are right🤔
But if in parameter, it's not mean duplicate?
so in memory you would have at first:
0xA: Player
0xB: -some data
0xC: -name: "bobb123"
0xD: -more data
0xE: String s: points to 0xC
then you run s = "aaa"
now in memory you have:
0xA: Player
0xB: -some data
0xC: -name: "bobb123"
0xD: -more data
0xE: String s: points to 0xF
0xF: "aaa"
String a = "a";
and
String b = "a";
these are cached
but not
String c = "a".substring(1).concact("a");
because it uses new String(chars);
Ahh, yeah
in short if you want to modify a field of the Player, you need to do Player.xyz = "aaa"
doing String s = Player.xyz and then s = "aaa" will not work
but why would you wanna know this?
Can I do this to store player in another class?
class User {
Player player;
public User(Player player) {
this.player = player;
}
}```
in English, it would be like saying:
make s point to the memory at Player.xyz
then, make s point to the memory with "aaa" in it
But you want to say:
make Player.xyz point to the memory with "aaa" in it
Which is different
yup
Store the player UUID and fetch an Offline player object upon request
Ahh ohh yeah
oh, i doubt you have control over that in java
it's not worth it imo
this is called hardcoding
and you're creating stress over changes
Haha
passing a reference is hardcoding?
That means when we modifiy player in User class, it will affect to the original Player that hold by somewhat class, right?
we have design patterns to allow us to switch or adapt classes
yes, unless you reassign it
player = new Player() will not affect the original
player.a = b will affect the original
if you want that
Ohh yeeaahh!! I got it!
Player is not guaranteed to be persistent where UUID is.
What if I want to copy a player? Makes it duplicate.
The Player object may go stale
that you can @rigid otter
Yes, of course
What?
the thing I like pointers for is functions such as bool tryParseInt(int *out)
though luckily in Java for this specific scenario there is Integer
still it feels heavy to need to create a new object just to package multiple values into one return
you can pretty much do side effects with lists so it would be good to allow them for all types
Ok, but now I got the main point! Thank you Fr33styler#7673 Kaktusz#7790 ElgarL#3528 Buby#2953
also
all the pointers
are copies
the one passed via the function param are copies of the one you used to call that function
i think c++ has it too
so chaining 5 functions with the same argument creates multiple pointer objects?
ig that makes sense considering you don't want a reassignment to mess with the previous function
exactly
have you done a java course before?
same for objects tho
it'd be much much better if you spent a day just learning java without anything spigot related
what is wrog with this code?:
if(Objects.requireNonNull(event.getCurrentItem()).getType() == Material.BEDROCK) {
Player online_player = (Player) Bukkit.getOnlinePlayers();
Player target = (Player) event.getWhoClicked();
Location target_location = target.getLocation();
online_player.teleport(target_location);
target.sendMessage("§aAlle Spieler wurden zu dir teleportiert");
online_player.sendMessage("§f" + target.getName() + "§a hat dich zu ihm teleportiert");
target.closeInventory();
}```
nah i was asking you
aye
Bukkit.getOnlinePlayers(); returns a list of players not a player object
(Player) Bukkit.getOnlinePlayers(); ah yes casting a collection into a player
and how can i get all of them in a variable?
most of my misconceptions about Java are adjusting from other languages
multiple players could be on, how would you handle that
doing C# since 2014, then started uni this year which was C, Assembly and now Java which I used briefly before
if you've been doing c# this should feel very familiar
@bright yoke and how can i get the Online Players in a variable
and you?
okay
how do you want to handle that
yes...
i dont want to spoonfeed you, try to write something
okay
do you know how to loop through all the players?
forEach works
so players.forEach or so?
yes
for (Player someone : players) {
// Teleport 'someone'
}
``` this would also work
is there a difference between forEach and for(... : ...)?
minor speed decrease
but 99.9999% of the time the code is slow because of something else, not something as simple as forEach
there's also the limits of lambda methods, such as not being able to access non-final variables
ah so they're not as powerful as in C#
String list = "";
players.forEach(player -> {
list += player.getName() + ", ";
});
``` this won't work for example
but in exchange there's java enums so you win some you lose some
java enums are god but other languages cant use them because of a stupid patent
yes oracle has them patented
wow that sucks ass
A system and method are provided that facilitate use of an object-oriented
enumerated type within a computer program. During operation, the system
receives source code for the computer program. The source code contains a
declaration for an enumerated type. This declaration specifies a fixed number of
enumeration constants that comprise the...
but what should i write into the () after players.forEach()?
if you don't know how to use forEach, use this instead