#help-archived
1 messages · Page 223 of 1
pls nitpick me smile x}
not primitives unless you got something like FastUtils, Trove or GoldmanSachs
@marsh hawk I'm not sure if sparkjava is just for REST apis, but otherwise... 🤷♂️
yeah
@marsh hawk Do you just want to listen on a port for http requests?
yeah precisely
Then you can just use a ServerSocket. Let me write you an example
So this is basicall a really simple web server that listens on a port for a server shutdown:
public class WebManager {
private static final int PORT = 11017;
public WebManager(final JavaPlugin plugin) {
this.plugin = plugin;
CompletableFuture.runAsync(this::listenForRestart);
}
private final JavaPlugin plugin;
private final String responseOk = "HTTP/1.1 204 OK\r\n\r\n";
private final String responseDeny = "HTTP/1.1 403 Access denied\r\n\r\n";
private void listenForRestart() {
try {
final ServerSocket serverSocket = new ServerSocket(PORT);
while (true) {
final Socket socket = serverSocket.accept();
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
final OutputStream outputStream = socket.getOutputStream();
final String line = bufferedReader.readLine();
final String[] args = line.split(" ");
if (serverSocket.getInetAddress().getHostAddress().equals("127.0.0.1") && args[0].equals("POST")) {
System.out.println("§aHTTP shutdown initialised.");
Bukkit.getScheduler().runTask(this.plugin, Bukkit::shutdown);
outputStream.write(this.responseOk.getBytes(StandardCharsets.UTF_8));
break;
}
socket.getOutputStream().write(this.responseDeny.getBytes(StandardCharsets.UTF_8));
socket.close();
}
} catch (final IOException e) {
e.printStackTrace();
}
}
}
And only one IP can use a POST request for this. (Its not really safe as someone could tinker the IP)
I mean this very boilerplaty and there are frameworks that can do more but for simple requests this is pretty fine.
ill give it a try thankyou 🙂
Btw if you want to respon with json then a HttpServlet would probably be the better approach
okay so I have an API, but I want to be able to use it with other projects and potentially let other people use it as well how would I go about setting it up so other people can use it? I've only ever done this when it was in the same project folder. (Using Maven)
So for maven you would need to host your own maven repository.
When you use maven dependencies you will often not only get the <dependency> but also the <repository>
Im using the Sonatype Nexus Repository Manager for example
You can upload the project to github and use JitPack to grab it as a repo
Or you can use JitPack...
But i think a nice setup with Jenkins and a dedicated maven repo is also desirable
Hey so fun story about me trying to save resource folders
<repository> <id>sonatype</id> <url>https://oss.sonatype.org/content/groups/public/</url> </repository>
is that what this is
push to github -> webhook to jenkins -> upload to maven repo
it works just with a simple saveResource(folder name)
i just didnt include the folders in the jar yet
:)
so is there a tutorial on how I can learn to webhook with jenkins and upload to a maven repo?
I've never done it before
You dont need that... it took me a bit to set that up. But there are some tutorials out there.
I'll take a look now thanks
when is ItemMeta null?
like is it possible to have a null ItemMeta while having a valid ItemStack?
IIRC, it will be null vanilla-based.
I.e if you craft an item, find one in a shaft etc.
okay, thank you.
ItemMeta can be null if the item is AIR
Yes
Not vanilla items.
They don't.
They do
Oh lord.
Just tell which one doesn't then. Solved 😂
They do everything but AIR has item meta with getItemMeta()
That has always been a thing
ItemMeta is literally the bukkit implementation of the nbttag
And everything but air has nbt data
I even remember choco mentioning that vanilla doesn't.
Anyhow, you're making me insecure about my respond now, I'll have to check again.
Okay, so after a quick look all items with an nbttag has itemmeta
Those without don't
So some vanilla have some don't
Soo.. Uh... What's the necessity of a null check on getItemMeta?
It probably won't generate for air
Well, yeah.. But for actual items, I mean.
So everything.
watf
how do i implement the physics of a car plugin
So ehm ,i was partly correct
What is maximum player's setExp()?
@alpine yoke probably the max 32 bit or 64 bit interger
I am curious about this so I actually gotta check, Jan.
Ikr, i just want to make a countdown so the LEVEL goes down and the bar goes down too
yo
If you're fetching it from a vanilla source, it most likely will not have meta
would Math.floor(3/2) return 1?
^ @bold anchor That's from choco.
I'm going to, give me a second.
Maximum experience value can be gained by /experience command is 2147483647 which is (231 - 1). This is likely due to experience being stored as a signed Java-standard 32-bit integer.
Maximum level of XP players can get legitimately is 21863,[more information needed] but they can get up to 2147483647 using commands, in this case, the experience bar may disappear and reappear.[3]
-gamepedia
setXp is only for the fullness of the bar
yes, I do have the level countdown done
every 20 ticks it sets level to countdown int
and once game starts it puts the level to 0
but I wanna make the XP though
1f is full 0f is empty
does annyone know a good crate plugin thats not too hard to config, and can let me use heads from Headsdatabase as a head?
i need one that can use hdb
custom ;)
there has to be one that can use hdb
@bold anchor It seems you're right actually..
So, technically a null check for itemmeta is unnecessary in terms of events?
So just check the type. 🤷♂️
There is 3 types of air
:p
Oh wait there is mat.isAir
private void startsrv() {
try {
Thread.currentThread().setName("OAuth2 MC Thread");
final ServerSocket serverSocket = new ServerSocket(port);
System.out.println("server started");
while (true) {
final Socket socket = serverSocket.accept();
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
final OutputStream outputStream = socket.getOutputStream();
final String line = bufferedReader.readLine();
final String[] args = line.split(" ");
System.out.println("recieved");
if (args[0].equals("POST")) {
System.out.println(args[1]);
break;
}
socket.getOutputStream().write(this.responseDeny.getBytes(StandardCharsets.UTF_8));
socket.close();
}
} catch (final IOException e) {
e.printStackTrace();
}
}
``` any clue why this isnt responding? If i send a post request it just loads forever
You need to send a 200 something response
socket.getOutputStream().write(some 200 response)
oh right im dumb lol
weird im not even getting the "recieved" string in console though
Are you using http requests?
yeah
I think there's an API for them
ill check that out
Although in my opinion JavaScript is much better for this kind of stuff
Rip
i tried spark just before but its way too many jars i need to shade
its very enticing though
anyone know why intelliJ builds such large jar files for such a small amount of code ?
and how can i tweak this so i don't have massive plugin files
i know why - because i decided to also build spigot.jar 😄
My plugin has spigot so it can run without spigot
oh no
Hello! This does not work, it not store. Any help to store custom data in an item?
ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null) {
PersistentDataContainer persistentDataContainer = itemStack.getItemMeta().getPersistentDataContainer();
NamespacedKey namespacedKey = new NamespacedKey(this.plugin, "key");
persistentDataContainer.set(namespacedKey, PersistentDataType.STRING, "value");
}
itemStack.setItemMeta(itemMeta);```
@marsh hawk You can use Rhino to load javascript in java. https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino
seems like alotta overhead
Probably but it's up to you
HttpServlets are aids holy shit
Java Is generally a bad language when it comes to http request
yeah definitely
It also isn't ideal for web development
yeah definitely
interesting
they use HttpServlets
I will need something similar for my plugin as well
If you find something good tell me
or create an easier to use API for the rest of us :)
Yeah it got transfered to the eclipse foundation
hm
some very efficient coding here
if (permissions == null)
permissions = bPermPermissions.create(getServer(), "dynmap", perdefs);
if (permissions == null)
permissions = PermBukkitPermissions.create(getServer(), "dynmap", perdefs);
if (permissions == null)
permissions = NijikokunPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = GroupManagerPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = LuckPermsPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = LuckPerms5Permissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = VaultPermissions.create(this, "dynmap");
if (permissions == null)
permissions = BukkitPermissions.create("dynmap", perdefs);
if (permissions == null)
permissions = new OpPermissions(new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue", "pause", "ips-for-id", "ids-for-ip", "add-id-for-ip", "del-id-for-ip" });
wtf is that.
...
its in dynmap lmao
lol
I meant it's just to check if the previous permission integraton failed but still
could be some easier way to do it lol
wth
Yeah there are better ways
I have no clue how they create the HttpServlet
yeah probably java's weakest point
thats why all my http services are in other langs
i literally use redis to communicate to those non-java services to do http reqs
Any help on storing custom data in an item please?
its easier lmao
Have you read this: https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/ @lofty meadow
cant have duplicates in hashset
hashmap
ok
well
https://github.com/webbukkit/dynmap/search?q=MainServlet&unscoped_q=MainServlet
I'm so confused wtf. they have no reference to MainServlet
so how does it get instantiated?
a hashset is a list that aims to reduce duplicates. for instance a HashSet<Integer> cant have two 1's in it.
Yeah he's been asking us to spoon feed him code all day
hi gays
hi gay
uh oh
I've done something to crash my server ;-;
I triggered an event and it's just frozen xD
You probably did a loop too large
ah
or maybe an infinite one
hmm well there is one loop
That feels like way too many
what are you trying to achieve with the function
It will probably not crash but it's deffiently not efficient
it can probably be cut down
right, so I have a crate object
^
it stores a bunch of ItemStacks
I have a list of Inventories
I want to display all of the items across multiple pages
the list of Inventories is to store each page
this function is for removing an ItemStack
i have a paged inventory class if you want
but you are doing a double for loop
and each iteration is 2 new inventory variables
thats alot
the firsst loop is to itterate through all the pages
and each iteration is 2 new inventory variables
@marsh hawk but they should get deleted after the loop?
by java clean up
you shouldn't rely on gc
the second loop it to itterate through each item
you shouldn't rely on gc
@marsh hawk gc?
Garbage Cleaner
this is moving all the items along
garbage collector
oh
excuse my messy code this was a while ago
i'll see if I can take 'inspiration'
literally all i do is store all items in an array
and calculate amount of pages needed
ok but how do you handle an item being removed?
you need to shunt all the items along
that's what I'm trying to do
refresh inv?
re-open it
but when do you fill the hole which was left?
or do you you just put all the items back in from slot one, using the updated list
yeah just 're-render' the inventory
oh ok
it's better to iterate through say 100 items in an array of itemsw
than to iterate over 10 inventories 56 times
and when you're opening the inventory you're not even using the map
mk
yeah why have the Inventory inv variable
if its stored in a map anyway
p.sendMessage("bruh bruh 69 " + event.getRawSlot());```
now this is programming
Yeah
lol
this is a menu right
and doesn't need to persist each time you open?
so say for example i put a dirt block in it
next time i open it will the dirt block be in it
or will it be fresh each time
Because imo, if it's just a menu i wouldn't store it anywhere
so i need to store it
?
didnt come out good lol
but for example with my menus i just pull data from elsewhere and create a new inv each time
just saves mem
gc will pick it up
what's up
what
What
database connection
Yeah what's up with it
What exactly is the problem
Spigot has MySQL drivers shaded
do you have a link please?
For what
"Spigot has MySQL drivers shaded" about this
There's no link about it, they're just inside the server jar
that's a good idea thanks
Actually that tutorial is really bad, I think it should be completely removed from Spigot or rewritten because it confuses beginners
@sturdy oar is this possible
what i am thinking is making a login here on this database connection and put as plugin in spiggot?
Yes?
ow i see
You know you have to encrypt the passwords with salt and hashing right
thanks for the tip 🙂
Just look at AuthMe code they're doing this
Can somebody help me a need a small plugin but i don't know how to find it
@sturdy oar yup my frnd recommend that plugin is this already making a datbase?
I don't understand
AuthMe is a plugin right?
me in my position what i want is to make a database to handle data. do auth me has a physical database like mysql?
I have diferent area's (arena's) and i would like to have sign teleport but that i can set a maximum of players in the area so if i set the max to 2 players 2 player can join but a third wouldnt tp if they click the sign, does anybody know a plugin for this or anything?
Yes AuthMe can use MySQL and saves all the data in encrypted format
You can specify the algorithm
Default is SHA256
I think
great! i will take a look the algorithm
This not work for me, please help!
ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null) {
NamespacedKey namespacedKey = new NamespacedKey(pluginInstance, "mykey");
itemStack.getItemMeta().getPersistentDataContainer().set(namespacedKey, PersistentDataType.STRING, "myvalue");
}
itemStack.setItemMeta(itemMeta);```
Ohh, what?
Could anyone update Spigot to Combat Test 6 as a test version?
why does my dependency not show up when i have imported it?
you should build your project
Hey, so im opening a new server, and I wanna use Spigot's plugins.
so I downloaded them into a folder called "Plugins" but nothing happened.
there is no folder with .conf file after restart at the "config" Folder.
Im sure I missed something..
.conf? You sure? You using Sponge?
yes, but I saw that Sponge is ok with Spigot, only with Bukkit it is a problem.
all of them cannot be together with sponge?
Sponge can run with Forge
wasn't that the whole point of sponge?
There was an attempt to make Spigot plugins compatible with sponge once but it got discontinnued
Sponge got a really nice API
i have no idea how to use sponge's api
I've never tried using it
very very different than what bukkit has
lot of builders
at first glance it's not easy to get into
Hey. is there a way to send player title with 5 ticks fade in, 40 ticks stay and 10 ticks fade out?
I'm trying to make a plugin that gives a player a virtual furnace. My plan was to just spawn an invisible one under the world (nobody has access to bedrock level in this map) and open the furnace gui at a distance. Any obvious issues with this?
(alternatively fill level 1 of the spawn chunk with them and assign them via an array)
@alpine yoke sry i beatrey you im in verified Team 😦
gg
Hey. is there a way to send player title with 5 ticks fade in, 40 ticks stay and 10 ticks fade out?
@alpine yoke https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#sendTitle(java.lang.String,java.lang.String,int,int,int)
declaration: package: org.bukkit.entity, interface: Player
Im 1.8.8
rip for me
O
So basically you need a PlayerConnection which you can get by casting Player to CraftPlayer and then call CraftPlayer#getHandle().playerConnection.
Then
You gonna need to send 2 packets iirc
I think it’s called PacketPlayOutTitle or something
and how can I make the title like colored?
Yeah
Check out the packet class
It has 2 main different constructors
One for setting fade in, duration and fade out
And one for initiating type of title
And the title content
hey if i coded a plugin for 1.15.2 and works on spigot 1.16.1 but doesnt work on spigot paper 1.16.1 do you think that the problem is paper?
Yeah that might be
Wooow it works
yay
thank you Conclure
do u know how was the actionbar thing called to send msg?
PacketPlayOutChat ?
nicey
You can do it without packets in newer versions
1.8.8
I know right, but Im on 1.8.8 cuz skywars
@subtle bison doubt (X)
ah
this is my attempt at a GUI reloader but it doesn't seem to be working?
I might be passing in a different instance of the inventory or something, so maybe that's why it's not working
I don't think that is the issue though as I just tried this :/
which should paass in the exact instance of the inventory they're looking in
yes
I make a change to the inventory
but because inventories don't update
I reopen it
What change?
Doesn’t Inventory#update or something works as well?
lolxd is supposed to be subtitle
true
like this
PacketPlayOutTitle subtitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, chatTitle);
thanku
Yeah
yeah conclure I don't see an option to update ):
Let me see
ty
Oh I know
You’d do something like looping the viewers because it seems like Player has the method and it’s called updateInventory()
ah
ok ty
hmm
is it just Player?
or does HumanEntity have it too
as I can't see it for human entity
can u cast from HumanEntity to player?
Yeah
it still doesn't work ;-;
do it a tick later then
anyone have tutorials or just advice on how to debug/read nms code effectively ?
@formal nimbus a bukkitrunnable would work fine
I’d recommend BukkitScheduler cuz of lambdas
No pls
Eyo, how can i make my custom vexes NOT go through walls?
e.setCollidable(true);
didn't do the trick...
That's for entity collision with other entities
That's for entity collision with other entities
@lone fog yeah I figured.
Any ideas on how to have it for walls/blocks?
Is this not right? Console says it isn't a command but I'm pretty sure it is a command. Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "lpb user " + sender.getName() + " meta setprefix 10" + args[0] + " ");
It can be run on spigot servers, I've done lp and it still doesn't work.
Yes
do it a tick later then
@bold anchor he recommended delaying
and I thought it made sense
public void update() {
inventory.clear();
populateGui();
for (HumanEntity viewer : new ArrayList<>(inventory.getViewers())) ((Player) viewer).updateInventory();
} this should work (What my buddy is using)
Alright I'm asuming no one knows about removing vex ability to go through walls then
Well
what does populateGui() do?
Re adds the items
right
well I already do that
and I already clear it
so I just need the for loop?
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "lp user " + sender.getName() + " meta setprefix 10" + args[0] + " ");
sender.sendMessage(colorize("&7Prefix &9> &7Prefix succesfully set to &c" + args[0]));
}```
this runs as an unknown command, @naive goblet I changed it to the spigot command rather than the bungee one and it still doesn't work. Is my command layout correct?
@karmic sable there is a noClip boolean for entities, might be worth messing around with that. in NMS...probably should mention that.
is there a more efficient way to store information about a block than just using an h2 database
this database will be checked every time BlockBreakEvent is called
is their anyone can help me with this
@hoary cove what's your problem
try that again
hastebin.com @hoary cove
but with less caps.
@raw arch did it throw you an error?
[AuthMe] the server is shut down as defined in the configuration
I must be doing something else wrong
Yeah
@spare tiger tbf a h2 should be fine
all what i need is database name; username; password and it all right it still has this persis error
You wiped the inventory and readded the items as well?
@hoary cove is there any other errors around that
I'll show you what I did
what is better for saving a database as a file? h2 or sqlite
goBack moves them back to the last inventory they were viewing
and removed the inventory they were viewing from their history
then I will show the crate.removeItem function
@hoary cove paste you error there click save give me link
@spare tiger https://hastebin.com/tegagogixu.sql
then for every inventory in the list of inventories the crate has, it should update them
@naive goblet No error, just unknown command
That means /lp user isn't even registering
Tho if I do it myself it works
I think I just realised the issue
I'M A DUMB ASS
I make a new list
so all the inventories change
but that doesn't change the inventory in the player's history
so it shows them the out dated copy
ughhh
right
time to fix
Oh lol
Nook hm I don’t know what is going wrong really did you register the command executor? Else you might try use LuckPerms api directly
get an older version if there is no newer version
@spare tiger yes i already tried it
hm
wait i will give the version
what do you have in your config? any confidential information like ips or passwords or username just put like four stars
i know nothing of the version
put your config on hastebin just censor your database info
okey
Wth how does AuthMe handle errors
Nook hm I don’t know what is going wrong really did you register the command executor? Else you might try use LuckPerms api directly
@naive goblet Other commans work for this dispathCommand
And if you were to use luckperms instead of lp ?
not create new ones
Lol
@spare tiger do i have to include all config?
but it got rid of a bunch of other stuff too
so I need to fix that
but it's updating!
which is the important thing
big thank
@spare tiger https://hastebin.com/bamasidefu.bash
@naive goblet I'll try it
is there any way to get more than 6 inventory rows?
or open a second inventory somehow?
There is, but the inventory will look super fucked
Just make pages
Really bugged
@fading frost bugged
Try and place 3 chest near each other with WorldEdit and you'll get it
and apparently you can't even attempt it in 1.14+ (https://www.spigotmc.org/threads/inventory-size-bigger-than-54-in-1-14.383806/)
probably to stop the bug
omd that was the shit where you glitched 2 chests into each other lol
Yeah basically
That's bugged inventory
Maybe go tell mojang to make a new inventory gui
they'll respond immediately for sure
help me spanish please
@hoary cove definitely seems like a bug with that version of the plugin
try an older version
okey i will make another try
There was a bug report on the Authme github that said to use a newer version of the plugin
Unsure if that applies to what ever Nasuku is experiencing.
i already used the updated version still has issue
What bug
Might be worth post a bug report if it still doesn't resolve itsself.
im still checking the later later version of it
I'm trying to spawn a invisible slime as a mount but when it spawns it is visible for a split second.
final Slime slime = (Slime)location.getWorld().spawnEntity(location, EntityType.SLIME);
slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 10000, false, false));
Any way to improve that?
cause he wants an invisible slime mount duh
If you want to force player to sit on stairs or simillar it's better to use an arrow
players can ride arrows 🤔
Yes isn't that fun
Logic: ONE HUNDRED
when it spawns it is visible for a split second.
Consumers
Can I talk to Spigot staff about my account ?
When I do player.setHealth(player.getHealth() - 4); it works fine until I get to low health. Once there is less than 4 hp left I get this error:
at org.bukkit.craftbukkit.v1_16_R1.entity.CraftLivingEntity.setHealth(CraftLivingEntity.java:112) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
at net.xubels.zipcore.listeners.CustomItemsListener.onPlayerInteractEvent(CustomItemsListener.java:46) ~[?:?]
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:315) ~[spigot-1.16.1.jar:git-Spigot-0509002-6b95d59]
... 21 more```
How can I make it just kill the player instead of sending this error?
you should set the health level to 0D instead of minus value. Your current value is: -1.9999651908874512, which is impossible.
or use Math.max
so player.setHealth(player.getHealth() - 0D); would take 0 dmg then kill at 0?
do java player.setHealth(Math.max(player.getHealth() - 4, 0));
that would just set the players health to his current health.
the one that reflxction posted is the right way to do it I believe.
or there is a better way, damage the player with Player#damage
^
beware that #damage triggers the EntityDamageEvent which allows plugins to intrude it (i think?)
yep
yo noob question cause I forgot
/punish <something> <something2>``` which is args 0?
something1 is args0 sg2 is args1
aight ty
@spare tiger AuthMe-5.6.0-SNAPSHOT.jar i used this version
Is there anyway I can add quotation marks to args[0]? I'm trying to make it execute a command which uses " " around the args when the player runs it
anything else shutdown's
Can I talk to Spigot staff about my account ?
@James.#8380 you can try the spigot support email. What has happened (if you can tell here).?
args[0] is a string anyway @raw arch what do you mean
ah.
just out of curiosity Nook why does the command args need quotes around it ?
to create a space after
how to send actionbar message?
You can use player.spigot.sendMessage()
player.spigot().sendMessage()
interesting, thanks
is it possible to create a fake Player so i can execute a give command for that fake player?
why would you want to give something to a player that doesn't exist?
many plugins have commands to give items to a player
i'd like to be able to generate those items without a player
You can generate items with your plugin 🤔
^^
Just create an ItemStack, I don't see why you need to give it to a fake player.
^^ Yeah there's no reason
for other outside plugins that don't have a way to create the item other than giving it to the player
Not sure what you mean
i could probably just save the ItemStack that I want in-game and then just generate that
yup
Yeah that's what you should do
ok thank you :)
It could also be generated from yaml files
would changing the block below the players each tick be extremely laggy?
how to send an actionbar message, spigot().sendMessage() doesn't seem to work
actionbar is a title, thats all i know
would changing the block below the players each tick be extremely laggy?
@dusky sigil you could change the block when the player moves event
Good godarn idea.
iq 200
how to send an actionbar message, spigot().sendMessage() doesn't seem to work
@lunar widget
IChatBaseComponent chat = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + message + "\"}");
PacketPlayOutChat packetPlayOutChat = new PacketPlayOutChat(chat, ChatMessageType.GAME_INFO));
CraftPlayer craft = (CraftPlayer) player;
craft.getHandle().playerConnection.sendPacket(packetPlayOutChat);
}
}```
yeeted from the spigot forums
No don't it's better to use the API
the api with no NMC something like that?
player.Spigot.sendMessage(ChatMessageType.ACTION_BAR, <insert text component>)
Do that
NMS and im sure there is
@raw arch ive been doing some testing and it turns out spaces count as args in 1.16 (if that's the version you're using) so you can StringBuild the args and you'll have the args + spaces
I need to eat dinner brb
@pseudo crown I'm using 1.14.4 unforunately
Also what spigot version are you compiling against? @lunar widget
(Ping me when you're back)
I'm not sure if they do I have this right now and spaces aren't being counted for the args part
"luckperms user " + sender.getName() + " meta setprefix 10 " + args[0] + " ");
You making quick commands for LuckPerms?
I am making a command for a dono perk
Which can allow the player to change their prefix
ah I see
Yeah
That looks shady
I mean if it's for private use it's fine
Also why not just use the LuckPermsAPI @raw arch
Yeah it's not being distributed lol
I thought about that but I thought this method would be more efficient
Anyway you can force a space with:
"luckperms user " + sender.getName() + " meta setprefix 10 \"" + args[0] + " \""
(Going from memory right now, no pc)
oh isn't it \n
\n is for new line
Also what spigot version are you compiling against? @lunar widget
(Ping me when you're back)
@mellow wave 1.16.1
Alright what I showed should work
ok
My time to eat.. Here's the method in the javadocs: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.Spigot.html#sendMessage(net.md_5.bungee.api.ChatMessageType,net.md_5.bungee.api.chat.BaseComponent)
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
That works, thanks @mellow wave
can someone please tell me how to update configs with bungeecord config api? Its really dumb that i can't manage to get it working
I litterally tried looping through every entry
How can I change the direction in which the fake player looks? I've tried a lot of things found on the internet, but nothing seems to work.
Thanks
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
GameProfile skin = new GameProfile(uuid, name);
String[] textures = texture.split(",");
skin.getProperties().put("textures", new Property("textures", textures[0], textures[1]));
EntityPlayer npc = new EntityPlayer(server, world, skin, new PlayerInteractManager(world));
npc.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
for (Player p : Bukkit.getOnlinePlayers()) {
PlayerConnection connection = ((CraftPlayer)p).getHandle().playerConnection;
//connection.sendPacket(new PacketPlayOutEntityDestroy());
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
public void run() {
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, npc));
}
}, 10);
}
}```
Are you trying to load the configuration?
but im not able to make it recrusively
Could anyone compile the newest 1.16.1 build for me?
Could anyone compile the newest 1.16.1 build for me?
use buildtools
BuildTools doesn't work for me...
Are you trying to load the configuration?
@rare prairie no... Im trying to update it
So you want to save?
what do you mean with saving?
i want to update config entries
if they are missing
Update can mean by saving or loading the file, these are the method you can use.
how would i do that if i am planning to make a multi config file plugin?
new file -> load the file with ConfigurationProvider -> save (if you use any command that sets some values) -> done
its the same thing like on bukkit
ok, but as an example: My plugin finds this file:
entry1: value
entry2: value2
But what i want to have when loading the plugin:
entry1: value
entry2: value2
entry3: value3
how would i get my plugin to adding keys?
if they are missing
Configuration conf = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
if (!conf.contains("entry1")) {
conf.set("entry1", "value");
// ..
}
conf.save(file);
ok
is there a way to load a resource as a template file and edit the server file with its default values?
yeah i think this got a xy
?xy
Asking about your attempted solution rather than your actual problem
File file = new File(folder, "bungeeconfig.yml");
if (!file.exists()) {
InputStream in = getResourceAsStream("bungeeconfig.yml");
Files.copy(in, file.toPath());
in.close();
}
w
but what IF the file exists?
load the file
you want to add defaults ? @frigid ember
yes
1 sec
idk if you know it, but im using bungeecord
spigot api won't work
cuz of different configuration systems
fuck
😮
sry that this was late
no
well what a waste of time .
i think md_5 wrote it from skretch
who?
@rare prairie what do i need to do if i want something like bukkit config defaults in bungeecord?
ok maybe i should ask in the forums
im trying to give a votingplugin reward from a command block to the closest player. is this not possible?
/adminvote GiveReward VoteReward @p
:////
is there a similar plugin i can have just give people randomised predetermined items from a redstone command?
im new to java coding and i want to make a plugin that informs staff members when someone do /help
and i wrote this but i got stuck and i didnt know how to continue
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("help")) {
Player player = (Player) sender;
if (sender instanceof Player) {
if (player.hasPermission("help.p")) {
// and if server does contain staff members
player.sendMessage(ChatColor.DARK_RED + "a staff member will join you in no time");
}
else {
player.sendMessage(ChatColor.DARK_RED + "there is no staff memeber online");
}
}
}
return true;
}
@jagged torrent ok after inspecting the api i found out that
- The javadocs are broken and always show javascript is disabled
- There is something called "default", but its only when loading. Does that do what i want? And i need to save it then manually?
Valid, so when a player types the command /help, you send a message to a palyer ("Staff nickname")
?
no
you would need to loop through all the players on the server, and check if they have the permission (check if they are staff), if they do then you can send them the message! For example: Java```
// fancy for loop that i recommend you remember
for(Player pl : Bukkit.getOnlinePlayers()) {
if (pl.hasPermission(permission) {
pl.sendMessage("Assistance Needed!");
}
}
correct me if i misread your intentions 🙂
lol
i wanted to say if a player have a moderator helper ... ect rank
but
the perm idea is easier
and
better
yeah do that
ty for support
usually if a player is staff they would have a permission tied with it; np
anyone know how to do formatting with code blocks on discord? forgot .
ok johnny
man im so bored i just want to make some plugins for people - but not impossibly large or with big amounts of nms because im shit at nms.
help me, Idk how to send an actionbar message
@pseudo crown does it bother u if ask u some questions sometimes ??
player.spigot().sendMessage()
about plugins ofc
i do 😄 it's using nms though.. meaning you need to use abstractation or reflection if you wanna support different versions.. @lunar widget
@twin cosmos not at all, this chat is specifically for asking questions, just hit me
rip
you don't need nms for action bar above 1.12.2 iirc
ok ty
player.spigot().sendMessage()
@quick arch on what versions does that work?
Didn't the method I sent work?
If you want to force player to sit on stairs or simillar it's better to use an arrow
@mellow wave How come it is better to use an arrow? Any instantly noticable advantages?
ive actually never heard of spigot method to show actionbar.. i guess because ive been using bukkit
1.12+ I believe
Olivo, I importet and idk
@hybrid path It's smaller and won't be vissible
@frigid ember I stand corrected, in BungeeCord you can use a fallback configuration, but you can't copy all missing values to the config directly with the provided API, you have to do that yourself
I never used BaseComponents
There's a method to get legacy text
@hybrid path It's smaller and won't be vissible
@mellow wave Heck ok, can I just use the same code and replace it withEntityType.ARROWinstead?
Yes
k i'll look
i know in minecraft modding you can do something like: new IChatBaseComponent() i think you can do something similar in spigot as well ?
Just use new TextComponent(<insert message here>);
yep 😄
oohh
does it support enum colour codes ? (i don't see why not).
ok
I hope I remember things I don't have access to my pc
text components are a pain. https://i.imgur.com/Ok6SVua.png
oof
Not really
Just use fromLegacyText or something
nah that's fucking sick no ?
Time consuming
that's really good, you can just set the shit easily
Yeah just put the usual message in th the method I sent and it should convert
no i disagree, it gives you perfect control over the message you want to make
<red><bold>Hello world</bold></red>
That's done with MiniMessage Text (Adventure)
😏
does it also support command execution (so i guess <href src xD>?
rainbow seems cool
command execution?
that does look sick yeah
yeah so click me to /kill ! and when you click it you die because it runs /kill
that's kinda pog to be honest.
that's a really cool api 😄 i hope 1 day i can program something great like that
Hey guys, so i just downloaded vs code (i use standard vs and eclipse) and if i want to be able to work on my pre existing and new mc plugin projects i need to install the "maven for java" extension right
that's a title
vscode isn't an ide
get a proper ide for Java (Eclipse/IntelliJ/Netbean)
Damn okay then thanks
nick go away
vscode isn't an ide
get a proper ide for Java (Eclipse/IntelliJ/Netbean)
@quick arch wrong. that's what the Java extension is for. It literally uses Eclipse's code to do code-suggestion and other cool stuff
no one called you
@lunar widget That will send a title
yeah i know
Just use text components from legacy text with the message you want to send
ok
And send it with the spigot sendMessage
Damn okay then thanks
@blazing burrow You can use VSCode just fine. And yes, that is the extension you want to install. Just make sure you install theLanguage Support for Javaextension too
im looking at the spigot api and if this occurs does it actually mean it's not supported ? ```Java
public void sendMessage(@NotNull BaseComponent component) {
throw new UnsupportedOperationException("Not supported yet.");
}
No
The jar file that you're depending on is a barebones file
The actual implementation exists and is on the actual spigot jar that you use to launch the server.
so if i use buildtools and get the source i can see the real method ? either way thanks.
Yes
cheers.
so if i use buildtools and get the source i can see the real method ?
yes, although the idea is to abstract (read: not using) the server source
is the bungeecord getkeys recrusive?
hello. is there a plugin that forces the player to use optifine when in the server?
hello. is there a plugin that forces the player to use optifine when in the server?
no
hm thx
That would be very dangerous if they could do that
thanks a lot Nick
Just tell them to use Optifine
is the bungeecord Configuration getkeys recrusive?
That would be very dangerous if they could do that
Most likely forcing, as in "use or get kicked"
cause i want to force my players to use shaders
cause i want to force my players to use shaders
that's impossible
^
ok, thanks anyway 🙂
@frigid ember It is possible to deny connections without optifine. To do this you will need a custom plugin and all players using forge. And there is no force shaders option. That would just be stuipid
@pseudo crown how can i add a sonor effect like notification anyone just to pay attention to the player
??
all players using forge
Seems useless
No it sends a handshake packet with all mods. No other way to detect the optifine client
hm maybe you can detect it with the player login packet
no
I don't think Optifine is a forge mod.
It can load with forge
It's a client side mod and version
Forge might just inject the jar file on the classpatch
as a mod
@frigid ember It is possible to deny connections without optifine. To do this you will need a custom plugin and all players using forge. And there is no force shaders option. That would just be stuipid
@mellow wave hm i knew that u just cant force clients to use shaders, even if they have optifine
@twin cosmos sorry i don't understand what you mean, try to elaborate please also remember there are lots of other people here than can help you probably way better than me, but ill still try :p
That was just my thoughts I have no idea if that's actually possible
np\
You can just send them a pitched sound if you want to annoy them
(Asuming they have sound on)
You could probably also send a title covering the screen
oh
It can load with forge
Forge mods require(d) amcmod.infofile inside the jar. Optifine does not have it. Just because you see it load, doesn't mean it's a mod. Forge just injects it into the game
Are you guys talking about it's not possible to allow certain clients in general on a server?
I have no access to a pc atm
Are you guys talking about it's not possible to allow certain clients in general on a server?
Someone wanted all of their players to use Optifine for shaders
omg please stop chromebook... It's so annying it messes up my typing
They suck
Oh alright. I was just saying that because that's what Lunar Client does. A server can only allow people who have Lunar Client.
mhm
which you could probably fake if you knew the packet right ?
yes
Lunar Client makes use of plugin messages(https://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/).
WorldDownloader, VoxelMap, Schematica and WorldEditCUI is just a few that uses the plugin messaging channels to send information to the server
These are basically special packets recognized by the client and the server. They are named (channels) and can include any kind of data
that's really cool
They're handy if you want to make an optional mod and want to send information to the client from the server.
Ah, so you can write a plugin that detects the mod/client, and if that player has that mod/client, then they can join into a certain gamemode, queue or server.
Yes
That's also how the ForgeModDetector plugin works. It reads the forge handshake packet containing what mods a player is using
(Not sure about the plugin name can't remember)
But you could also implement that into the spigot source code itself, right?
You could implement anything you want in to your own fork
But you could also implement that into the spigot source code itself, right?
yes, but why would you?
yeah custom patches
just preference and opinions I guess, for this situation however, I do agree a plugin would be easier.
How do I get a player from a command? Like if I did /command @p mymod:myItem 2 the 2nd argument is meant to be a player. How would I get the actual player, assuming target selectors were allowed?
can I use title packets to send an actionbar?
yes @lunar widget
@frigid ember check if the player is online Player player = Bukkit.getPlayer(args[0]);
or if you don’t need the player online String player = args[0];
Bukkit#selectEntities() to use entity selectors
returns a List<Entity> (because it can return more than just players). Do the filtering you need to do
Thx for the fast reply. 😄 I'm in a hurry so this helps a lot
