#help-development
1 messages Β· Page 2128 of 1
The legacy warning shouldn't have anything to do with your error
Nor does it have anything to do with maven
hm ok
If you used the same plugin.yml the warning would have been there
Not required but it is recommended
The legacy support error went away when specifying the api-version. Thanks!
whats the difference xd
ew skript
Skript its a simple interpreter for building plugins. They are generally coded in a .sk file
basically its a plugin u put in
and its got a folder where u put files ending with .sk where you put your code
and it'll convert it to java
Basically what I told
but easier to understand
It won't convert to java, its just interpreted
Any here has knowledge and good practices about networking with redis. Specially hset, hget, pub-sub
?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!
I have this command which it registered in the main but when I try to input a player name that doesn't exist I don't get the error that I set it to. please help
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (command.getName().equalsIgnoreCase("getdragonwand")){
if (!(sender instanceof Player)){
System.out.println("Β§cYou must be player to execute this command!");
}
if (args.length == 0){
Player player = (Player) sender;
player.getInventory().addItem(ItemManager.dragonWand);
player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
} else {
Player player2 = Bukkit.getPlayerExact(args[0]);
if (player2 != null){
player2.getInventory().addItem(ItemManager.dragonWand);
player2.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
} else {
player2.sendMessage(ChatColor.RED + "(!) Invalid player");
player2.sendMessage(ChatColor.RED + "(!) getdragonwand <player>");
}
}
}
return true;
}
}```
How can I check when the player unequips an armor piece?
with an event
There isn't an event for that specifically, would inventoryclick work? This only works when equipping
there is an event for equipping armor so just check if the opposite happens
anyone here?
What is that called? I can't find that
Not in Spigot
Where can I find that? NMS?
Use inventory click event and check if the inventory is a PlayerInventory, then you can check if they clicked a armor slot and if the armor slot had a item already in it
No its an event added by some other unnamed fork of Spigot
please
What is the error
an internal error occurred bla bla bla
Ah! I think I see it, you are sending player2 the invalid player message instead of player!
For future reference the error is in the console
I know what the error is just not what causes it
im not dumb
This
yes i understood
Then why did you send this instead of the actual error
why is this code not working? ```java
Block block = bedLoc.getBlock();
block.setType(Material.BED_BLOCK);
Bed bed = (Bed) block.getState().getData();
bed.setHeadOfBed(true);
bed.setFacingDirection(face);
block.getState().update();
hey so i need some help. im using spigot 1.8 as a library so that i can make a plugin. all the stuff works (as in all the spigot classes like inventories, and players and everything else) but when i try to compile it says it can find object bukkit
it places the bottom part of the bed
what is something that is complex for spigot devs & can be added into my spigot util api
show pom.xml or gradle
u gotta place both parts
my pom.xml doesnt have any spigot stuff, its just mongo iirc
do I need a second location for the bed and then place it?
Just use #setType() to set the bed type
oh u are
thinkso
yes, thats why, u gotta add that to the pom.xml
ohh ok tysm
https://pastebin.com/tzz6UW0F added to pom, still same error
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You didnt add as dependency, just the repo
i did
Does it work then?
Why an image ;/
Only showed mongo as a dependency for me
You did it right the first time. Also now the mongo dependency is missing
Ah i see the issue. You're using 1.8 
β οΈ ERROR: No build artifacts found
Expected artifacts in: $HOME/.m2/repository/org/example/UtilAPI/1.0-SNAPSHOT
I keep getting this error when i try to use jitpack for my github repository . I have a release.. could anyone help me?
still getting this error
Show us your maven or gradle buildscript
where can i find it?
Then you definitely don't have one
No
I don't feel like going through it all
Look up tutorials on gradle or maven
Take your pick
i just want to know how can i use my project on another one using maven and jitpack
no need to go through it all
No see I do
i don't see any tutorials on this
Because I would need to show you how to make a buildscript
i've searched like 9 times
"jitpack publishing using github"
Like just search "gradle tutorial" or "gradle getting started"
if i kick a player with a reason "kicked for: \rreason", will it show as a newline? if it wont how do i make it?
i'm using maven
yes it will
Then search for that
ok thanks
I gave up, can anyone show me the FUC*** way of placiung bed with both parts PLEASE
on 1.8.8 that 100% WORKS!
I SPENT THREE HOURS OR MORE ON IT
nothing works lol I gave up is there any working code
Did you try this
Show the code
I tried getting the block data
ok
Block block = bedLoc.getBlock();
block.setType(Material.BED_BLOCK);
Bed bed = (Bed) block.getState().getData();
bed.setHeadOfBed(true);
bed.setFacingDirection(face);
block.getState().setData(bed);
block.getState().update();
Quick question: What's the BukkitRunnable used for?
Right so you didn't actually do this
Don't use it, pass a lambda to the BukkitScheduler methods
Why ?
I personally prefer using a Runnable and use it in my methods
Block#getState() returns a new instance every time
how do I update it without physics and why do I need to update it without physics
Because if you update with physics it breaks it immediately since there is no foot of the bed
BlockState state = loc.getBlock().getState();
//do stuff
state.update(false);```
k
So what does it do and why do you use it? π
Block b;
b.setType(Material.BED_BLOCK, false);
Bed bed = (Bed) b.getState();
bed.setHeadOfBed(true);
bed.setFacingDirection(face);
bed.update(true, false);```
god please let this code work
It's far more compact
in simple terms allows you to execute code after a said amount of time
do you mean b.getState().update or what
code scheduling Ig, altho as said most likely you'll find yourself that the BukkitScheduler methods do the trick well
That makes no sense π
I forget what's BlockState and what's MaterialData
Every time you call getState() you are fetching a NEW snapshot of the state.
Bed must be MaterialData
And what is great about scheduling vs just typing code with no scheduling?
Block b;
b.setType(Material.BED_BLOCK, false);
Bed bed = (Bed) b.getState().getData();
bed.setHeadOfBed(true);
bed.setFacingDirection(face);
BlockState state = b.getState();
state.setData(bed);
state.update(true, false);```
or perhaps wanna coordinate a task to run on the server thread from a thread in lets say the common fork join pool
This would be so much easier in 1.13+
yes
People really gotta stop using 1.8
Use this
your code didn't work, but ig you meant state.setData and state.update instead of b
how cna i get the player from a sender
I can test it now
respect!
Thanks! @ivory sleet
IT WORKED I LOVE YOU THANK YOU VERY MUCH ASND THAT YOU AGAIN VERY MUSCH @waxen plinth IT WORKS JUST WORKS I MEAN LOOK AT MY FUCKI*** BED
lol
pog
thats a cool sky texture
*shaders
ah makes sense
anyone?
but you don't know that I spent THREE HOURS of my life for that
What are you trying to do
like if i join the server from 1.17 and then from 1.18 how can i get the version i was joining from?
I know theres a way to do it as I do it for hex colors; just need to find the code lol
Viaversion API I would imagine
How I've done it is getting the protocolversion of the client, but I'm also using Paper, and its coming from their NetworkClient interface
I thought by "client version of the player" you meant a version of the player object that belongs to the client somehow
People's dumb questions in here have messed me up
lol yeah
I don't think there is a way to do it in base spigot, in Paper there is but tbh id rather use an api like viaver
is there a way to see total amount of lines of an intellij idea project?
there's this statistics plugin
Search in files the whole project
Turn regex on and search for \n
Then click open in find window
Or
cloc
cloc is better because it counts empty lines, comments, and code in separate categories
how do i check if a material is legacy (i get a random one). Shall I just do #toString()#contains("LEGACY")?
isnt there something like Material#isLegacy() ?
?jd
no
Why do you need to check
why ?
Redempt already did that
If you specify an api-version you should never need to check
So I dont give a legacy item to the player?
.-.
oh
ok ty, didnt know that
I need some help please
I want to make a space helm (which I have done)
but now I want to implement a command /spacehelm <player>
which gives that specific player the space helm
with the name of the player given to
like -
from - loladminname
to - playername
how can I do it?
https://hypixel-skyblock.fandom.com/wiki/Dctr's_Space_Helmet
here is an example
how do i make a baby villager jump at a player
like animating that they are bumping the player
kicking him in ithe balls is what i want
if you look at baby villagers, they gang up and kick you in the balls
Hey, how do I test, if an entity is an Item Iron_ingot?
can you send me a video when its finished I want to see that hahahaha
nice one π
thank you for that, but how can i ignore all other items?
watc > cloc
How do i check when a SPECIFIC CHICKEN moves. Just want to check when it moves and make the player move like it
schedule a runnable every tick
then check if old location .equals new location
oh
if no, there's your movement
it will work but it probably won't be very "smooth"
why
not working if i only do write if i flush and close it works but i cant rewrite again
Thank youπ
What is the best way to "scan" like a 20x20x20 block area then save somehow and then at some point place all the blocks at a specific location again?
Keep a 3d array of BlockData?
I'd create a Map<Location,BlockState>
yeah or a multi-dimension array as Redempt said, but a Map<Location,BlockState> is probably easier
Why would you do a map
because it's easier to use
and where do I save it?
in the map?
a map seems weird i would agree
First of all, each BlockState already is associated with a location
why? you are "mapping" a blockstate to it's location
its easy yes
oh right, I forgot that
Secondly, this system wouldn't allow you to build it elsewhere
then just use a Set
yeah but I need to save it even if the server crashes
Set<BlockState>
Which is what I think they want
BlockStates can't be "moved"
A 3d array of BlockData is the best way to do this since it lets you easily build again relative to another location
well in that case I'd use a Map<Location,BlockData>
That's also not useful
then you can easily save it in a file because BlockData can be turned into a string
why? they didn't mention that they want to move it to a different location
how do I save that tho? I need to be able to restart server and not needing to scan it again
BlockData#getAsString() or similar turns a BlockData into a String
If you need to save it then your best bet is to use my library
maybe just explain what you are actually trying to do @slim kernel
It can save a multi-block structure as a string and then easily rebuild it anywhere
With rotation/mirroring if needed
And it will even rotate the block data within the structure for you
for example building a house scan it and then place it else where I need it for my plugin
how can i get one player skull with custom texture?
i was trying and searching and i just got it for old versions
I would scan it once and then just place whenever I need it
then probably redempt's lib is useful
but tbh I'd use schematic files
i'd just use heads database, its easier. otherwise you need to use base64 encoded skins and use those on skulls with nms i believe
damn i got ignored
CompletableFutures
callbacks @quaint mantle
you asked like 30 seconds ago?!
yep
how do I get and use that
noone "ignored" you
and i did answer you anyway
you can't just interrupt existing conversations and expect people to answer to you within 10 seconds
skull ItemStack or skull as a block?
anyway now im gonna interrupt this conversation with my own question
itemstack
I'm sorry πΏ
i got this sql query that spits out a syntax error and i cant tell why, i just want to add columns to tables if they dont exist
sql validators are also useless
showing the error may help
yeah its not helpful
no problem, just be a bit patient π
I'm already looking for code to send you
you're looking for a custom head itemstack with a base64 texture, right?
okay
yep something like that
i want to get the texture from one web
let me see
Is it possible to set the velocity of a LivingEntity when it has no AI (LivingEntity#setAI(false))? It doesn't move in my case, also, when I set the AI to true, then apply velocity and after that set AI to false again, it doesn't move either.
AFAIK: no
"no ai" = "not moving", from what I know
why do you need "no ai" though?
yeah i thought no ai by definition meant no moving
that'll always look laggy
try running it in shell and see it itβs valid
The entity needs to stand still normally, when I punch it, it should move in the direction I am looking
extend the NMS entity and override its AI logic
that's the "best" solution
So I have to use the Mojang Mappings for this?
why is it sendin this, i have this nowhere in my code
yes
It's probably the usage of the command you defined in plugin.yml
yes it is but why is it sending it
because you return false
no
Okay, I tried to avoid it, but since there is no other way :I
why i don't have GameProfile method? π€
did you register the command?
But why avoid it
try changing the name to something as a test
oh wait no i didnt
That's what md_5 says in the Spigot Update
As always, but especially now, please try and avoid/limit NMS usage at all costs.
ok now how do i choose whether the server uses the default ban or the custom ban?
?
Ah nvm I thought you wanted to avoid the mappings not NMS
From googling it seems you should use COLUMN_EXISTS to confirm the existance of a column rather than your select
Instead of saying this, why don't you tell us what you find confusing in this command. That would help @coarse finch more to improve :)
you have to add mojang's authlib as dependency
see the pom.xml of the "core" module I linked
anyone? i want the user to be able to choose whether to use the vanilla ban command or my ban command
minecraft:ban
how do i make an item have certain uses, so like after i right clicked it 3 times it disappears
but i want it to default to just /ban is the vanilla ban if they choose
item personal data container
i donβt think you can do that without dynamically registering and unregistering commands
idk if you even can unregister a command
could i use commandmap?
maybe but it might cause issues
im sorry but can u give me an example?
if i can just make it where i dont need anything for it in the plugin.yml it will work
Use the PDC. ItemMeta.getPersistentDataContainer() will return the PDC which you can use to store data under namespaces. Iβll highly suggest using mfnalex βs MorePersistentDataTypes library.
?pdc
Exactly
In this episode, I show you how to use Spigot's Persistent Data API to store primitives and Strings in items, blocks, and players. #Spigot #Minecraft
β Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentatio...
thanks both of u
np
?paste
I now run BuildTools with --remapped and added the things to pom.xml which md_5 wrote in the thread. But if I try to extends EntityZombie for example, it still doesn't recognize. This is my pom.xml: https://paste.md-5.net/hutagitede.xml
how complicated it is to get a simple head
π
Is there a way to live update a server resource pack?
someone please help me setup maven
it always gives errors
i dont know how to add dependencies i have api
It is not recognizing my api
have you imported it?
how
you're missing dependencies
what do i need to do
Idk, I'm on eclipse
import what
Ig you don't have maven for it
So add it to the build path
oh nvm bit late
do not add it to the build path
I am already finished hahaha
They have no Maven for it tho?
Wanted to use mojang mapped NMS, why can't I use it even if I added everything to my pom.xml?
any err?
No
Here is the pom.xml https://paste.md-5.net/hutagitede.xml
pls tell me what should i do
it seems fine, have you checked that the libs was imported?
You mean the import Statement in my class?
btw they change the name of some class in mojang mapping
add what to build path
Your api
some old name can't be used anymore
how
It's stupid to add to stuff to the build path, but idk how to do it if you don't have maven for it
Idk, I'm on eclipse
This is pretty actual from this post : https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-2-release.534760/#post-4305163
What is row 43
alex
me?
do you use maven
obviously, I just sent a blog post about how to use mojang mappings with maven that I wrote, lol
Thank you! :) I will try and tell you if it worked :)
can u help me setup it?
im getting error
np!
They have spigot working with maven, but not their own API.
Which they have not imported
And have no maven import for
And since I'm on eclipse idk how to help them
java.lang.NullPointerException: Cannot invoke "org.bukkit.scoreboard.Scoreboard.getObjective(String)" because "skyflag.skyflagminigames.SkyflagMinigames.scoreboard" is null
i cant see run button and i get error
skyflag.skyflagminigames.SkyflagMinigames.scoreboard is probably null
and what's the error?
data.set(new NamespacedKey(SlimeChunkDetector.getPlugin(), "uses"), PersistentDataType.INTEGER);```
what the f is this
whats wrong with this line? java public static SlimeChunkDetector getPlugin() { return plugin; } this is how i did it in main
Can manager.getNewScoreboard() be null?
Still I can't use e.g. EntityZombie in my project. IntelliJ also doesnt propose to import something. I believe I did every step right and everything was added to my local maven repository. Any idea why it still won't work?
What do you mean what is wrong with it? Do you get a runtime exception? Compiler error? Is it just not working?
may you try CraftPlayer class, if it do not work, means your libs is not added successfully
ye idk whats wrong it just doesnt work
So no errors?
org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer? That works
?paste your pom.xml
ill send in dms cuz i cant send pics here
oki
!verify
Usage: !verify <forums username>
to send pictures
@slow thunder
.
oh ok
read it?
did you run BuildTools with the --remapped option?
Are you using the files somewhere else?
they don't use EntityZombie as the name anymore in mojang mapped NMS I guess?
Yes, is there a way to check if it has worked?
In IntelliJ, do File -> Invalidate Caches -> tick all boxes, then click "invalidate & restart"
That could be the issue, but what do I use instead?
Zombie I guess?
after that, open your project again and wait a few minutes until it has re-indexed everything
if it still doesn't work, ping me pls
!verify UrSOMeanLOL
A private message has been sent to your SpigotMC.org account for verification!
@tepid ore
how do i check if an itemstack is a splash potion
now this
?paste Show the code
check if the ItemStack's getType() == Material.SPLASH_POTION
instanceof
instanceof?
use getType as above
Can any1 help? https://hastebin.de/urixuxumin.less
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!
That is what this channel is yes
ur funny
You've already closed the stream
They are one-time uses
I am funny? You are the one who asked "can any1 help" without providing further information
i forgot xd
if you just ask "can any1 help" then noone can help
It was kinda funny tho
don't close your stream while it still running
im not closing it tho
what's GameServer line 56?
the ioexception
.
?paste the whole GameServer class source code
You need to store something as well, like this data.set(new NamespacedKey(SlimeChunkDetector.getPlugin(), "uses"), PersistentDataType.INTEGER, myInt);
it cant be empty
:>
sm
Np :))
we all are
your "process" doesn't seem to have any output stream or it's already closed
what the heck are you trying to do there anyway?
the whole code looks a bit weird tbh
susicious
execute spigot commands
Wat
that servers are running in a process
? If you want to run commands just use the api
what kind of outputStream you are getting from that process
the spigot servers output bruh
if you want to write something "to" the server, you have to use the server's INPUT stream, not the OUTPUT stream
how will i write into inputstream
getInputStream then write the data?
@tender shard @sterile grotto Oh nooo, it was "Zombie" instead of "EntityZombie" all along, Im stupid :D Thank you two very very much :D Now at least that works ;) See you when I get the next error xD
you cant write into inputstream
I am so glad this discord exists, I wouldnt have found the answer on the internet
wtf
replace getOutputStream with getInputStream ?!
are you on the java process api ?
oh yeah, obviously mojang has different names π
yea
of course you can, that's what it's for
an INPUT stream is to RECEIVE input
Required type:
OutputStream#
?
a processes output stream is what you write to for it to end up in the processes stdin
do you have any idea what the difference between the following things is?
Input/Output
Reader/Writer
@fleet pier ?
so your java logic gets the output stream that the process has the respective input stream for
obv
well I think the opposite is true
you are trying to send commands to the server by using its output stream
omg qt! <3
which works one time
but the scnd time i do that it stopps working
if you are trying to execute spigot command, why don't you just use spigot API?
cuz i cant access the spigot server its running in a process
still
try to use System.lineSeparator() instead of "\n"
the system i work on is standalone it could execute anything all i want to do is execute commands in that process
it doesnt have to be a spigot server yk
okay
oh, I see
You probably have the issue that you need to actually flush the output stream
[18:59:13 ERROR]: Could not load 'plugins/dctr-PRE-RELEASE-0.1.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `space.helm.dctr'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:84) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:393) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:269) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.ClassNotFoundException: space.helm.dctr
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:155) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:114) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:398) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:82) ~[patched_1.16.5.jar:git-Paper-794]
... 8 more
I keep getting this error
anyone can help me?
org.bukkit.plugin.InvalidPluginException: Cannot find main class `space.helm.dctr'
you need to provide a main class in your plugin.yml
what
name: DctrSpaceHelm
version: '${project.version}'
main: space.helm.dctr
api-version: 1.16
see
plugin.yml
o
right
wait what if I change the dctr
to the class name
will that work?
name: DctrSpaceHelm
version: '${project.version}'
main: space.helm.SpaceHelmet
api-version: 1.16
no
space.helm.dctr.SpaceHelmet
SpaceHelmet is your main class?
you need to provide the packages and the main class at the end]
i think so
name: DctrSpaceHelm
version: '${project.version}'
main: space.helm.dctr.SpaceHelmet
api-version: 1.16
this correct
yes
if that is the path to your main class, yes
ill ask again because i had to go get dinner, but i got a syntax error in my sql query
DROP PROCEDURE IF EXISTS addColumnToTable;
CREATE PROCEDURE addColumnToTable()
BEGIN
IF (NOT EXISTS(
SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tableName'
AND table_schema = DATABASE()
AND column_name = 'test') )
THEN
(ALTER TABLE BANKS_PROFILES ADD COLUMN test SMALLINT DEFAULT 0;)
END IF
END;
CALL addColumnToTable();
and the error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ALTER TABLE tableName ADD COLUMN test SMALLINT DEFAULT 0' at line 9
It supposedly tells me where the issue is, but i can't see what the issue is because the syntax at least in my eyes and according to google is fine
pretty sure you should not have a ; after your 0. Your closing ) ends the statement
i already tried removing it, didnt change the error
alter table table_name add new colm name column structure or definition [before colm name | after colm name];
it should be ADD NEW COLUMN ?
seems what google is saying
seems to be just about what im doing
how do i add 1 to PersistentDataType.INTEGER
you first get it, add 1, and then set it
yup
i want to give people an item with 1 then add 1 everytime they right click an itiem
and when it reaches 3
the item disappears
basically 3 uses
ok then use ItemMeta#getPersistentDataContainer().get() to get the current value, and use ItemMeta#getPersistentDataContainer().set() to set the next value. and delete the item when it reached 3
dont forget to set the item meta to the item again or the change wont reflect
that worked ty @hushed spindle
what do you mean rank?
like
Wdym ranks
third party defined?
like [VIP]
They are handled from Luck Perms i think
noo like
Mostly
I want to embed it in a code
luckperms
i need some help. in the config, the server admin can choose whether to enable or disable a custom ban command. how would i implement that?
if its enabled, it uses a ban command i wrote, otherwise, it uses vanilla ban command for /ban
You can just use the minecraft:ban command instead of your plugin command
No need to bother with a toggle for each command
not everyone knows that, and i want it to be for the /ban command
can i just change which has the /ban, like switching it from me to the server?
If you use the namespaced versions yes.
you can add some logic in your custom command
Itβs just that your input needs to be the same
ok how would i implemenet that
If your config value is false, have the server execute the ban command using the minecraft:ban namespace.
nooo, i want it when a user uses /ban, it will use either my ban or the servers ban based on the config
like can i just disable my command entirely if its false
I guess you can use the command map directly but that sounds like a bad idea
Well what I suggested would essentially do that, but unregistering commands isnβt easy.
why would it be a bad idea?
Itβs not necessarily a bad idea itβs just a little dirty since the map isnβt exposed
You have to hack your way into it
oh ok
how do i check if PersistentDataContainer equals something?
Get the value and compare it?
.equals
how do i get its value?
I mean, if you want to compare the entire container, .equals is implemented
why am i getting this
why would you even compare the whole container
i wanna just compare the key i added "uses" which is an integer
@slow thunder ?
yes that worked when setting the data but i want an if statement so if it has 1 use, then set it to 2 and if iti has 2 uses then set to 3 and if it has 3 uses then clear inv
They already have
The save it back to the container
But it seems they don't know how to do an if check??
when the server is reloaded the bukkit runnable will start again
or basically loop it in join event
how can I do this?
If you have a runnable that runs on join you can loop online players in your onEnable method and start it again there
.
That's how you get the value
You've already done it once
ok i got the command map, now how do i unregister a command
You remove your command from the command map
if (itemInMainHand().im().getPersistentDataContainer().get("uses", PersistentDataType.INTEGER) == 1)
will this work?
Yeah
itemInMainHand() doesn't appear to be a method in your class
oh shit i deleted it when i was testing earlier
Xd
how exactly is that done?
bascially i want to remove the test sourceset
Just remove the folder
wont it recreate it
No
hm
how 2 use lp api?
jk
String prefix = user.getCachedData().getMetaData().getPrefix();
so I just need to implement this
am i doing this queuing right, it throws jar does not contains plugin.yml?
?
Since you're building with Intellij you need to tell it to include the plugin.yml
I highly recommend using maven instead
(or gradle)
i cant fucking setup maven
ok so im pretty cure i cant create 2 of the command class, so how would i get the existing command class that i have in the main class?
Instance or class?
whatever doing new BanUtils; does
Instance
ok
Save it as a variable before registering it
And return the variable when you need it
i do
Yeah
so i make a method to return it in the main class?
Hold on
ok i got it i think
public class MyClass {
private static MyClass instance;
public MyClass() {
instance = instance == null ? this : instance;
}
public static MyClass getInstance() {
return instance;
}
}```
Like this
Wat?
or the main class
Where you need it
ok
MyClass is the class you want to get
i already have an instance of my main class and i think its interfering
?paste
https://paste.md-5.net/wedakuxeto.java i cut out the command part of it
probably not, idk what that is
Oh, so the public BanUtils() { instance = instance == null ? this : instance; } has to be in the BanUtils class
oh ok
Then use BanUtils.getInstance() to get the instance
ok
ok and if i unregister a command i can just do getServer().getPluginCommand("ban").setExecutor(BanUtils.getInstance()); to register it again?
im so confused
i have a command that they can choose to have enabled or not
if (plugin.getServer().getLogger().warning(im.getPersistentDataContainer().get("uses", PersistentDataType.INTEGER).toString()).equals("1")){
}``` why is this wrong
can somone help me
ive been stuck in this for 3 hours
You have no NamespacedKey, only a string
You need to do .get(new NamespacedKey(YourPluginInstance, "uses"), PersistentDataType.String)
Oh, just return when it is called if the command is disabled
its an integer key tho
ok let me try
java.lang.NoSuchFieldException: knownCommands
Object result = getPrivateField(Bukkit.getServer().getPluginManager(), "commandMap");
SimpleCommandMap commandMap = (SimpleCommandMap) result;
Object map = getPrivateField(commandMap, "knownCommands");
@SuppressWarnings("unchecked")
HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
knownCommands.remove(cmd.getName());```
Are you on 1.17 or above?
1.18.2
Make sure the knownCommands field isn't obfuscated
private static Object getPrivateField(Object object, String field)throws SecurityException,
NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Class<?> clazz = object.getClass();
Field objectField = clazz.getDeclaredField(field);
objectField.setAccessible(true);
Object result = objectField.get(object);
objectField.setAccessible(false);
return result;
}```
how do i do that
I assume you copied and pasted that from somewhere
Anyways open the SimpleCommandMap class and take a look
It should be available in your IDE
oh i found a thread that is almost exactly what i want
ooh even better, https://github.com/Pelt10/DynamicCommand
Same thing there make sure the field name hasn't been changed
oh and make sure to follow their license
in this case it's fine to use and modify but you should keep the license in mind. Don't just copy and paste code blindly
yeah
Is there a bot for Ressource Updates? I post an update and the bot writes an automatically message with the content of the update
How will the bot find the content
Heβs talking about CD basically
I semi looked into it, there are endpoints to publish a resource, but you need some tokens and they may be protected by cloudflare
can someone help with this
Try creating section
Adding section
Adding value
Saving
And then read
ok the resource didnt do what i need. anyways the class is not obfuscated
send the yml file then
its just
warns: in the config but i also tried
this to create the section but it doesnt work same errors
but thatβs not a configuration section
there is no configuration section called βwarns.β + of.getUniqueIs()
right
youβre getting a value from warns
not a configuration section
and then after that youβre trying to get a configuration section
but why would i be getting an error sayings "warns" doesnt exist? what would it be if its not a config section
@dry forum How about you directly set a value by doing getConfig().set("warns." + player.getUniqueId, "Hello");
np
can anyone help me?
With
oj it didnt reply
this
youβre sure the field names are correct?
i would check if it is correct then
ok, how would i do that?
the thing it errors on is in the class SImpleCommandMap not sure if that helps
control click
yeah i know that
so is the name of the field youβre trying to access the same as the one youβre using?
yes
not sure why you would get a fieldnotfound exception then
im not sure either
try doing getDeclaredFields and printing them out as debug
Sry, I'm slow. idk if you've solved it, but it should be .get(new NamespacedKey(YourPlugin, "TagName"), PersistentDataType.WHATEVER_TYPE, YourValue);
yeah i figured it out thanks
Nice :>
i just noticed my fan vent is asymmetrical π‘
Fix it
i cant its a laptop
how can i fix this
but sniskus you know anything about this?
how do i check if args[0] is an integer?
Wat is dis?
Can you rewrite the message
args[0] instanceof int
no
no
basically i get this error java.lang.NoSuchFieldException: knownCommands but the field exists
no i dont want to do that because in that case console gives error
"".equals(string.replaceAll("[0-9]")); is what I use. You have to check for a hyphen at the start and make sure that length isn't 0 tho
would it not work
a string wonβt ever be an instance of an int
oh makes sense
@tepid ore for some reason replies arent working
but read that
how would I go about making it so if a certain player joins, their gamemode is forced to be in creative?
What is a certain player?
Permission?
check thier name and it matches, set them in creative
Make a PlayerJoinEvent listener, check that the user name is correct and change their GM
Player player = event.getPlayer();
if (player.getName() == "ArisTheMage") {
player.setGameMode(GameMode.CREATIVE);
}
what is that field?
This does not work
knownCommands
dont compare strings with == use .equals
Never dealt that much with fields, but I assume that field does not exist
lol no
ah
whats the type of the field and where does it come from
right
well its what was on the forum
idk and idk
lol
oh it comes from SImpleCommandMap i think
Always use .equals unless you are comparing primitives or null
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
event.setJoinMessage("Oh look, A person has joined. Very cool.");
Player player = event.getPlayer();
if (player.getName().equals("ArisTheMage")) {
player.setGameMode(GameMode.CREATIVE);
}
}
?paste
This also does not work
public static void unRegisterBukkitCommand(PluginCommand cmd) {
try {
Object result = getPrivateField(Bukkit.getServer().getPluginManager(), "commandMap");
SimpleCommandMap commandMap = (SimpleCommandMap) result;
Object map = getPrivateField(commandMap, "knownCommands");
@SuppressWarnings("unchecked")
HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
knownCommands.remove(cmd.getName());
for (String alias : cmd.getAliases()) {
if (knownCommands.containsKey(alias) && knownCommands.get(alias).toString().contains(Bukkit.getName())) {
knownCommands.remove(alias);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}```
You did register the events right?
Yes, the join message is changed even
whats getPrivatefield doin?
Do you have any other plugins that might interfere with this?
Yeah It might
Try changing the priority
did you register it?
I have multiverse core
wait already asked
i'm trying to make it so It doesnt boot me into survival every time
if youβre doing it only for yourself it might be fine to wait a tick or so
@EventPriority(priority = EventPriority.HIGHEST)
just remove the plugins jars out of the plugins folder and see
I can send it in a sec
Well multiverse is the culprit
how do i stop a thread without the deprecated stop
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
What is an output stream?
as far as i know an input stream is the input, and the its output stream is?
is it the other party input stream?
like, what you receieve from the other party input stream?
actually
isnt it reverse
input reads and output sends right
and output stream is the output
private static Object getPrivateField(Object object, String field)throws SecurityException,
NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Class<?> clazz = object.getClass();
Field objectField = clazz.getDeclaredField(field);
objectField.setAccessible(true);
Object result = objectField.get(object);
objectField.setAccessible(false);
return result;
}```
I want to use a bit of kotlin in my plugin but get the error ΛΛjava.lang.NoClassDefFoundError: kotlin/jvm/internal/IntrinsicsΛΛ.I donβt want to use maven or gradle because I donβt know how. So how would I fix this?
Use maven or gradle and shade the Kotlin stuff in to your jar
It will be harder without them
im trying to loop kits my kits like this for (String kit : KitData.get().getKeys(false)) { but it doesnt return anything
nvm
Can I use maven or gradle in IntelliJ after creating a project? If so how would I do that
I'd create a new project and move the source files over
Will that work? I have written quite a lot of code.
oh and install the Minecraft Development plugin it will take care of most of the setup
I have but most of the time I work offline so the plug-in wonβt recognize the Minecraft version
Yes you will just have to import the same dependencies with maven
Do you have recommendations on whether to use gradle or maven?
I prefer Maven, but sometimes I have to use Gradle
It depends on what your goal is
I find Maven easier, Gradle is a bit more complex
Hey, I am getting a ClassNotFoundException and ClassNotDef Error when trying to create an object of a class that extends Slime from NMS, any idea why?
?paste
This is the errorlog in console: https://paste.md-5.net/adewowonez.nginx
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
I already use Mojang mapping
hm looks fine exept you have two spigot dependencies
Make sure you're using maven to compile your jar
It is "package" under "Lifecylce" isnt it
this
Yeah
ive been using straight up ItemStack for all of my custom items. would i be benificial to create wrappers for them? I realize this is kind of a subjective question, but I just want someone else's opinion.
im pretty sure it would be beneficial, because i have 10+ custom items
Ok so for a class like this, should I use an interface or an abstract class?
abstract class
actually yeah having said that cause of the registering it should be abstract
but if that wasn't there
well you canβt have fields in an interface either
I could replace the fields with methods like getString() or getIcon()
yeah exactly
why use an interface over an abstract class?
like when would you actually use one
Ok, i believe i have gotten it to work, thank you
oh, thank god
any idea of how to make it work?
Thanks, that worked :)
Hi, anyone can send me his github link please. Because i wanna get example for doing a Storage system
Who's "his"
this
@chrome beacon can I tell Maven somehow to compile the jar directly to my plugins folder in the server directory?
Yes but I don't recommend that
ArrayList<ItemStack> items = (ArrayList<ItemStack>) KitData.get().get(kitname + ".items"); i use it like this for (ItemStack item : Kits.getContents(args[0])){ its giving me an error
annotate the class with @Getter so you dont have to annotate every field with it
oh cool, ty
Sonething is null
trying to save a player's inventory for some reason this loop doesn't save the 35th slot for (int i = 0; i < 35; i++) any idea why? all the other slots get saved
how would I do that? I am now at the point where I have to implement this..
You can also avoid half the hassle and just add the pathfinders onspawn
But yeah seems fairly simple
My goal is to have a noAI mob, which gets a velocity when hit by a player
So it shouldnt move normally
NoAI doesn't tick pathfinders
Or gravity itself
Theres Mob#setAware
Or you can just clear the pathfinder list
But it should stop moving completely, until I hit it
No gravity no nothing?
Well, I want to assign a velocity then, the mob flies a parabola and then it shouldnt move anymore