#help-development
1 messages · Page 1633 of 1
however for some reason the getObject will not parse an array
easy solution
we change it to list
and change config too
so theyre both lists
then we use getStringList
not found
k
it doesn't have spigot support and im 99% sure there are no api docs
but its there
you are going to have to java String[] matrix = data.getStringList("matrix").toArray(new String[0]);
uh i dont know rust
oh fine ill try
yes
anyone?
Now watch your IDE bitch about possible null
just do object?
lol it didnt
it instead said that items/matrix cannot be null
when i was doing the if check
idk anything about kotlin
isnt kotlin a coding language
LOOK WHAT I FOUND
Okay
kotlin is a jvm language that works very similar to java but with nicer syntax. People yell at you for learning it first because its a bit smaller and theres less examples
but as you learn kotlin you learn java by extension so eh
you need to change your config entries to a List if you are loading as a List
Its kinda like speaking italian and then listening to spanish
eh
im using your way
you just changed to getStringList
so change teh config to match
recipes:
cow:
itemStack: COW_SPAWN_EGG
matrix:
- "DDD"
- "SSS"
- "DDD"
order: "DS"
items:
- "DIAMOND_SWORD"
- "STICK"```
must be fine right
yes
imma test now
yooo
could i use someones big brain
i have this custom item in my inv
what command would i use to clear it out of my inv
im really confused about all that info
i have a copy/paste of it too
[SZMYT: The data tag did not change: {Motion:[7.620469671919723E-6d,-0.0d,3.783139530776624E-6d],UUIDLeast:-7469281371821056333L,Health:5s,Bukkit.updateLevel:2,Invulnerable:0b,Air:300s,OnGround:1b,Dimension:0,PortalCooldown:0,Rotation:[15.942183f,0.0f],Thrower:"SZMYT",FallDistance:0.0f,Item:{id:"minecraft:fish",Count:1b,tag:{display:{Lore:["Pollock are plagued by parasites"],Name:"Pollock"}},Damage:0s},UUIDMost:-6329548184662228477L,CustomName:"§;§:x1 Pollock",Pos:
Please someone help
just copy and past?
do you have the power to help me 😂
.
no i cannot because an error is only like 1/3rd of the problem
theres also the code and the exception if there is one
hard to remove it with commands
i need to command so i can make a shop
try NBTExplorer to edit your inventory
any idea how I would go about checking if the config.yml is outdated and if so reset it?
yes
add a version
wdym
the plugin is already there, its not mine, its a custom fishing plugin. but the gui for the shop is ass and all fucked. so i was gonna make my own in deluxe menus
???
is that seriously your answer
yep
fork the shop plugin
if its opensource
can anyone help me with my problem??
@rare cave how would I go about resetting my plugin config?
srry but google is not being very helpful
delete it then saveDefaultConfig()
yeah as in the delete code
Would this fix my problem
whats ur problem
and if so, how do I run mvn install in the folder
its not open source and if it was i wouldnt be able to do it anyways im lowkey tarded 😂
these 2 images @rare cave
but ty for your help
Neither of those images say anying about a maven package. But NMS changed there is no 1.17. Package names changed
Alr I figured out that but how would I go about checking if a config key doesnt exist, just check if null?
where would I find the names??
try it
what post
this should work anyways
it is
the stash link??
its fine
you should not compare integers with float
this doesnt seem to work
i just realised that the last 2 lines of the if are redundant
but the clearing of the file
doesnt seem to wok
From teh announcements https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
is having ur plugin depending like 99% on config.yml bad
depends what for?
it has checks to see if keys are not there, and uses a default ;-;
but i still want the config to update
all im asking is how to clear/delete config
ty lol
once you have it workign, use a seperate file for yoru recipes. Not config.
that worked ty
None of my things are spigot, they are all net.minecraft, and org.bukkit.craftbukkit
nope
whats nms I have nbt
nms = net.minectaft.server
i want users to be able to change the recipes as they like tho
you read that post I linked you about 1.17 nms mappings
So?
its separate from the config, so it won't stop your plugin starting up when a users breaks the recipes when editing them. And they WILL break it.
o
also if its a seperate file you can add a reload recipes command
keep users out of your plugin config as much as you can
nearly two hours ago I asked, anyone?
can you explain your problem a bit more, rather than just "it's broken"?
I mean you could try boolean instead of Boolean
You are using a system no one here has ever used. But my guess is that yoiu are running an Async Future on server stop. However ther server will nto care and will stop anyway
^^ This sounds possible too
my guess is that he just never uses his #handleStop method
since he's just adding the callbacks to his list via CF
EDIT: nvm
He uses them via JavaScript through that spi whatsit plugin
spi whatsit yes
yes
How would I get the last location of the player in the last world in PlayerChangedWorldEvent
doesn't he add the callbacks via js to his plugin?
No clue, who would use JS as a plugin to a plugin when you have direct Java plugin access anyway
?jd
I can't see through there anymore
How do I give player Splash potion of Healing?
You can't get it directly through spigot, what are you trying to do?
bruh for somereason intellij wont let me click next
saving the last location in the world. But I think I got it. Haven't tested it yet but I think PlayerTeleportEvent will do
nice
yeah works
Do plugins disable in the reverse order of enable?
is there an event for entities turning their head towards a player?
ummm - afaik it is somewhat random but idk
That is so incredibly specific i have no clue why there would be
°-°
It's probably not a great idea to rely on that, what are you trying to do?
I mean there must be a dependency topological order, shouldn't be weird if it is so
You would just need to listen for their movement
so
i think packets but idrk
I am wondering if an overwritten dispenser behaviour can be put back into registry on disable on server reload
maybe it disables it before every one of them
Or, every few ticks you could check for entities around a player, and save their position and check if they start facing the player?
Although we shouldn't be touching this
Hence, server reload = bad
packets based
or actually
look here
my domain has a - and I cant use it to name a package in Java should I just name my package like my domain without the -?
whats the best way to have a function continuously execute once every second?
?scheduling
commands always execute on the main thread, however you can hand off processing the same way
using the scheduler
ah okay
There are sync and async methods in it
be careful. Accessing teh Bukkit API is not safe async
?paste
Anyone who doesn't mind helping? https://paste.md-5.net/zesamalozo.cs
why don't you directly go to hastebin
?paste
are they?
why does it have to be on md5 website
RecipesManagr class: https://paste.md-5.net/ojodayuzub.java
Anyone who doesn't mind helping? this is the errror: https://paste.md-5.net/zesamalozo.cs
this is line 16 in main class : getServer().getPluginManager().registerEvents(new RecipesManager(this), this);
not necessary
your object recipe is null
debug to see why I guess
thanks
wdym
1s
itemStack = ItemStacks.createBookStack(Enchantment.getByKey(NamespacedKey.minecraft(material.toLowerCase())));
And what does that do
public static ItemStack createBookStack(Enchantment enchantment) {
ItemStack enchant = new ItemStack(Material.ENCHANTED_BOOK);
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) enchant.getItemMeta();
if (meta != null) {
meta.addStoredEnchant(enchantment, 1, true);
enchant.setItemMeta(meta);
}
return enchant;
}```
wait
and if meta == null
I know why its doing that
probably
i mean idk
prob cuz
getByKey(minecraft.
wants
the minecraft name not the
namespacedkey
name it whatever lolz
as long as it traces back to you
or your org
it's good
itemStack = ItemStacks.createBookStack(Enchantment.getByKey(NamespacedKey.fromString(material.toLowerCase())));
is fine
right
No
a normal book
that has damage of enchanted book
so it's practically a enchanted book
or wait
is enchanted book material diff from book?
oh woops
Hello everyone, I am using google translate to send this message, sorry for the potential errors.
Let me introduce myself, I am a young Minecraft developer. I am currently programming a local Minecraft server with the Python 3 programming language. I am using Spigot for my local test server.
My problem :
- When I create the script for example:
import mcpi.minecraft as minecraft
#I'm not sure what it is for but I think it allows me to code in Python on Minecraft
mc = minecraft.Minecraft.creat ()
#Allows to create a link between my Python page and my Local server
mc.postToChat ("Hello Worl")
#Allows the console to write in the chat: "Hello World"
What I want is to create the command "/ hello world"
Then use it in a secon time so that it executes the script at the top
You have an idea ?
You can't write Python scripts for Minecraft Java Edition servers
bruh..'
RecipesManagr class: https://paste.md-5.net/ojodayuzub.java
Anyone who doesn't mind helping? this is the errror: https://paste.md-5.net/zesamalozo.cs
this is line 16 in main class : getServer().getPluginManager().registerEvents(new RecipesManager(this), this);
mcpi is for Minecraft Pi edition, for a RaspberryPi. You have to learn Java to use Spigot.
However I can create houses with Python code I even create a KOTH
Whats line 84 in RecipesManager
Hey you know in spectator mode how you can right click an entity then you get their view? How do I do this in code?
That may be but ultimately Spigot is made for Java, and you won't find much support here for trying to worm Python scripts in to the server
work with PacketPlayOutCamera
is there no spigot method for this?
is there a way to check if someone has flymode enabled#
?
player.isFlying
Player#setSpectatorTarget maybe
Player#getAllowFlight() checks if they are able to fly, Player#isFlying() sees if they are flying at that present time
or getAllowFight
Something within recipe must be null 2Hex, I'm guessing it's probably not finding something from the config, so check the order, matrix and itemstack.
Thats the target idk if it would work
What do you mean? Just check if a player rightclicks an entity and then do player.setSpectatorTarget(Entity entity)
Try it. That looks to be what you're looking for.
no maven illegal
[12:22:42 INFO]: [EndereleteNew] [STDOUT] NAME: ArcaneLegend
[12:22:42 WARN]: Nag author(s): '[]' of 'EndereleteNew' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
case 2:
if (player.getAllowFlight()) {
player.setFlying(true);
player.setAllowFlight(true);
e.setCancelled(true);
} else {
player.setFlying(false);
player.setAllowFlight(false);
}
if (e.getView().getTitle().contains("Player Control's for")) {
String name1 = e.getView().getTitle().substring(31);
/*String name = e.getView().getTitle().substring(17);
name = name.substring(0, name.length() -2);
*/
Player player = Bukkit.getPlayerExact(name1);
System.out.println("NAME: " + name1);
if (player == null) {
e.getWhoClicked().sendMessage(Utilities.color(" Player is not online or the player is staff you cant do there gamemode!!"));
e.getWhoClicked().closeInventory();
e.setCancelled(true);
return;
??
the elitra just popes out#
?paste
i figured out my problem myself lmfao
it was becuz NamespacedKey.minecraft didnt use namespacedkeys
Oh alright I thought it was something else
guys getItemOnCursor().getType() always returns AIR
I use ViaVersion maybe it causes this
(my sever is 1.12)
whats the best/smoothest way to interpolate teleportation from location x to y over a certain time like in seconds or ticks
how I can disable Falling gravel sand and other?
ten seconds search
EntityChangeBlockEvent
check if the block is instanceof FallingBlock
cancel
How do I make a seperate file for my config.yml? Since I don't want people fucking it up and ruining their copy
Do I just use normal java files system
Anyone know the proper way to cast a block to a Bed? (1.16)
This seems to give me a class cast exception...
import org.bukkit.block.data.type.Bed;
Bed bed = (Bed) block.getBlockData();
java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.block.impl.CraftBed incompatible with org.bukkit.block.Block
getBlockState() prob
Custom section https://www.spigotmc.org/wiki/config-files/
thx
pog its spoonfeed code!!!!
jk
I think I tried this. Will test again.
First you find the correct interface for Bed in the Javadocs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Bed.html
So ig you will use getBlockData()
then you lookup its superinterfaces
That will tell you what you need from Block to be able to cast
teach a man to fish 🙂
thats why spoon = bad
Code looks fine that error feels a bit off though. Are you sure that's the right one?
I think he imported the wrong thing, no?
Nah didn't import the wrong one. That's the correct import I'm using
what
no
Your way is either wrong or weird
public static final Set<Material> BED = ImmutableSet.of(
Material.WHITE_BED,
Material.BLACK_BED,
Material.BLUE_BED,
Material.BROWN_BED,
Material.CYAN_BED,
Material.GRAY_BED,
Material.GREEN_BED,
Material.LIGHT_BLUE_BED,
Material.LIGHT_GRAY_BED,
Material.LIME_BED,
Material.MAGENTA_BED,
Material.ORANGE_BED,
Material.PINK_BED,
Material.PURPLE_BED,
Material.RED_BED,
Material.YELLOW_BED
);
🙂
if (Tag.BEDS.isTagged(block.getType())
Whats about block.getState().getData() ?
Tags are so you don;t nee to build your own lists
endsWith()
check if the material (convert to string if it isnt already) endsWith() "BED"
those are both ways
but what ElgarL said is better
Didn't know this existed.
?paste
dont mind me im just using this to store my code
@blazing bronze so you tried block.getState().getData() ? i guess that should work
Sec haven't had the chance to test it yet.
Had some other stuff I was fixing up.
if i wanted to maintain formatting (italic, coloring, etc.) while manipulating a string, how would i do that?
i have this default:
but after formatting i end up with this:
btw the "a player" is intentional
Just tested:
import org.bukkit.block.data.type.Bed;
Bed bed = (Bed) block.getBlockData();
Works just fine for me
Here is the quick test plugin I used: https://paste.md-5.net/etuxinumad.java
Odd this isn't working for me.
Mines on a blockBreakEvent though. Let me reorganize it a bit and see if it works then.
guys
private static MainClass plugin;and
private static JavaPlugin plugin;
are the same right?
yeah
Yes and no.
first one is better right
MainClass refers to your mainclass
yes
while JavaPlugin refers to any JavaPlugin
becuz with first onne ii cann access stuff there
like plugin.getSmthThereIDK
11111111eeeeeeeeeeQEFefWEG
with the first one you can access to methods from your main class
hey any idea
which is good
right?
yes
I can ignore 'Field can be converted to a local variable' right
customConfigFile = new File(getDataFolder(), "recipes.yml"); if (!customConfigFile.exists()) { customConfigFile.getParentFile().mkdirs(); saveResource("recipes", false);
Result of 'File.mkdirs()' is ignored, why?
Would this still be considered a list List<Map.Entry<UUID, Integer>> ent = new ArrayList<>();?
hey are fallingblock entities cached by the client in some way?
i feel like when i spawn some out of render distance, the player will eventually see them when they come into view
was curious if someone knows a way to avoid that
hmm i suppose i can cancel the spawn packet
hi everyone, i have a question, how to set custom skin to fake player
You set the skin in the PlayerDataInfo (or just Player Info if you're looking at wiki.vg) packet
customConfigFile = new File(getDataFolder(), "recipes.yml"); if (!customConfigFile.exists()) { customConfigFile.getParentFile().mkdirs(); saveResource("recipes", false);
Result of 'File.mkdirs()' is ignored, why?
because it returns a boolean value which you dont use
but you can ignore this...
any idea
if (player.getAllowFlight() == false) {
player.setFlying(true);
player.setAllowFlight(true);
e.getWhoClicked().sendMessage(player.getName() + "fly enabled");
e.setCancelled(true);
} else {
player.setFlying(false);
player.setAllowFlight(false);
e.getWhoClicked().sendMessage(player.getName() + "fly Disabled");
e.setCancelled(true);
}
create a GameProfile and put the textures of the skin in the GameProfile#getProperties map
and when i remove == false it only trys to disable thje flight
ok so simply
instead of
player.setFlying(true);
player.setAllowFlight(true);
do player.setAllowFlight(true);
player.setFlying(true);
Because youre making the player fly without them having the ability to
You can set them to flying even if they don't have the ability to.
youre only giving the player the ability to fly after you make them fly
setAllowFlight just gives them the ability to toggle it on and off themselves
?paste
paste the error there.
first setAllowFlight to true, then setFlying to true
btw you can change if(player.getAllowFlight() == false) to if(!player.getAllowFlight())
Why would you need that
still keeps trying to disable
Ohh for the displayname or lore?
No there is completely no use for that
Use normal item meta
What is different between normal items and horse armors?
Nothing.
thank you
LeatherArmorMeta mainly exists because Leather armor can also be colored
you can chose the color of a leather horser armor
No?
Which is not possible with a simple ItemMeta
Horse armor is a special type of armor that can be given to a horse to wear. Only normal horses can wear armor; donkey, mule and undead variants such as skeleton horses and zombie horses cannot be equipped with armor. Horse armor decreases damage done to horses when hit by melee attack or a ranged attack from the player or another mob. Horse ar...
How do I make it so a player cant change their yaw or pitch without it being glitchy
This is what I am using for colorable furnitures
Hmm I think you could force them in spectator view of a static entity
you know how if u wear a pumpkim it that that blur overlay thing, how can I add that while the player is being in a view of an armorstand or something
i tried making the helmet of the armorstand and the payer a pumpkin but it didnt work
Alright thank you
:D
It would be cool to have a ColorableItemMeta interface or something
mhm
because it's not really cool to have to add 3 if else
?paste
Hey!
Why is my custom config nnot working?
I followed the Wiki
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
It seems outdated and flawed, anyone knows how to do iit better
It's not outdated
If it's not, then am I misusing it
my recipes.yml (In my jar) is inside my src folder
But not with my classes
my classes are in main\java\projectshit\
It should be in the root of the jar in the same place as the plugin.yml
Also you forgot .yml in your saveResource
What
I don't need that
It's saving the file directly
and it's copying the file type as well
and everything belonging to it
thats what i think
you put all yml files in your resources folder
it was probably pre maven
I edited it
hey is the a way in the if statment to check if a player is glowing like
if ( player.getGlowing){
if (command.getName().equalsIgnoreCase("ench"))
if (p.hasPermission("ab.enchant"))
switch (args[0].toLowerCase()) {
case "sharpness":
p.getInventory().getItemInMainHand().addEnchantment(Enchantment.DAMAGE_ALL, Integer.parseInt(args[1]));
p.sendMessage("Enchanted" + args[0] + args[1]);
}
else if (args.length == 0)
p.sendMessage(ChatColor.RED + "Usage: " + ChatColor.BLUE + "/enchant <enchantment> <level>");``` Why does my command not perform anything when I run it?
isGlowing()
@eternal oxide It still does not create it
player.setglowing(true):
open your jar and make sure it exists in there
}thank you
Did you add .yml to saveResource
Did you register your command in your main class?
yes
no
._.
Do that
full file name
send us the whole class
also in plugin.yml
You're just bad at following it
?paste
wiki says custom.yml
bruh
private void createCustomConfig() {
customConfigFile = new File(getDataFolder(), "custom.yml");
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("custom.yml", false);```
from wiki
this is in your flyspeed command block
ok worked
What do I need to do to create custom permissions
oh mb
you edited
register them in your plugin.yml
I see the issue
how to enable second layer for fake player skin?
I get Index 0 out of bounds for length 0
check if args.length == 2 below
if (p.hasPermission("ab.enchant"))
ok
you should also do the commands in separate classes... and your isFloat and isInt method should be private and not public static
I'm going to have a lot of commands
yeah then you have to do a lot of classes
yeah thats cleaner and better practice
If I have different classes, I can access this method anywhere
then make for these methods a separate class , for example NumberUtils or something like this
ok
So I've been having this issue with the following snippet of code:
TextComponent mainComponent = new TextComponent(String.format(event.getFormat(), player.getDisplayName(), ""));
Where player.getDisplayName doesn't show the correct hex colors, it only uses the last letter in the hex code (since I'm pretty sure it uses § instead of ChatColor, the display name is set by EssentialsX). Is there a way to convert hex colors using § into something that a TextComponent can properly use as color? Sorry if the question is weird, I can show an in game example of the issue if needed.
huh alright. well either way the issue I'm having is that my display name is showing up as this
instead of this
safe to assume you're on the latest version?
on client + servre
yeah I'm running the latest 1.17.1 jar
Gotcha, try doing something like this
TextComponent component = new TextComponent("Test string");
component.setColor(ChatColor.of("#1565C0"));
player.spigot().sendMessage(component);
Source: https://www.spigotmc.org/threads/using-bungee-chatcolor-with-textcomponent.488979/#post-4082026
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event){
if(event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)){
System.out.println("Nether");
event.setCancelled(true);
}
}
Source https://www.spigotmc.org/threads/stand-in-a-portal-but-cancel-enter-it.282178/
then teleport elsewhere
I do this later in the file with no issues. heres the whole file https://hastebin.com/tutorixuwu.java
I'm not sure this wll make a difference, but is that name colored to begin with using the legacy style?
Also
Why are you doing that within tempcomp and not maincomponent?
Oh i found your bug smack
It is the name being colored to begin with according to this thread
Chunk#getChunkSnapshot() Capture thread-safe read-only snapshot of chunk data
that means i can call that method from another thread or that i can use that snapshot object in another thread?
tempComp is used to convert each word in the message to a TextComponent to be added to mainComponent.
Also its colored however EssentialsX colors it, as it's a nickname from that plugin.
you should be able to read it in another thread
so, just use, not call the method?
what happens if i call that method from another thread
call should be fine I'm wrong. https://www.spigotmc.org/threads/issue-with-thread-safety-while-using-bukkit-api.178393/
ok, good
if i divide any coordinate by 16, ill get the chunk coordinates, right?
mod 16 google is wrong? xD yes divide by 16
Source: https://minecraft.fandom.com/wiki/Chunk (see Finding chunk edges)
so with setdurability, the items go below 0 durability and never break
bitshift
Also works to bitshift by 4 since 2^4 is 16 Faster, but harder to read
not a stupid question
it doesn't make sense. The only other optinion is to just put it in another file
which, i might do
Breaking your logic into methods is good practice, even if they only are called once
i was thinking about putting my latters into logic
but the only check i do consistently is is.online basically
i try to keep complex code out of the plugin area
I'd do it as much as you feel necessary. following good naming conventions will make the code really easy to read and maintain
the only problem i have is i haven't commented as much as i would like to
but its all relatively simple
then i get functions like bettterwrritte(iterable<iterable<String>>, file)
with 3 t
In many times,good named methods explain more than comments do. i like both.
What does betterwrite do?
it appends to the last line of a file
//writes to last line
val index: MutableList<String> = ArrayList()
for (x in file.readLines()) {
index.add(x)
}
for (x in string)
index.add(x)
write(index, file)}
What needs to be appended?
i should just do file.readLines().toMutable().add(x)
honestly a lot of programmers have different style. I'm not sure what language that is or what tools it has, but in Java, I would just name that method appendToFile.
//writes to last line
val readfile : MutableList<String> = file.readLines().toMutableList()
for (x in string){
readfile.add(x)
}
write(readfile, file)}
what does Vector#toBlockVector do?
i didn't do that because it doesn't do lists or something
just round its values?
for some reason i thought i could do a better
job than appendToFile
and i trust myself
it had something to with \n not working how i wanted it to and sometimes messing up
hm?
no?
whats the easiest library to have GUI's that dynamically adjust? (As in they change content data whilst you are looking into them)
probably one you program yourself
I doubt that
its the most lightweight implementation and the one most suited to your needs, and you understand how it works
I have never even worked with GUI's before
working in minecraft isn't like working in Qt5
great excuse to learn something in'it
I'm honestly not sure, but the javadocs give me the impression it's creating a vector out of the position which could be used to make moving things across far distances far easier/less intensive?
The method exists ? I'd try to avoid reinventing the wheel unless it's a necessity
mutableListOf() > ArrayList() (:
https://www.spigotmc.org/resources/smartinvs-advanced-inventory-api.42835/ is very easy to use and capable of dynamic adjusting through the update method and relatively compatible with 1.17 (tested on their v1.3.0), but I'm not sure of any up to date API's for inventories
https://www.spigotmc.org/resources/if-inventory-framework.57216/ haven't tried this one before but it looks pretty interesting, easy to use, and 1.17 tested*
thank you
anyone got some good resources for getting started?
How do I call those? Like I have added the example into a class file now but how do I call it to a player?
how do i make it so that the distance required for a fishing rod to unhook is shorter?
?paste
i==1 works
i==2 the item apears even if the player dont have perms
and none apeAR WHEN OP
With Java spigot or programming or all?
which item? glow?
yes
only glow apears when op and realy i dont want that i only want it to apear if they have perms op or not
all the others work like that but glow
plugin development for 1.17
not sure what the difference is between java and spigot programming
Can you find the docs? you wnana get instances of the inventory and then you can called the .open method dform the SmartInventory reference
and how do I init an inventory provider?
Gotcha,
Java being the language, spigot being the API.
Here's the Javadocs: https://hub.spigotmc.org/javadocs/bukkit/
Here's a little getting-started on spigot: https://www.spigotmc.org/wiki/spigot-plugin-development/
package index
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Caused by: java.lang.IllegalStateException: The manager of the SmartInventory.Builder must be set, or the SmartInvs should be loaded as a plugin.
I keep getting that, but I have it loaded as a plugin
SmartInventory.~~getBuilder ~~ SmartInventory.builder() check that method out
thanks
yeah i tried but its still giving me the error
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
//xvar = !xvar;
SmartInventory INVENTORY = SmartInventory.builder()
.id("customInventory")
.provider(new InventoryProvider() {
@Override
public void init(Player player, InventoryContents inventoryContents) {
}
@Override
public void update(Player player, InventoryContents inventoryContents) {
}
})
.size(4, 9)
.title(ChatColor.RED + "Unclosable inventory!")
.closeable(false)
.build();
INVENTORY.open((Player)sender);
return true;
}
how do i unhook a fishing rod from an entity?
The issue there is your perm is defaulting to op then
In your plugin.yml make the default false then by default nobody has the permission
I haven't tried this before but I THINK you could kill the fishing hook entity? So maybe listen for ProjectileHitEvent to get the fishing hook entity.
More info: https://www.spigotmc.org/threads/can-you-remove-the-players-fishing-rod.309918/
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class AtlasCore extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("<!> AtlasHost has loaded <!>");
getServer().getPluginManager().registerEvents(listener:this, plugin:this);
}```
i seem to be missing something?
(listener:this, plugin:this); gets highlighted in red
So I want to code this command where when a player runs a command, a book gui pops up to their screen, with text and other pages. They dont get a book though, a gui just opens after they run the command. How could I code this? I googled it, and couldn't find anything. Even looked on YouTube and couln't find anything.
You need to give the player a book and quill and then open it for them
Yea ik it’s hacky but that’s how it’s done
oh
I think that calling Player.openBook on the new versions does that natively
From what I remember reading spigot code
Oo I’m outdated perhaps lol
how do you include a variable in a string?
thnx!
?paste
how to use sync methods in async events?
call a sync scheduler
Hello, I think I found a bug with spigot 1.17
"max dura: " + item.getType().getMaxDurability()
This prints 0 for a diamond_sword
like this?
I generally just call runTask but that works
BukkitScheduler#runTask
can you give me an example of this?
anyone that can spot the s p a g h e t t i in my code
https://github.com/2Hex/OnceUnCraftable
why does this exist
is there a faster way of testing your plugin on a local server?
make the IDE compile it directly to the plugins folder
dont i need to unload the plugin first?
Looks ugly
Re-use variables
You can make it delete and paste into the plugins folder
then just restart the server
and test
If you're extra fancy, make it replace the plugin and automatically restart
do you know how to do that?
I don't really test locally so just google it
where can i set the compilers output?
IDE likely
i can't do that
i need the entity to be alive
FishingHook is an entity
oh yea that
yea i tried fishinghook.remove but it doesn't work
it doesn't unhook
the next time they rihgt licck they're fishing rod it messes up
how
reuse code
All I see is event.getBlock everywhere
and getPlayer
Start your listener with the following:
Player player = event.getPlayer();
Block block = event.getBlock();
Material blockType = block.getType();
World world = block.getWorld();
BlockState blockState = block.getState();
and work with those variables
You can also call
private final Random random = ThreadLocalRandom.current(); at the top of the class to simplify a bit
And name your variables properly
All I see is lazy copypaste
why are you calling getInt twice for the same path?
just reuse the variable
Re-use all the variables
Condition 'chance == 0' is always 'false'
That's because your random already cleared it
Also do the cheapest calls first
Like checking for entity types
does that really make my code look better
It makes it perform better for literally free
But reusing variables does make your code look a lot better
Naming them correctly does too
aha ok
Also IDK why your IDE isn't screaming at you
But when doing toLowerCase, toUpperCase, pass in a Locale
Condition 'e.getPlayer().getInventory().getItemInMainHand() == null' is always 'false'
do i remove this
public void onPlayerChat(PlayerChatEvent e) {
Player player = e.getPlayer();
player.sendMessage("Hi");
}``` am i doing this wrong?
Although it shouldn't do in most cases, it can give issues when translating weird text
Arabic symbols and things like that
It is correct
Did you register the listener?
by register do you mean this?
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;```
Probably
Bukkit.getPluginManager().registerEvents
do i remove this Condition 'e.getPlayer().getInventory().getItemInMainHand() == null' is always 'false'
check if Material == air
ok
I believe it will be returned as air as it's tagged with @NotNull
yes
ok
.
i wanna check if the config i set to 0
or wait
does that
if (!(ThreadLocalRandom.current().nextInt(100) < chance)) return;
right
ik i could use > but whatever
yo, i have some questions about LibsDisguises if anyone is familiar with the api
i asked these in the MythicCraft discord but it is a little less active than this server 😛
this?
this is obviously the class you want
😄
i am going to copy-paste part of something I already wrote if that's alright
bit easier to read cause i’m on mobile haha
no worries, it isn't actually code :P
Basically
I am trying to serialize a Disguise object
For now we can ignore the PlayerDisguise as i have another method which handles those
DisguiseUtilities includes a getGson() method which allows me to serialize the disguise, but deserializing using gson.fromJson(disg, Disguise.class) throws an exception
In essence... it serializes just fine, but deserialization is proving to be an issue
can you call the constructor?
of the Disguise?
hmmmmmm
there is a new Disguise() which is an anonymous inner type
if that's what you mean
apologies
i am still familiarizing
i’m not too sure - never used this plugin before
so don’t really know what to look for tbh
ahhh understandable
what is the event for when an egg breaks after hitting a wall
scroll down to the custom section
thanks alot
hey sorry to ask for code
im wondering how i can have like
logs for stuff in-game? obviously i store a ton of stuff in a log file
but im wondering how i can get something like...
(a player or somethinglike that types /logs)
and they get text like
-- Server Logs --
1.
2.
3.
4.
etc.
its just a loop... im just not sure the exact values of that loop
for (everything in the config) {
print the config
}
but I recommend using a database if you're going to be storing ALOT of data
@quaint mantle
Might seem stupid but Block#getDrops is returning an empty collection
Is there any workaround or something?
This might be a bit over the top of my head, but I am trying to set the outer layer of a players skin to the outer layer of someone else's skin. Is that even remotely possible with spigot?
You'd have to make a custom skin, upload it to mineskin, get the data and whatever and send it to the player
lots of work
aha... but theoretically it could work?
with a ton of packet hackery yes
definitely possible
Alright... I'm willing to take on the challenge... but where would I even start to do that :P
Editing the skin
that's the goal not the start xd
Like
first learn how skins work in MC
getting the skin data and adding the overlay to the png
then posting a http request to mineskin and getting the result
then sending the result
Skin data is just some fancy base64
aha I see... time to do lots of research :)
i already have that all good and setup, im just wondering how i can make pages of text basically
sorry i guess i just didnt know how else to word it
i.e; /lookup somethinghereidk 8
and get the 8th page of logs
I'm really not good with gradle/maven, how can I fix the class loading to resolve this?
java.lang.LinkageError: loader constraint violation: when resolving method 'javassist.d javassist.f.a(javassist.d)' the class loader 'EliteMobs.jar' @77a2c467 of the current class, com/magmaguy/elitemobs/EliteMobsL10, and the class loader 'LuckPerms-Bukkit-5.3.53.jar' @5f295a1c for the method's defining class, javassist/f, have different Class objects for the type javassist/d used in the signature (com.magmaguy.elitemobs.EliteMobsL10 is in unnamed module of loader 'EliteMobs.jar' @77a2c467, parent loader 'app'; javassist.f is in unnamed module of loader 'LuckPerms-Bukkit-5.3.53.jar' @5f295a1c, parent loader 'app')
is this something a relocation would fix? again, I absolutely suck at this side of things
If I have a BukkitScheduler Task and set the delay between each execution to a variable, will it change the delay whenever the variable changes or will it stay the same?
I think java code is executed step by step
so when it will read for example runTaskLater(duration)
it will be the value of duration at the moment
I mean if I change the 1L at the bottom to say a public integer variable, and then modify that variable with a command, will it change the delay or not?
Because I think it wont
no, once you create the runnable its timer is set
ok thank you
you can change the timer for any new runnables
so I just cancel it and start it again with the command
why do you need to change the timer?
Will the spigot api work on bukkit?
what?
Does anyone still make plugins just for bukkit
what minecraft version was last bukkit
Out of question how come people declare scheduler?
as shown here
scheduler = Bukkit.getScheduler();
why not just
Bukkit.getScheduler().runTaskTimer```
1.7
is there a spigot 1.7 ?
Pretty sure Bukkit supports 1.17
dunno, spigot docs says so
Seems kinda redundant
yea
Why do you want 1.7?
You said 1.7 lmao
its not like you're declaring is a new instance or anything... its always getting the same scheduler...
in order to use scheduler#cancelTask() out of that scheduler
yes, that was when all teh Bukkit devs stopped work on Bukkit
You can sort plugins by 1.17 on the Bukkit forums though 🤔
yes, its an API that is now updated and maintained by Spigot
Ah
But Bukkit itself was stopped at 1.7
xsetval:
usage: "xsetval.usage"
not-enough-arguments: "xsetval.not-enough-arguments"
too-many-arguments: "xsetval.too-many-arguments"
must-be-integer: "xsetval.must-be-integer"
too-high: "xsetval.too-high"
invalid-item: "xsetval.invalid-item"
does-not-exist: "xsetval.does-not-exist"
successful: "xsetval.successful (Item: %item%, Value: %value%)" # %item%, %value%
xsetvariance:
usage: "xsetvariance.usage"
not-enough-arguments: "xsetvariance.not-enough-arguments"
too-many-arguments: "xsetvariance.too-many-arguments"
must-be-double: "xsetvariance.must-be-double"
not-zero: "xsetvariance.not-zero"
too-high: "xsetvariance.too-high"
invalid-item: "xsetvariance.invalid-item"
does-not-exist: "xsetvariance.does-not-exist"
successful: "xsetvariance.successful (Item: %item%, Variance: %variance%)" # %item%, %variance%
xvartoggle:
on: "xvartoggle.on"
off: "xvartoggle.off"
sender.sendMessage(messages_prefix + config.getString("messages.xvartoggle.off").replace("&", "§"));
Why do I get a NullPointerException from this?
every other getString works fine except the xvartoggle category
how to make the experience decrease every second?
for example: the full scale of experience and you need to remove the experience a little bit to 0
scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(this, () -> {
codetodecreaseexperience();
}, 0L , 20L);
you may find on and off are reserved keywords. Just a quick guess
it worked before
ok then your code is broken 🙂
thank you very much. I will try
but where .-.
because the return value of "org.bukkit.configuration.file.FileConfiguration.getString(String)" is null
at me.konstanius.konstanius.commands.xvartoggle.onCommand(xvartoggle.java:23) ~[?:?]
prefix works fine in every other message
wait
ok now I look like a clown
Then check teh actual file you are accessing is fully upto date and those entries are not missing
Seems like I misremembered that part
it works after I changed the names
Thanks for the tip!
np, I had a feeling they were
bukkit?
spigot > bukkit
ZeroDay, Astolfo, Moon, Azura, and Tenacity
apparently these clients
can bypass AAC
are the checks neutralized from the hax devs lookin at AAC source code?
im just wondering how i can make pages of text.. something like
text here or something, and then:
- text here
- other text
- more text
- even more text
- etc.
If I develop in 1.8 pure API, no NMS, will I remain forward compatible with later versions?
Cached, shorter and cleaner
No guarantee but probably
Im using packet to spawn client side entity, but how can i get a free entityid?
if i spawn an entity with a id that already exist in the client, the existed entity will be removed, right?
Would you know what it may depend on for you not to be too sure?
Or are you just intuitively not sure, because same here
Feels like there should be caveats
Math.ceil(Math.random() * 1000) + 2000;
Yes for instance Inventory#getTitle was yeeted
How can you kill all armor stands?
Steal LuckPerms?
how am i getting a NPE on this line?
if(item.getType() == Material.AIR || item == null) continue;
item == null should be before anything else
There’s a lot of plugins which prompt an ascii banner on enable
... They didn't invent it
i realized that right before you said that
lol
Wouldn’t call it stealing
^
ok, i will try it
world.getEntities().stream().filter(entity-> entity instanceof ArmorStand).forEach(entity -> entity.remove());
or something like that
figlet
btw @ivory sleet I finally got what you said about my gitlab (CraftInventory may be the problem) and the CraftInventory you saw was actually a GUI and what's causing my problem is giving a list of items
Yeah
But because I want to generate dozens of random numbers, I feel that random numbers may still repeat
random can alwasy repeat, thats random
It may be better to record the existing ID of the client to the server
if you want a never repeating and have a limit on teh amount of numbers you can simply ensure you only pick new numbers
ah entity id conflicts. Yeah good luck with that
why does this not work?!?
Isn’t there a synchronous id instance for that
Idk might be nms
But definitely exists one
See if you can trace some methods and it should be all good
ah this make sense. I just need to keep an growing integer.
what exactly does not work
both the kickPlayer and broadcastMessage are never executed
heres some context
print out his level so you can see if his level is == 1
What's the alternative to the PersistentDataContainer in versions before it was added
nbt
CustomTagContainer or smtng iirc
Like the NBT API? It says that can only work with vanilla tags in entities
yes it is 1
errors in console?
only the experience going below 0
because they arent kicked
oh wait
was a config file error
did u solve it?