#help-development
1 messages · Page 2221 of 1
not really giving any information here… i’m asking what the string represents, and where it originated from
it is a location of a raid and it's from raidTriggerEvent
ok, so have you checked if the key that the number is being set under and key are the same?
yes
when I do this @EventHandler public void badOmen(RaidTriggerEvent event){ JsonElement element = JsonParser.parseString(String.valueOf(event.getPlayer().getPotionEffect(PotionEffectType.BAD_OMEN).getAmplifier())); obj.add(event.getRaid().getLocation().toString(), element); Write(); }
it makes the entire json file "null"
try (FileWriter file = new FileWriter(plugin.getDataFolder() + File.separator + "data.json")) {
Reader reader = new FileReader(plugin.getDataFolder() + File.separator + "data.json");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
file.write(gson.toJson(JsonParser.parseReader(reader)));
file.flush();
} catch (IOException e) {
e.printStackTrace();
}
}```
oh wait
doesn’t look like Write is actually writing anything
gson.toJson(obj, writer)
neat
seems like I am connecting to the Purgatory server, then getting connected back to the Lobby server, I think I might need to somehow cancel the connection to the Lobby when I send the player to Purgatory
00:47:50 [INFO] [/127.0.0.1:53462] <-> InitialHandler has pinged
00:47:51 [INFO] [/127.0.0.1:53464] <-> InitialHandler has connected
00:47:51 [INFO] [Teleputer] <-> ServerConnector [purgatory] has connected
00:47:51 [INFO] [Teleputer] <-> ServerConnector [lobby] has connected
if(plugin.configuration.contains("Purgatory."+String.valueOf(player.getUniqueId()))){
player.connect(target);
}
any event that I could use that can just re-route the player before bungeecord decides to send the player to the priority server?
found it, "ServerConnectEvent" and "setTarget"
Usually you would use vault.
But if you want a fully custom solution and dont need support for other plugins then
a core economy plugin or an economy implemented in a general core plugin is the way to go.
I am currently using the player's UUID to check if they have any punishments, but is their a way for me to use their IP rather then their UUID?
yes but uuids is probably the better option
you could use them in conjuction but i wouldn't use stricty the ip
then what about alts?
. . . an alt
I was already going to
oh wait, I think I did a dumb, Im hosting the bungeecord server on my own computer, thats why its always returning the localhost ip
Is there an easier way to turn an intemstack into JSON (needed for Bungee chat's HoverEvent) than to turn it into an NMS itemstack, then creating a new CompoundTag (what used to be called NBTTagCompound), and then calling #save() on that?
How can i get mobs to spawn in a forceloaded chunk without a player?
I'm currently doing this but I wonder if there's any way to do this without NMS. COuldn't find anything in Bukkit.getUnsafe() or CraftMagicValues though :<
@Override
public String itemStackToJson(@Nonnull org.bukkit.inventory.ItemStack itemStack) {
final ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
final CompoundTag compoundTag = new CompoundTag();
nmsItemStack.save(compoundTag);
return compoundTag.getAsString();
}
Clone the craftbukkit repo from spigot's stash, and then check out the "nms-patches" folder
for example this is the patch added to "PlayerConnection" that calls the PlayerCommandPreprocessEvent
no. CraftBukkit consists of patch files that alter the original code, because obviously they cannot just redistribute mojang's code
?stash
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/net/minecraft Here are all the patch files that turn the vanilla server into CraftBukkit
Hello, does anyone know what should be done so that a boss bar always remains at the top of the screen and no other takes its place. It's for a boss bar that will indicate coordinates, temperatures, time, so it must not move, it's unpleasant. Thanks
cserver is CraftServer. That's the implementation of "Server" and is fully on stash since it doesn't contain mojang code -> https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/CraftServer.java#796
CraftServer#dispatchCommand calls the SimpleCommandMap's dispatchCommand method
one more thing:
You will find the SImpleCOmmandMap in Bukkit, NOT in CraftBukkit: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/command/SimpleCommandMap.java
How can i make a player spectate another player without being in spectator mode? I'll like to make a spectate system and the spectator mode hotbar is just ANNOYING
put the player in creative mode
and stop him from clicking anything in any inventory
and interacting
with anything
and give him invisiblity
good luck cancelling inventory click on creative mode xd
90% of Creative is client side
when the item is air I get java.lang.IllegalArgumentException: Cannot drop air and idk why
int material = random.nextInt(Material.values().length);
int amount = random.nextInt(64);
ItemStack item = new ItemStack(Material.values()[material]);
item.setAmount(amount);
event.setDropItems(false);
if (item.getType() != Material.AIR){
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
}```
any ideas?
what
how
ok
yeah ik
thx
well now i have this:
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
}```
and this error still happens
use Material.isItem()
ok
you can't. in order to fully copy the itemstack, you need to access NBT tags since Bukkit API doesnt fully expose all the item properties
afaik
?paste
i have written this a while ago, this serializes NBT tag to read friendly form of map
which can be dumped into yaml file
and still be readable to humans
I keep getting this:
Error occurred while enabling Plugin251 v1.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.soclownish.plugin251.Plugin251.getCommand(String)" is null
at me.soclownish.plugin251.Plugin251.onEnable(Plugin251.java:38) ~[plugin251-1.0.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:536) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:554) ~[paper-1.19.jar:git-Paper-28]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:468) ~[paper-1.19.jar:git-Paper-28]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:633) ~[paper-1.19.jar:git-Paper-28]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:419) ~[paper-1.19.jar:git-Paper-28]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.jar:git-Paper-28]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1121) ~[paper-1.19.jar:git-Paper-28]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-28]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
did you add your command in plugin.yml
how do I make an entity drop nothing in EntityDeathEvent?
getDrops() returns a List<ItemStack>
you could prob clear it
ok i'll try
?paste error logs please
Null at Utils.java:53
so its for the command ig
either region or ProtectedRegion are null strings
thx, the second command was in the first command
some know how make a chat align like a table ?
i found some codes on the forum but nothing works 100% and some codes use bars to align
you cannot properly do that, unless you are sure that all your players are using the same font
check out this for example https://www.spigotmc.org/threads/free-code-sending-perfectly-centered-chat-message.95872/
Font Info Enumeration: http://pastebin.com/9Be2DF2z
Method to send: http://pastebin.com/BADd6K43
Many just recommend using a...
Bukkit.registerRecipe
but using default font np
thanks
im trying to do this @EventHandler public void craftGet(CraftItemEvent event){ event.setResult(itemStack); }
but it says that i should input "Result" in there instead of ItemStack. how do I get a result?
I think you use the wrong method
Result is an Enum with three fields: ALLOW, DEFAULT, DENY
hmm
PrepareItemCraftEvent is what you want
Hey,
How do I properly send an Item Break particle? Without them flying all over the place
hi, trying out custom mobs with nms, but im not sure how to set the custom name, im using mojang mappings
setCustomName takes a String not a Component
no?
If you're using Mojang mappings you should be able to do Component.literal("Hello")
seems to work, thanks
when I use this code it works but after i click in the crafted item slot the item doesn't disapper, it just turns into another random item.
Event code:
public void craftRecipe(PrepareItemCraftEvent event){
event.getInventory().setResult(getRandom());
}```
getRandom code:``` public static ItemStack getRandom(){
ItemStack item = null;
while (item == null || !item.getType().isItem() || item.getType() == Material.BARRIER || item.getType() == Material.COMMAND_BLOCK || item.getType() == Material.COMMAND_BLOCK_MINECART || item.getType() == Material.CHAIN_COMMAND_BLOCK || item.getType() == Material.REPEATING_COMMAND_BLOCK || item.getType() == Material.STRUCTURE_BLOCK || item.getType() == Material.STRUCTURE_VOID || item.getType() == Material.BEDROCK || item.getType() == Material.LIGHT || item.getType() == Material.SPAWNER){
Random random = new Random();
int material = random.nextInt(Material.values().length);
item = new ItemStack(Material.values()[material]);
int amount = random.nextInt(1, item.getMaxStackSize()+1);
item.setAmount(amount);
}
return item;
}```
any ideas?
ohgod
There are many spawn methods. different ones give different results. Which are you using?
Well that's certainly a method
you can optimize a lot there
Currently this one:
player.spawnParticle(Particle.ITEM_CRACK, player.getEyeLocation().add(player.getEyeLocation().getDirection()), 1, itemstack);
But pretty sure PrepareItemCraftEvent fires every time the crafting bench is clicked
including the result slot
And which one would let me do that?
I want the crafted item to appear as a random item and i want the player to be given another random item which doesn't have to be the same item
but when I click on the random item it works and then the crafter slot turns to a random item
what is your value for itemstack? That field shoudl be a Class type
without me doing another recipe
The ItemStack is correct.
That's the item which is supposed to break
There is no spawnparticle method which accepts an ItemStack as the last parameter
The last parameter accepts anything
just set zero offsets
the extra value is the speed, which should affect them flying
Thank you, I'm using .05 as the last double, that seems to look fine.
But the particles still don't work correctly.
Depending on my rotation, they fly towards me or away from me, left, right ...
you could try setting the spawn Location setDirection(newVector())
i recommend calculating an array without those items and then just using one random call
I'm using LuckyPerms to create ranks which I pass into a GUI. Before you can choose the rank you must choose the player from the first GUI with the head of every player online at the server. I check if the name is right and then the GUI is specifically opened for them. It works, however when I now get the new rank example "VIP", if you go back onto the selector GUI it will say "VIP name" and therefor the plugin doesnt work anymore?
What should I do
static final List<Material> randomItems = new ArrayList<>(Material.values().length);
static {
for (Material mat : Material.values()) {
// skip non items
if (!mat.isItem())
continue;
// skip specific items
switch (mat) {
case Material.BARRIER:
case Material.COMMAND_BLOCK:
case Material.LIGHT:
continue; // skip
}
// add item
randomItems.add(mat);
}
}
Random random;
public Material getRandomItem() {
return randomItems.get(random.nextInt(randomItems.size()));
}
if(random.nextDouble() > level * 0.1) return;
// code to run enchant
does this look good to make a 10% chance for each level of the enchant to work?
Somehow I can't change the display of an item, after some debugging, I've noticed that the problem is that the rename code is in a scheduled task, but if I put that code out of the task, it works.
Any clues?
doesn't it increase the chance of returning and not calling the code below like it is rn?
probably the item reference becomes outdated
can you send your code?
Yep
no right now it reduces the chance every level
because with level 1 its > 0.1 you have 0.9 left aka 90%, but with level 3 its > 3.0 which is 7.0 left so just 70%
?paste
sorry but that tower is kind of unreadable
anyways im pretty sure it's because you are referencing to an itemstack instance that might not be valid anymore
How could I help you.
inside a task, don't use old item references but get new ones inside the task
How am I supposed to "recreate" a link or a reference between the task and the itemstack.
How do I update my localhost server version?
java -jar BuildTools.jar --remapped --rev latest doesnt update to 1.19, it just looks for updates of the current installed version
I'm using LuckyPerms to create ranks which I pass into a GUI. Before you can choose the rank you must choose the player from the first GUI with the head of every player online at the server. I check if the name is right and then the GUI is specifically opened for them. It works, however when I now get the new rank example "VIP", if you go back onto the selector GUI it will say "VIP name" and therefor the plugin doesnt work anymore?
What should I do
Stop using names and use the Players UUID
Nvm I got it
instanceof not ==
How exactly does ClickType.DOUBLE_CLICK trigger?
I mean, does it wait a moment to check that it's not two single clicks or what
is 1.19 using java 17?
16
ok thanks
it first calls a normal InventoryClickEvent with a normal leftclick, and when the second click happens fast enough, then it calls it again for the double click
yeah
100% sure
well may as well install both jdks
I don;t even have 17 installed. only 16
isnt java 16 already dead? 17 has LTS
makes sense, thanks
your ide might have installed it for u
Old age. I probably just forgot 🙂
ok i've been at this for like almost 2 days now and i'm kinda mald
so does the if statement execute BEFORE the click event actually happens??
yes
I wonder - are 50% of people here older than the average member? Probably not
its so you can cancel it
Any event that you can cancel fires before the event actually happens (is allowed)
The event gets called. Then all plugins get notified about it (that's when your code runs). Then when all plugins were notified. the server checks if the event was cancelled. And if not, it executes the stuff that this event was called for.
The event itself does NOTHING.
the event is only there to control what should be done by the server itself afterwards
getKiller is always a Player or null
its like
Event event = ...;
callEvent(event);
if (!event.isCancelled()) {
// execute code
}
ugh so how do i make it so that the if statement executes AFTER the click occurs? i'm a bit confused on the whole "cancelling" thing
why
of course it executes after the click, otherwise there would be no event you could listen to
the server cannot call a clickevent before any click occured
what do you want to do exactly?
just remove the instanceof test all together. Also compare enums with == not equals
basically i want to say "Wooden Axe is in the offhand" whenever the player in the inventory places a wooden axe in the offhand slot
the message sends whenever i take out/unequip the wooden axe which isn't what i wanted
you should check the slot type and id
The event cancell is simply a permission to see if the action is allowed. If you cancel the event the click asction was denied and whatever wwas supposed to happen from that click will not happen
then you have to check whether the cursor has an axe inside it
well i thought i did it in these lines but apparently they don't work, so what other way could i check?
check the source slot / item stack
when the event is called the click hasnt actually been processed yet so the axe is technically not in the offhand yet
meaning the offhand will return the previous item
also pressing F wont execute this i think
check if the clicked slot is the offhand slot and whether the cursor if an axe. If yes, then they are equipping the axe right now
or like the offhand switch key
i got that covered, i'm currently working on equipping/unequipping via inventory rn
ok ty for the help, i'll try the things you guys suggested
this may be a odd way of doing it, but if you check the item in the cursor slot (and it is an axe), and the item slot clicked (is the offhand slot), you can logger it
nvm u said that
i didnt read
uh would i use getSlot or getRawSlot to check for the offhand slot?
k then use
ItemStack itemClicked = event.getCurrentItem();
if (itemClicked.getType() == Material.WOOD_AXE && event.getSlot() == /* appereantly offhand slot id */ -106)
// code
getSlot() returns in the inventory
getRawSlot() returns in the inventory view (so both top and bottom inv)
ah ok
How can i fix that maven try's to find a dependency in a wrong repository? D:
idk what i'm doing wrong here but it's still sending the message whenever i take out the item from the designated slot
and i've tried setting the slot id to 0 because -106 doesn't seem to be working
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack mainhandItem = player.getInventory().getItemInMainHand();
ItemStack offhandItem = player.getInventory().getItemInOffHand();
ItemStack itemClicked = event.getCurrentItem();
if (itemClicked.getType() == Material.WOODEN_AXE && event.getSlot() == 0) {
Bukkit.getLogger().info("Wooden Axe is in the offhand");
}
}```
is it working as you want when you put the item in the slot
just not when you take it out?
no it sends whenever i take it out, rather than placing it in
i want it to work when i place the item IN the slot, not out
it always seems to work whenever i take it OUT
and it's driving me crazy
idk what the offhand slot id is
oooh wait use event.getCursor() instead of event.getCurrentItem()
aight lemme try that thx
yeah I said that like 5 times lol
not for offhan
yeah
i just messed something up so badly it fixed another issue
my brain is so confused rn
I only get this
Could not find artifact ca.bkaw:paper-nms:pom:1.19-SNAPSHOT in papermc (https://repo.papermc.io/repository/maven-public/) Could not find artifact ca.bkaw:paper-nms:pom:1.19-SNAPSHOT in papermc (https://repo.papermc.io/repository/maven-public/) two times
?paperdev
Make sure to ask in the appropriate server concerning development towards different JAR types such as PaperMC. (Tip: Google them!)
try the paper discord
They're not Supporting papernms maven xd
neither does spigot
We only support Spigot
what is "paper nms" supposed to be anyway? NMS is NMS
nms using a paper jar ig
paper-nms-maven-plugin
?otherdev still not supported here. go ask whoever made it
For questions concerning other server software, ask in the appropriate help server.
no way
that actually worked
thank you guys so much for your time i'm so happy rn omg
lessgoooo
now i just need to figure out the id for the offhand slot :poob:
log the slot number of whenever you click on a slot, then click on the offhand slot
seems like a custom chat mixed with a custom font pack
its a resource pack that changes non commonly used characters.
wait i just pulled a smooth brain how do i log that
yes you can make this by doing that
wait nvrm basic java left the chat
event.getSlot()
Hella, i have some questions about class inheritance, let say i have a Super class with some methods, but another class extend it and it have extra methods
I dont know why im nighmare with this simple thing
this isnt rlly a question
Anyone has an idea why this is not firing?
You want to do a plugin that work with custom texture pack?
if (event.getClick() == ClickType.DOUBLE_CLICK && event.getClick().isShiftClick()) {}```
Can u send full event?
Custom texture?
Dm me please
can't spoonfeed you the code but here are some tutorials
https://www.spigotmc.org/threads/texture-pack-prefix-logo-on-scoareboard-tablist-chat-etc.557111/
https://www.spigotmc.org/threads/advanced-resourcepack-mechanics-how-to-create-custom-items-blocks-guis-and-more.520187/
Hello Everyone, I just want to show to those who don't know how to add their server's logo on the Scoreboard or even an image as a prefix how to do it....
well it's an event directly set to an inventory item.. like java settingsItem.setAction(event -> {
can you explain your question in full
Oh, you are coding your menu api right?
Yeah, my bad
kinda
Is it even possible to trigger the double click when I'm reopening the inventory with single clicks?
Its easier to help
does separate dimension have a separate player's inventory or that's just a multiverse-core thing
Nevermind I just use Drop (q button), is nicer too
just an mv core thing
what if i create dimension with normal world generation
and travel there without mv core
im asking this since im manipulating player's inventories rn and I would need to give player's items back after some time
I think if you load the world in through code, then tp the player, their inv should remain the same throughout the worlds
but I havent worked with custom worlds is a while so i might not be correct
not that's just my dementia lol
apparently multiverse-inventories is a thing
and there are no separate inventories in multiverse-core
Anyone else love lamda? Looks pretty cool
claim.getMembers().stream().map(Bukkit::getOfflinePlayer).map(OfflinePlayer::getName).collect(Collectors.toList())```
at a cost of little performnace
mmm lamdas love em
Yeah, but meh i dont worry so much on performance
Because it just for a command
Ima be wrong but just discovered that mongo has an async driver for java
wait offline players store uuids if they have joined the server before correct?
😡 🤡
yes
Yeah, they saved in users.json (i think)
usercache.json
yeah that
i think bukkit.offlineusers is since the server has restarted
there's bazillion of devs who don't know that and save it too
Dovidas, do you know any tuto about annotations and construtos with anno? like:
boolean execute(Command command, AnnotClass argument);
So them i can do argument.name(), etc
I would love to learn annotation processing too
but I always skip them for some reason
Oh the same happen to me, im wondering learn annot proccessing and i dont do it because either dont have time nor forget it
I'm unable to modify a Spigot message via BungeeCord on 1.19. I made 2 test plugins to add "Test" to the start of my message and broadcast it on both servers, and this is what happens
Here's a thread with more info: https://www.spigotmc.org/threads/1-19-chatevent-setmessage-doesnt-affect-message-on-spigot.560995/
Does anyone know if that's intentional or not?
Maybe the format?
How are you sending/receiving the messages? PMC (Plugin Message channel), Redis? Just for being curious
Guys one dumb question, but is this a proper sentence?
"Edit the height from which anvils are dropped when /anvil [player] is used"
It's just chat messages
For me its pretty understable
Allright, can u send full code of the event here
Also Bungee's ChatEvent doesn't have a method for changing the format, that's only on Spigot
I'm so insecure about my english sometimes xD
Bungee
public class BungeeChatTest extends Plugin implements Listener {
@Override
public void onEnable() {
getProxy().getPluginManager().registerListener(this, this);
}
@EventHandler
public void onChat(ChatEvent event) {
event.setMessage("Test " + event.getMessage());
getProxy().broadcast(TextComponent.fromLegacyText("Bungee: " + event.getMessage()));
}
}
Spigot
public class BungeeChatTest2 extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
Bukkit.broadcastMessage("Spigot: " + event.getMessage());
}
}
This worked as intended on 1.18.2 and below
Oh, are u spanish?
Changes in 1.19
Where is the issue, on Bungeecord or Spigot?
50% 🇩🇪 & 50% 🇮🇹
only that first thing is adding "Test"
Spigot, because it doesn't recognize the change
Oh nice, im Uruguayan
Oh nice, it's morning in uruguay right now?
However, if I cancel the ChatEvent on bungee, it cancels it on Spigot
Around launch, its 12:30 pm
Nice, I'm living in the future xD It's 5:30 pm here
Yeah, they check if player has moved or not in a specific amount of time
There is an event called PlayerMoveEvent, and you record down intervals between when that event was last fired, if the interval is too long, you assume they are afk
the server keeps track of that?
well your plugin needs to
6:33 PM
Central Europe
or Northern Europe
for you
middle earth
its 1:34am for me
climate change wouldnt affect your climate i guess
correct (╯°□°)╯︵ ┻━┻
Hey all, I'm working on a fix to a dead mod, emojichat, from this change in 1.19: https://bugs.mojang.com/browse/MC-251764
I had tried the suggestion of replacing \u0020 characters with \u0000, but it looks like it just changes it to another character, [sp].
I'm not super familiar with all of the ins and outs of the Minecraft Unicode stuff, I had previously added some custom emotes for a small server which just took editing the resource pack itself.
I wasn't sure if anyone had come across this character before and could point me in the right direction, I'm sure I'm just doing something dumb.
and does anyone know where i can find for the other versions?
I'd recommend checking for walking + head movement separately and check if both have changed. That way getting pushed by water doesn't consider them active
im not sure if a playermove event is fired whenever the player moves it head, would makes sense as the yaw or pitch changes but you could check that out
also ^^
or you could be fancy/over the top and check to see when they last sent a move packet instead
Yeah it gets fired, but you can check which part changed
world.getPlayers().stream().filter(Object::equals).forEach(CraftPlayer::sendPacket); you can simply it
wouldnt be too difficult
k
Is yaw/pitch excluded from that?
performance will go bro if you scale that or if there are a lot of players
Because I was thinking PlayerMoveEvent already listens to those packets
why are people calling a Player object 'all' in their foreach lambda anyways?
But it caused because of the Stream , not because of lamda
makes sense
But on newer versions, they are more optimized
streams are still slow fuckers in most cases
Allr
and enhanced for loops can look fancy too 😏
Agree ith u
I dont like shity foreach without lamda
''.getOnlinePlayers'', maybe it all players ?
i only use a forEach if i can use a method reference in it
what the issue?
i mean getOnlinePlayers().forEach(all -> {}), all is still an individual player variable
¯_(ツ)_/¯
ok
people being weird i guess lol
what byte i use to make player dont pull the bow more..?
well seeing that it is the same event i would say they are sent together but it would make sense if not
They are not weird than me
i made the player pull up the bow for the players but now i want to reset that
?protocol
is there a way in 1.19 to change the direction a player is facing without having to teleport them?
Wouldnt hep changing his yaw and pitch location?
that doesnt reflect on the player iirc
do you mean change the player camera position?
If he want to change the player camera, change his pitch and yaw
i used to do that on older versions
if you do it while they are moving wont it make them rubber band a bit
i remember a old donny bobes video where he had a plugin that moved their pitch/yaw
so there definitely is a way to do it
are you sure it wasnt scripted?
Any alternative, for getting an OfflinePlayer by his name? Because looks deprecated
fetch uuid and get by that
no there shouldn't really be a reason your using their name
predict the next position using vector logic so it negates the rubberbanding
On a command?
if you only have a name theres no other way
correct
?tryandsee
?tryandsee
I'm guessing no one has seen this, which is fair enough, but I have an actual picture of it now that I can attach xD
idk
yeah
You are telling, entity.horse
Agree
To make a entity follow a player i need to?
with paper, getPathfinder.moveTo
maybe you need to use nms idk
pathfinder goals
without paper, nms
that wouldnt have a walking animation though
but teleport require lot of resources
if you make it a marker it wont be sent to the client i think
and thats done async anyways
updating the position isnt intensive
Its cuz of tracking the player movements
You can imagine what yeath im try to reply
top is paper, bottom is nms
Allright thanks!!
Its for a trying of an ac that why
we love the letter methods
Also is extrange that hipixels ac have some bugs
At some time you can see the entity on tab or screen
weirdest thing ive seen today
check if they have played before smh
maybe chec kif you can make args[0] a uuid
and otherwise take in as a player name
He?
then you can do both Orbyfied and e32e2-23dniu-blablabla
is there a way in 1.19 to change the direction a player is facing without having to teleport them?
would be pretty nice to use
pretty sure you have to use teleport
that updates the views of other players automatically too
unless you wanna use packets
example im dumb today
regex or checking the length and trying to parse it and catching exceptions
any one got good resources on using nms im completly new to nms ?
haha
@sterile token
String plrArg = args[0];
UUID uuid = null;
try {
uuid = UUID.fromString(plrArg);
} catch (/* not a (valid) uuid */ IllegalArgumentException ignored) { }
Player player;
if (uuid != null)
player = Bukkit.getOfflinePlayer(uuid /* use uuid */);
else
player = Bukkit.getOfflinePlayer(plrArg /* use name */);
its a bit stupid and messy
but yeah
that should work
wouldnt regex be faster than throwing an exception?
bruh no def not
hm idk
exceptions slow too
Hi dose anyone know how to set a players nametag colour onPlayerJoin?
OHH ok thanks
Hi guys how i can take status of server from bungeecord, i've tried with ProxiedPlayer but i don't like this method
Its possible have something like ProxyServer.getInstance().getServerInfo("dev").getPing()
use brackets lmao
?paste
...
oh no this.plugin.getApi().getMessage().send
What?
every time
kinda
bruh you gotta be kiddin me, one line
this.plugin.getApi().getMessage().send(player, "Claim.Info", "{prefix}", this.plugin.getConfig().getString("General.Prefix"), "{owner}", Bukkit.getOfflinePlayer(claim.getOwner()).getName(), "{home}", claim.getHome(), "{flags}", claim.getFlags(), "{members}", claim.getMembers().stream().map(Bukkit::getOfflinePlayer).map(OfflinePlayer::getName).collect(Collectors.toList()));```
looks like i cannot live with you 💀
Not only you
what is this 💀
my eyes
claim.getMembers().stream().map(Bukkit::getOfflinePlayer).map(OfflinePlayer::getName).collect(Collectors.toList()));
this the novel of my one line code
tf
have you uploaded your claim plugin to gh yet?
No
What do you need to see
i can send it
all :kekw:
Lol, why edge, open nodejs service?
Why? Do you want to make me fun of my code :sad:
wanna see it lol
just use regex
So I'm testing a new plugin and am getting this error code:
Could not load 'plugins\LifeShareTeams-0.1.jar' in folder 'plugins': uses the space-character (0x20) in its name
Does anyone know what this means?
Thats a 9 year old question. Exception raising has greatly improved since then
exceptions aren't an anti pattern
what the hell are you on
lmao
i dont really care if its an anti pattern as long as its performant
you shouldnt use it everywhere
throwing exceptions purely makes sense for some things
but i expect regex to be quite a bit slower
Nevermind, found the bug
As in your code your exception is not actually controlling the flow its not an anti-pattern. your exception is simply ignored.
lmao y'all really trying to cause as much overhead as possible
but still cannot understand them
me?
not me lol
write simple code
its simply lmao :fun:
switch-case
catching exceptions to check if an UUID is valid instead of using a regex it's not good practice
yeah but don't stick a stream between every line of code just because it makes complicated actions in 1 line
just write a for loop
Na, my devmatter understand perfectly my streams and backwards
you say "don't bullshit me" and then say shit like that
you do you man
ok im stupid ofc regex is slower because you need to parse it afterwards too
but just for checking regex is actually faster i think
trycatch is not that fast
with an avg 174ns / pass
what is slower
jumps instead of checks every condition
Oh allright, so switch is better
if you just want to check, regex but if you need to parse it might aswell use try catch
and i doubt youll ever only need to check
mye as it will check it twice
yeah
Altoguht i cannot do a switch
havent even looked at UUID#fromString lmao
so fromString is preferable imo
?
4 nibbles
ok looks pain
still faster than regex
java vers?
true
I dont understan d that characters
but regex only checks
corretto 16
so its actually kinda uncomparable
so it's the new java9+ method
yea
because to get the uuid you need fromString anyways lol
bitmasking
you defo shoult try to avoid java 8 with UUID#fromString
the newer method is quite a bit faster
java8 does string checks iirc
ho uses java 8 tho?
this is java8
you would be suprised
wait bruh
my regex pattern is broken
lol
that might be why
it validated this
lmaoo
Yeah here the 50% shoudl be using Java 8
Hey guys its possible ping a server with bungee for take the status of the server? Without ProxiedPlayer?
you gotta add dashes
you can just do linux stuff for that
no need for bungee even
just try to open a socket or something
I want create a plugin for take the status of all servers
personally i would do this with redis pub/sub
Its possible to send data encoded from proxy-spigot and backwards doing pings?
ehhh
I have read that on forum spigot one
ok most performant way to do this (cpu time, idk about memory) is
if (uuidPattern.matcher(str).matches()) {
// account for parsing done in fromString
UUID.fromString(str);
}
+- UUID_RegexDontParse: 1000000 Passes (MAX) | Total Time: 185964899ns (185ms) | Avg. time/pass: 185ns (0ms)
+- UUID_RegexDoParse: 1000000 Passes (MAX) | Total Time: 132492801ns (132ms) | Avg. time/pass: 132ns (0ms)
+- UUID_Exception: 232006 Passes | Total Time: 1000126999ns (1000ms) | Avg. time/pass: 4310ns (0ms)
this is just proof that trycatch is a slow method
Other alternative if you dont have a vps?
benchmartk code
its pretty generally known you should never catch an exception that you can avoid.
make an internal server protocol that communicates data
now i bet with random lengths too fromString is faster tho
because it will stop immediately
so idk
interesting how parsing is faster than not parsing 🤔
i have concluded that java has a pretty fast vm
lol wtf
I hear the word "packets" being tossed around quite a lot. I'd like to learn more. My current objective is being able to manipulate a client's packets to force their camera location, but I would love to get a better understanding of packets in general. It seems packets can be used to make a truly unique experience.
PAtience
Packets are a set of data, which are transmited (sended/receive) between a server and a client
Is there a better way of doing something like
public Object getValue() {
Object o = plugin.getConfig().get(getPathToSetting());
if (o != null) {
if (o.getClass() == Boolean.class) {
return plugin.getConfig().getBoolean(getPathToSetting());
}
else if(o.getClass() == Double.class) {
return plugin.getConfig().getDouble(getPathToSetting());
}
else if(o.getClass() == Integer.class) {
return plugin.getConfig().getInt(getPathToSetting());
}
}
return plugin.getConfig().get(getPathToSetting());
}```
why doesn't spigot have packet events?
Just use get directly like you did on the 2nd line?
maybe is not an int
java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
yeah idk why it says it's a double
if number have a "," or "." its a double
So: 10.2 == double
This won't help with your error
It changes nothing
“,”?
Lmao, why the heck copilot every 2-4d has a new update?
ah
Yeah, we denote decimals with the "," because "." for us means thousans
same here. 1.000.000,00 is a million
yeah
1.000.000__,00__m
the underline is the decimal part
idea?
Because they change stuff?
Yeah, but why the shit doesnt auto update?
Im thinking for creating an intellij plugin, for auto update for intellij plugins
If you want to hide a player, but don't want to remove them from tab, why don't you just use invisibility?
You can still see the nametag while invisible? That's definitely a plugin doing this
Or a client. Invisibility hides the nametag. Unless you are on the same team using scoreboards, the player will be invisible.
there is player.hidePlayer(<plugin instance>, <player you want to hide>);
o wait
u want them on tab
That removes them from the tab list. Which isn’t what they were wanting.
hideEntity
well you could simulate the player on tab
Or use that.
my 20GB free is sobbing
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#hideEntity(org.bukkit.plugin.Plugin,org.bukkit.entity.Entity) is still draft api but will work fine. I am like 99.99% sure that it's the same as hidePlayer, but works for every entity, and will NOT hide the name from tab
declaration: package: org.bukkit.entity, interface: Player
@tender shard i just change the 1.18.2 to 1.19 in pom.xml to update it?
to update what?
You need to run build tools as well.
like this
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
to
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
I just found out about ChatPaginator.wordWrap and holy shit is this useful
thanks, also never heard of this
It is, but it’s annoying because it only accepts a String[] instead of a List<String>.
It’s not hard to convert, but it would be nice if it just had more overloaded methods.
unfortunately I have absolutely no need to ever use it lmao
just use put
Do you have your own methods in your library? :D
no, I just never needed to know at what place a line would break
I'm using it on lores of item metas so they don't get too long and out of the visible window / just make them look cleaner
It also doesn’t let you access or change the default width values.
for lore? I thought it was only for chat messages?
noo
It returns a string array. So use it wherever you need it.
Whether that be chat or item meta.
metaLore.addAll(Arrays.asList(ChatPaginator.wordWrap(lore, maxLoreLength)));
That gives me a nice lore that only has lines at a max length of maxLoreLength
if one line would be longer the word is just put in the next line
I wonder why it's called "ChatPaginor" then lol
ikr
I would have thought it breaks it so that you know how the client would add line breaks when using the default font
in chat
oh
yeah misleading name it has
but now that I found out I think I'm gonna use it on lores regularly
Before that I made custom breaks in the lines
PlayerDeathEvent
hi, what is the max. amount for ItemStack class?
i am looping through the player inventory and i was expecting to have another itemstack instance for every 64x of the item
but i think its not how it works
I think some items can only be stack up to 16
and of course some can't be at all
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
the problem is, some of them are probably too much, like more than 64
white wool for example
is it possible?
Stack size is hard coded in teh Material data
There's a way to get to 127 but that doesn't work properly
you can alter it using reflection, but its not easy
mfnalex has a plugin that allows you to alter teh stacksize (premium)
code is on GitHub
Yes but I also limited it to a max of 64, because the vanilla client has 64 as limit hardcoded. Even if you set the stack size of e.g. COBBLESTONE to 128, the client wouldnt let you stack 2x64 cobble stacks. One would have to do all this manually.
To change the stack sizes, the following things are required (will reply again in a minute):
get the "maxStack" field of the bukkit Material class. It's a private final int. Change it to the value you want.
Then get the appropriate NMS Material. You can get it through CraftMagicNumbers, it's a net.minecraft.world.item.Item. It has a private static final int called "MAX_STACK_SIZE" in mojang mappings, "c" in obfuscated 1.17-1.19. Simply also change this
in 1.16 and below, or in "spigot mappings", it's called "maxStackSize"
and then you have to deal with a shit ton of bugs that this results in, mostly for items that can be "used" with right-click and that normally cannot be stacked. For example using a stack of 64 water buckets will result in only one empty bucket. For potions however, it works fine. This is all pretty random
So the answer is, yes you can, but you will regret it.
Hello, I need help with a math problem. This isn't in spigot but it is in minecraft, I was wondering if it'd be appropriate to post here?
sure
?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!
The answer is probably, somehow, twelve
yes.
probably
very likely
answer is x = amogus(y)
error undefined variable y
i love how there are like at least 6 people patiently waiting for him to finish typing
yes
amogus takes a y value and maps it to the x value i nthe amogus
I am trying to rotate a group of points (armorstands) around the structure's center of mass. Rotating the positions themselves is easy enough (I am simply getting the offset in position from the center of mass for each point and then rotating that as a vector on each axis by the desired amount)
To rotate the armorstand's head, it takes in two different types of parameters:
A) A vector (The top of the armorstand's head will face that way, not the front, but this should not matter with this context)
B) Three numbers (X-Axis, Y-Axis, Z-Axis, these numbers are degrees)
As said, I am simply getting the difference in location from each point to the center (Point - Center).
This is not giving me a vector representing the structure's overall orientation, it is giving me a vector pointing away from the center towards the new location of the point, so I can't just input that for the rotation.
do you have the overall orientation accessible somehow
or is this with command blocks or smth
there is no location/entity representing the overall orientation
it's variables
although not spigot
might be confusing
because applying that should give the desired result right
yes the task is to construct the view vector
basically, degrees to rotate the offset vector for each point on all 3 axes
ok
well might be for command blocks but this isn't that
what is it?
a custom coding language designed to run on a server
ah
it's not even text based, it's inside the game basically
p.addPotionEffect(PotionEffect.slowness(10, 2));
Is this how you would add a potion affect?
these are available yes
make a new instance of PotionEffect with new PotionEffect(PotionEffectType, duration, amplifier)
not sure if duration goes first
ah okay thanks
might be amplifier before duration I don't remember
its duration first, then amplifier
k
These are available but I don't know how to apply them here
Math is not exactly my strong point I'll be honest lol
just had sin and cos and shit
lmai
lmao
oh wait
i think i might know
its weird
cuz you need 2 axis on the look vector per angle
i think
Vector lookvec = new Vector();
float yaw = ...;
float pitch = ...;
float idk = ...;
/* yaw */ lookvec.add(/* x */ Math.cos(yaw), /* y */ 0, /* z */ Math.sin(yaw));
/* pitch */ lookvec.add(/* x */ 0, /* y */ Math.cos(pitch), /* z */ Math.sin(pitch));
/* the other one */ lookvec.add(/* x */ Math.cos(idk), /* y */ Math.sin(idk), /* z */ 0);
``` @wind tulip idk lol
maybe this
thats in java tho
so idk how your thing works
yes
wait no I meant Y
idk = Y
Does anyone have an example on how I can give a player a pre rendered map with an image on it?
well yaw would rotate around Y
yeah
if it works ill be shocked
lol
lol yup
a lot of funky rotation issues would be fixed if they didn't automatically flip the yaw once you try to look upside down
wait what
Thats called gimbal lock
To avoid you prevent flipping, or you rotate using quarternions
waht the fuck
thats som e weird rotation
wait but they do look like they are rotation correclty
wtf
h no
nvm
some axis do
hm
k
f3 doesn't show you that for armorstands actually
but I can display it using particle lines
gimme 1s
nah like show which axis everything is
you seem to be double rotating. you are rotating them all about an origin, but you are also rotating them about their own axis
yeah thats to make it look seamless
well yeah that's how armorstand poses work
wdym
I don't have the direction that the whole structure is facing
yes, but when you are rotating them about their axis you are doing it in reverse
if I did I could just input that
like
what do you mean? Multiply the vector by -1?
the workd axix
I assume you are trying to rotate them all as one big cube
no
ok so
what I'm doing is rotating a group of points (armorstands) around another point
they are rotating properly but then I need to rotate their heads too so that it's smooth
the problem is, I don't know, in the code, which direction they should face (as a vector)
but are they supposed to remain in formation, as if its a BIG cube rotating?
yes
then yes, your individual rotation is wrong, you are doing that in reverse
doing what in reverse
the rotation of each block
look at your video, they are holding teh correct position in the formation, but they rotate in the reverse of the way they should
ah I see what you mean
can you even set the look vector on armor stands
i cant do it with spigot api
only euler angle
yeah ik but thats interesting
somehow
wait so what was the issue?
oh wait
no i d=still dont know
oh yeah wait in minecraft source code they invert the y component
and they also multiply, not add
Hi, is there a way for me to get all minecraft commands on plugin loading?
It seems like the "knownCommands" don't contain them when my plugin is loaded, at that time it only contains the servers commands (bukkit, spigot, and depending on if its paper or not also the paper commands)
You could just wait a tick. Of course the server cannot know what commands a plugin will register that gets enabled after yours
I don't want other plugins commands, some of them are even in the list, most likely due to being enabled before mine.
I want the normal minecraft commands (i.e. /tell (/w /msg), or /minecraft:tell)
How do I avoid Raw use of parameterized class 'Class'
public Class getInstanceOf() {
return switch (getSettingType()) {
case BOOLEAN -> Boolean.class;
case DOUBLE -> Double.class;
case INTEGER -> Integer.class;
};
}```
Use Class<?>
How would I use this + get the UUID cause when I use rank plugin it changes the displayname of the player so the GUI wont work
target = player.getServer().getPlayerExact(ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()));
thanks
do not use player names to identify (they are only to display). Store teh players UUID and use that
yeah, you could put the players uuid on the items pdc, and then get that when needed
pdc?
persistent data container
ah I misunderstood. Anyway, you'll have to wait a tick, then it'll also include all the vanilla commands
If this is for your admin menu just use FIxedMetadataValue in the heads Meta
could you give me an example of that would look like?
but also yea, you dont really need to use pdc for this, metadata would probably work
head.setMetadata("player", new FixedMetadataValue(plugin, player.getUniqueId().toString()));```
is it fine with 1 tick though?
What I'm trying to do is loading/unloading modules dynamically and if I replace a minecraft command, re-register it when the module gets unloaded.
This far it works, but I've only tried it when the module was loaded while the server was already on, the moment i restarted the server with the module turned on, and i turned the module off, the minecraft commands didn't come back, already debugged so this is why i was asking about this.
I'm afraid that if I delay the loading of the modules by a tick that it could end up in weird behaviour .-.
yes, one tick is enough
You don;t need to toString, just store teh UUID
Not gonna mess anything up either?
it should work fine
alright ty
incoming "Damageable" question
To read the UUID back```java
if (!head.hasMetadata("player")) return;
UUID id= UUID.fromString(head.getMetadata("player").get(0).asString());```
What would i do before that? private FixedMetaDataValue metaDataValue;
you could also just store the uuid
without the tostring stuff
yep
you put the metadata on the head at teh same time as you are creating it and setting its owner in the Meta
Seems to work fine, gonna monitor it for a bit and see if it's causing any issues but tyvm
np! IT's a bit weird that the vanilla commands get registered after the bukkit ones etc
should be other way around imho lol
but yeah that's the way it is
yea true, delaying the loading by a tick was pretty much my first idea, but I was just wondering if theres a cleaner solution since delaying on init doesn't seem like the best thing to me
there is no other way
this is from CraftServer
it first loads all plugins and enables them, then after they are all enabled, it adds the vanilla commands to the map
I highly assume it sets the plugin commands beforehand so they override the minecraft commands
?paste
actually, you are using heads, you don;t need to set anything. Just use getOwner
youll want to make sure the player is online though
could you maybe come online on my test server and see what im talking about?
They will be, he creates teh skulls from online players
I guess they could have logged off in the ser seconds between
yes but it checks it later in an event, which by then they might have logged out
yep
not really sure why thats necessary
so he understands my problem and maybe could help further
the problem being?
getOwnign Player should be fine as it returns an OfflinePlayer
I HAVE IT IN MY CODE
but it doesnt work which clearly means u dont know what im saying the problem is
dont see how seeing it on the server would change that...
i do not see how seeing this inventory would change your problem