#help-development
1 messages · Page 1564 of 1
I mean
it seems better, since its out of the way, and not adding junk to your onenable
but its preference
class B{public static void main(String[]a){for(int i=99;i>=0;i--){System.out.println((((i==0?" No more "+"bottles ":""+(i==1?"- bottle ":"- bottles ")))+"of beer on the wall,"+(i==0?" no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.":"- bottle"+(i!=1?"s ":" ")+"of beer.\nTake one down and pass it around,"+(i-1==0?" no more ":"0 ")+(i-1==1?"bottle ":"bottles ")+"of beer on the wall.\n")).replace("0"," "+(i-1)).replace("-"," "+i).substring(1));}}}``` anyone know how to make this shorter?
regex maybe
is the aim to be 1 line?
but .replace can take regex
yes to save characters
public static void main(String[]a){for(int i=99;i>=0;i--){System.out.println(((i==0?" No more bottles ":"- bottle! ")+"of beer on the wall,"+(i==0?" no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.":" - bottle! "+"of beer.\nTake one down and pass it around,"+(i-1==0?" no more ":" $ ")+"bottle@ of beer on the wall.\n")).replace("-",""+i).replace("$",""+(i-1)).replace("@",i-1==1?"":"s").replace("!",i==1?"":"s"));}}```
bout 10 chars shorter lol
could probs cut down even more buy grouping common words
https://www.spigotmc.org/threads/how-do-i-report-a-bukkit-bug-to-the-jira.515202/ I'm getting weird behaviour when I log into the spigot Jira, does anyone know what to do here?
Guys, How to set A Permission for a Player , and Set him a Custom NickName
Luckperms the way to go
you probably put the wrong command
make sure your command is also defined in the plugin.yml file
i wrote this interpreter from scratch
how to make gui
you make gui
no
yes
Does anyone know how I can get player Nicks to appear above their head after using /nick? It appears in chat and tab but not above their head? ( Note : Ranks do show, just not nicks )
player.openInventory(yourInventory);
Cooooool
I think packets but idk
I made it work using TAB
hello, I have a problem : when I send a message to a player all § are replaced by an  so how can I solve this (I pick this message from a JSON file encoded in UTF-8)
try using &
That means your file, or how you are saving/loading is not UTF-8
If I want to download a plugin from spigotmc.org, I can do https://www.spigotmc.org/resources/<resource>/download?version=<id>, but I don't know how to translate versions to version id's
Why does spawning a particle at a Location fine but teleporting a Player to the same location variable puts them at a weird place
I can archive this with spiget.org
Location loc = user.getEyeLocation();
Vector dir = loc.getDirection();
RayTraceResult result = user.getWorld().rayTraceBlocks(loc, dir, dist, FluidCollisionMode.NEVER, false);
Location end;
if(result != null) {
end = result.getHitBlock().getRelative(result.getHitBlockFace(),1).getLocation();
}
else {
end = loc.clone().add(dir.multiply(dist));
}
user.teleport(end.toCenterLocation(), PlayerTeleportEvent.TeleportCause.COMMAND); //This doesn't work
user.getWorld().spawnParticle(Particle.FLAME,end.toCenterLocation(),0); // This does
No
It teleports to a weird location
if I do this
user.getWorld().spawnParticle(Particle.FLAME,end,0);
THe particle spawns at the right location
But if I put user.teleport before that
or after
It goes to a strange location
Hmmm, weird
Yeah
Hello is there any item drop event? (But not PlayerItemDropEvent , Entity... BlockDrop..)
Like when player q out an item?
nopp
Look for super classes
okay!
for example, When you dig up bamboo, the top falls.
That's blockDrop
^^
I looked and there is not a superclass u can use
There must be an event listener for it
gl
HMmmmm
I found blockdestory event
But I don't know where to run this event.
xD
Look when it gets run
sorry, I'm not good at github
how to look that?
If not open a jira issue I guess
thanks your find, but I meant, where to run this event?
You don;t run events normally, you listen for them
manager.callEvent(new BlockDestoryEvent)
I'm making the event cause I'm not using paper 😄
using paper or not makes no sense
Hi!
Is there any way to know if a block has already been destroyed ?
Thanks
nvm
wdym?
in specific location?
to make a jobs plugin, to prevent players to break, place forever to cheat with exp system
hmmmm So you want me to place/break just once on one coordinate at one location, right?
Then use PersistantDataContainer 😄
I high recommanded you looking codedred's tutorial
np
I learned that from that video
?pdc
Or that
but it's only working for 1.13+ and i'm actually using 1.12.2
Explain fully what you are trying to do
here is the explaination
@eternal oxide
?
ah
Not very clear
What block are they placing/breaking to get XP?
You should not give exp for breaking blocks that return themselves, like sand, dirt, gravel
Well... my server has an xp server.
To make it simple, when you break a block, you win xp. When you have more than 1500 Xp, you're level 2.
The problem is that if you find a iron ore, and that you break and replace the block forever, you're winning XP with the same block.. so you're cheating with XP system.
And i try to prevent that
Your simplest method would to be to make those blocks drop iron instead of ore
or, you could set a flag on those blocks once mined and prevent them being placed
the simplest though is to have all ores drop ingots instead of ores
so that coal still have an utility, I would like to use this method.
So how can i proceed
?
coal doesn;t drop a block, it drops coal
as you are on 1.12 you have no PDC, so you are either going to have to use NBTAPI or go the drop ingots route
yep.. but i'm not talking about xp, i say that if you make drop ingots instead of ores with iron, gold... coal wouldn't have any utility and i don't wan't to do that
coal give exp when broken
yes... but it causes problems with iron or gold for ex.
Ok.. i'm going to use that
How do I get Server returned HTTP response code: 503 for URL: https://spigotmc.org/... if I don't use this in my program? I tried with search in IntelliJ to find this url, but I can't find it
if you set an NBT tag on the ItemStracks as they drop you can then check for those tags when they try to place a block
and will the tag will stay on the block if the server stops ?
The tag is put on the ItemStack, and yes it persists
on another note why does this not send anything?
Set<String> mb = configuration.getConfigurationSection("").getKeys(false);
//Also tried configuration.getKeys(false);
//Same result.
//The config DOES contain keys and values
sender.sendMessage(mb.toArray(new String[mb.size()]));```
same result
is there anything in your configuration?
yes
Yeah, not going to be able to help with just that info
because this works:
configuration.getStringList("keys");
yes you can set teh width of the ray
it is a ray, it expands in both axis, its a radius
yeah...
I get this error Server returned HTTP response code: 503 for URL: https://spigotmc.org/resources/85346/download?version=407160 while I am trying to download from this url: fileDownloader.downloadAndUnzip("https://api.spiget.org/v2/resources/85346/versions/" + versionID + "/download", new File("TvheeAPI-" + versionNumber), download.getName());, as the stacktrace prints, this is the line with the problem
Access denied
Yes I know, but I am downloading from another url
You can't automate file download from spigot
I literary changed it, but the program still downloads files
Spiget is just a wrapper for spigotmc
You need to host the file yourself
No because I can download it form spiget, but the problem is that I get an error from an url I am not downloading from
No they don't, I have tried in my browser
My guy please just listen
Try yourself downloading from this url https://api.spiget.org/v2/resources/85346/versions/364426/download
Just an example btw
You cannot automate the download from spigotmc
final ReadableByteChannel channel;
connection = (HttpURLConnection) new URL("https://api.spiget.org/v2/resources/" + resourceId + "/download").openConnection();
connection.setRequestProperty("User-Agent", TvheeAPIPlugin.getInstance().getDescription().getPluginName());
channel = Channels.newChannel(connection.getInputStream());
final String path = DebugMessage.class.getProtectionDomain().getCodeSource().getLocation().getPath();
final String decodedPath = URLDecoder.decode(path, StandardCharsets.UTF_8);
final CustomFile thisJarFile = new CustomFile(decodedPath);
final CustomFile destination = new CustomFile(thisJarFile.getParentFile(), TvheeAPIPlugin.getInstance().getDescription().getPluginName() + " V" + newVersion + ".jar");
final FileOutputStream output = new FileOutputStream(destination);
output.getChannel().transferFrom(channel, 0, Long.MAX_VALUE);
output.flush();
output.close();
And why does this code success then?
If it works then why are you here
Because the error sais I am using another URL
Read carefully
I never used https://spigotmc.org/resources/85346/download?version=407160 anywhere in my program
F12
Ah I will see
I cannot check because my school disabled it
I can't see the download link, it just downloads if I click on F12
ok.
How would look a block that isn't on the list
?
https://www.redirect-checker.org/index.php sais
Result
https://api.spiget.org/v2/resources/85346/versions/364426/download
302 Found
https://spigotmc.org/resources/85346/download?version=364426
503 Service Temporarily Unavailable
you add the tag to any broken block (ItemStack) you don't want them to place again. Then in the block place event you check for the tag, if you find it, cancel the event
Yep so it redirects just like I said above
Now you're going to have to upload the jar yourself
You can use github for this
Yes I am using it already
But I didn't upload until version 1.6
But what will the url be then?
but how to check if it had already been placed. If I add a boolean to true, should i check if it's equal to false ?
okk, going to see by myself. thanks for help
?learnjava 
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.CraftOfflinePlayer cannot be cast to class org.bukkit.entity.Player (org.bukkit.craftbukkit.v1_17_R1.CraftOfflinePlayer and org.bukkit.entity.Player are in unnamed module of loader 'app')
Player p1 = (Player) Bukkit.getOfflinePlayer(player);```
SINCE WHEN?!
Just like all Animals aren’t Pigs
it is a player
OfflinePlayer is not a Player necessarily
A Player will always be an OfflinePlayer
Not the other way around
Use isOnline on the offline player and then use getPlayer
yep... i'm a beginer, i started java 3 months ago
Same honestly, only so much I still have to learn
Or if you know already that the player is online use Bukkit.getPlayer instead of getOfflinePlayer
You don't
Manipulate in terms of?
If you really need to you will have to modify their player data file
i see
The server does not keep every player in ram. Only the ones that are online
well its not that important
You can manipulate offline players statistics if that’s what you want to do
I use a Database for offlinePlayers
eh fair enough its just annoying right now
i just seemed to remember that that code worked before
so im a bit pissed
as in
it fails if i give it my name
I tried using my plugin on other version then 1.17 and it doesn't work at all, the console says it's loaded but commands don't work and I get some other error... What do I need to do?
read your latest.log for errors
it's some sqlite database errors, but that doesn't have anything to do with my commands not working at all
What api version did you set in your plugin.yml?
when testing 1.8.8 I set 1.8.8, I also changed it in the pom.xml and I used java 8 for compiling
really?
anything below that is ignored
but does the plugin also work in 1.8?
depends on your plugin
right
Ye
Does it matter if I use java 8 or 16?
no
oh ok
well..
so long as you set teh version to build for
afaik 1.8 is not able to use java 16
You can force it to run :)
just set the target version and you should be good
There's a option and for some reason on 1.8 If you turn it off it lets me use java 11 on it probs will work with java 16 too but I haven't tried yet
I got this when trying it on my 1.17 server https://paste.md-5.net/dibunacugi.sql
1.13 not 1.13.2
its his api version thats wrong
do I change it both in plugin yml and pom xml?
ok
Would there be any way to make a gui that looks like the creative inventory and be openable in other gamemodes
Basically open the creative inventory in survival with custom listeners
so i need to make an entity which can be flying. i would like to be able to make it fly from point a to point b without flying through stuff and through unloaded chunks. what is the best way to do this?
there is no easy way as far as i know to make an ai for ideally an armour stand as then i could put blocks on the head to make a custom model
I did this and plugins seems to enable I get some errors in console, but my commands again don't work at all
fix the errors
The erros don't appear if I use 1.17 server
I am not aware of a custom nav-mesh kinda lib to make the navigation manually though
yes, fix the errors if you want to support lower versions
how can i create an Itemstack and the Itemstack is the item on the head of my armorstand???
new ItemStack?
ok but i dont know to set the item stack for the item the armor stand have on head
cast your entity to ArmorStand
Hey, is there a method to change a citizen's npc's gamemode?
you can access its methods from there
like this????? : Entity ArmorStand = e.getEntity().getPassengers().get(0);
(ArmorStand) e.getEntity().getPassengers().get(0);
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
ikr
still write my source code comments and documentation in british english out of pure spite
pls helpp
🚫 🥄
i am sure if you simply searched up the citizens docs you will find your answer there
cant find it
you have to be joking right
idk
I found it in like 15 seconds
I mean, I can't find a method to change the gamemode in the documentation
never used citizens before, but i am sure this has the exact same effect you want https://jd.citizensnpcs.co/
whoops
NPC#setProtected
will try it out
Hello i just made a new 1.17.1 plugin and it doesn't want to load (i have coded before)
here is the log https://hastebin.com/iwubahonuv.sql
at me.pixelwarp.ducksmp.Enchantments.<clinit>(Enchantments.java:11) ~[?:?]
private static Enchantment InstantKill = new InstantKillEnchantment(new NamespacedKey(plugin, "instant_kill_enchantment"));
plugin is null
If you have coded before that error isn't hard to figure out
i know
then why ask
.
i init plugin before loading other stuff
you're trying to reference plugin in a field, which means plugin must be set
if it is set in the constructor then it is not set in time
the fields are initialzied first
initialized
I'm having issues with this set/get items code. Setting items always works fine. Getting only works the first time after a restart, then it always says the 'list' is null. I checked if the provided path always matches, and it does.
reload the config before using it
Why is that necessary? The config should be the same as the file, after calling saveConfig?
setConfig sets whatever is in memory to config, but your config is not properly loaded when your plugin starts up
i'm not sure what your getList method does, but bukkits get list will never return null
The problem occurs when the plugin is already running. The first time I get the items after a restart it works fine, the config is always loaded at start.
have you inspected your config.yml after a save?
saveConfig is a void
the code wouldn't compile if it was void
true ig they're using a custom method 🤷
After saving, items are visible in the list. Getting returns nothing, while I try to access the correct path.
getList comes from MemorySection
how do i fix it then this is my main https://hastebin.com/tequpuhuvu.java
anoder question, I've made a citizen npc equip armour, but it doesn't seem to have any effect on the protection of the npc, purely cosmetic. How can I fix this?
try adding flags and see which statement in the getItems method is false
wrong class
enchantments class then ?
maybe ask citizens?
I already debugged the code. getList returns null.
enchantments class: https://hastebin.com/elovonumez.java
move the initialization of instantkill and plugin into your constructor, and pass the plugin through the constructor
why reason why the entire enchantments class is static?
so it doesnt init InstantKill more times than 1
the enchantment
but what is the difference between putting the plugin in constructors & having a static get variable for it ?
does not need to be static to do that
ok
your problem is because you're trying to call getInstantKill from Enchantments when your main class is constructed by spigot, but your plugin has not been set yet since onEnable hasn't been called, therefore plugin in Enchantments is set to null causing the error on the next line
Seeing how that's solved how do i check best if an input was a number? as in part of the command
do I just do Integer.parseInt() and catch the exception if there's any?
is the value set by your set method actually a list?
yes, or use one of the numerous number utils methods provided by apache commons
but that is the easiest way
It works when calling reloadConfig before getList. So I guess it is a list yes.
i do not remember why, but lists specifically resolve to null when trying to call them before calling reloadConfig
lmb i don't understand i am calling "plugin = this" in my main class before using the other classes
so shouldnt it be set before the other classes are trying to use it ?
that plugin field is only set when onEnable is called, but spigot needs to construct your class first before calling onEnable, and it's during that process where your fields are initialized
oh
Never experienced that before. Is calling reloadConfig in my saveConfig, after save(file), a good fix? Or should I just do it after saving lists?
pvpmaster r u using a static singleton?
can i like delay when the fields init like maybe "TimeUnit.SECONDS.sleep(10)" ?
i simply just call reloadConfig in my onenable and don't run into issues after that
no
Never sleep on the main thread
i think you're not understanding
logging
um
I think?
I already do this. So that's not an option ;/
i am just trying to create enchantments but i need to set the enchantment.class field acceptingNew accessible to true but then in the same method i call "Enchant.registerEnchantment(Enchantments.getInstantKill())" but the plugin is null
Just sounds like you got a trouble with initialization order here
^
i also think so but idk where
in onEnable you first set the field accessible and then set it to true, then register?
Guys how to make when I click item in GUI , it sends message
Code runs linearly unless you tell it not to
@sand rune handle InvenotryClickEvent
Then @ivory sleet
Don't sleep on the main thread
Also send the loadEnchantments method
You will literally have the entire server wait
@ivory sleet
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
You're calling Enchantments.getInstantKill to early
where do i call it then
Call it after you set the plugin
i was setting the variable over on enable i was supossed to set it in onEnable under plugin = this;
@unreal quartz I found a solution! Just as you asked me, is the thing I'm saving a list. I don't think it was in the config. It gets parsed after saving to the file, but stays an array in memory. Saving it as a list solved my issue!
nice
Thanks for helping me out 🙂
no prlblem
hey guys, I've got a problem
I have a custom tab menu, but when a player joins my server they are still visible
Ok that looks fantastic tho
thanks 😄
took me a while
I have an player join event which runs the function which displays the tab menu
I still need to add a header and footer
mkay
yep, that has fixed it
thanks 🙂
annoyingly tho the fake player doesn't copy over my skin's mask
Looks great :)
Looking good :)
Will you make it in to an API?
is there absolutely no way to move a page
uhhh, I wasn't planning to
:sadge:
you're welcome to see/have the code if you want tho
cuz uhh this is (mildly) annoying lol
it's basically all the same stuff as making npcs
I'd love to see it
I always use Citizens for NPCs
Is queuing static method calls necesarry when writing to a database?
what do you mean by that
If 2 players leave at once the server then the saveData method I have will be called at the same time twice trying to write data to the database and probably giving me an error from one of the methods that the database is locked
you do not need to synchronise it yourself, that is managed by the database
ok then I just got to test it to make sure 🙂
databases are designed for this purpose
ok
I've been using npc.getTrait(Equipment.class).set(Equipment.EquipmentSlot.BOOTS, new ItemStack(Material.NETHERITE_BOOTS, 1)); to equip armour onto npcs, but it seems to be purely cosmetic, it seems to have no effect on the actual protection of the NPC. how can I fix this, or is there another method to actually set the resistance of the NPC
(yes, Ive tried asking the Citizen's discord)
It should affect protection if I remember correctly
Hey there! How can I get the output of an item in furnace?
How can I send each line on a new line? using \n is ugly and creates this ugly effect
lines.forEach(string -> //player.sendMessage(string));
I tried that but it gave me an error
i'll try again with what you have provided
Because getPlayerCount isn't finished counting yet I think
🤷 can't help you there lol
Can't stand using intellij
why do I say string?
its just a variable name. Name it what ever
yup
Remove the // to lol
You can use anything. Its your variable name
also you don't toString a completable future
ofc
that is not how you grab the resulting value from it
I know just playing with it cause it's giving me issues
what kind of error?
completeable future not complete
Hello, I've set a new version in the plugin.yml file, but when the plugin is loaded, the old version is still displayed.
CompletableFuture#thenApply will run the code inside that lambda once the future completes
might also use CompletableFuture#whenComplete
public CompletableFuture<Integer> getPlayerCount(String serverName) {
Player player = getFirstPlayer();
CompletableFuture<Integer> future = new CompletableFuture<>();
synchronized (callbackMap) {
callbackMap.compute("PlayerCount-" + serverName, this.computeQueueValue(future));
}
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("PlayerCount");
output.writeUTF(serverName);
player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
return future;
}
was sent this extreamly shit code by a friend. Going to rewrite it all
you can use CompletableFuture#get, but that will retrieve it right there and then on that thread
it's given me so many issues over the years
sometimes it works
sometimes not
so idk
just gonna do it the "intended" way
or that's what i'm planning
synchronized 😬
but last time I tried to fix it then it took me 13 hours with no end result
sooooo
yeah
unless it's easy i'm giving up on it
It’s hard to tell from that snippet solely
it's all like that
?
?paste
But btw while we’re going I suggest using Lock over synchronized, especially when it comes to completablefuture
ik that's why i'm rewriting it. Got sent it by a friend and been using it on and off but it's given me too many issues. Sometimes it works and sometimes not
well...
havent bothered doing something till now
any idea? 🙂
wdym
What do you need explanations about?
what is the "output of an item in a furnace"
FurnaceInventory.getResult()
let's say I give you iron ore
I want to know what would be the ouput of this iron ore if it was burned in a furnace
so here an iron ingot
How could I simulate players joining and leaving the server to test my plugin?
How does that work?
rather hard to do reliably with a plugin
the most common way is to simply open up anoter minecraft
I need 10+ players
You explained differently then what I thought you were asking. So this doesn't answer your question
I recommend using Mineflayer with an offline mode server for testing
alright sorry!
because you want something to work with 10+ players doesnt mean you need that many to test the mechanics
Bukkit.getRecipesFor(ItemStack) and check for furnace recipes and get the result.
debatable
great thank you!
a console client?
Javascript library for bots
This is what I used to do :
ok
private ItemStack furnace(ItemStack item) {
if (item == null)
return null; // Because item can be null
while (recipeIterator.hasNext()) {
Recipe recipe = recipeIterator.next();
if (!(recipe instanceof CookingRecipe))
continue;
CookingRecipe<?> recipe1 = (CookingRecipe<?>) recipe;
if (recipe1.getInputChoice().test(item))
return new ItemStack(recipe.getResult().getType(), item.getAmount());
}
return null; // return result furnace :)
}```
Code it to what you need
but I needed reflection
You don't just check if the server version is above legacy versions
well it sucks I never used java script
why do you need 10 in the first place?
private ItemStack furnace(ItemStack item) {
if (item == null)
return null; // Because item can be null
for (Recipe recipe: Bukkit.getRecipesFor(item)) {
if (!(recipe instanceof CookingRecipe<?> cookingRecipe))
continue;
if (cookingRecipe.getInputChoice().test(item))
return new ItemStack(recipe.getResult().getType(), item.getAmount());
}
return null; // return result furnace :)
}```
even when i make minigames the minimum is 6 players however nothing stopping me to test with 3
this should do the job!
I don't really want to support those legacy version, I'm going to drop the support for them
what do you think about this one? @stone sinew
If the version is not 1.13 you can use choice.
great
It's the best you're going to get if you don't have a pc good enough to run 10 instances of Minecraft
Javascript isn't very hard to use either
Hello, I have a plugin where I've set a new version/description in the plugin.yml file, but when the plugin is loaded, the old version/desc is still displayed, the plugin.yml doesn't seem to update when I build the package
And you're just checking by the Material
Any other item in the inventory with the named material will be affected tho
Not if you give it an itemstack
Ill try that
Guys , when I did Inventory Click Event it didn't work , I register the events , @EventHandler , Why That
I'm not also sure what is the purpose of the amount variable
IntelliJ? HELLO?
Did you register the class as a listener
?
@chrome beacon Yes
Show us some code. We can't help you without more information
you talking about the shuttle variable?
what I see is that variable being an instance variable and you attempted to call it from a static block
won't work
omg
lmfao
I didnt realise I set the method the static
bruh
it's 1am and i've been up till 5am the last few days working on this so my brain is dead lmfao
ye, take a rest dud
Taking a break is important
but I actually do something
You do more when your tired
bad code is still code
no
sleep is no code
In the future, you will regret not have written that code in a better way
as long as it's optimized, readable and works it's fine with me
obviously I have it laid out nicely so it's readable but i'm not gonna spend my life cleaning code noone will see
I'm not talking about optimization but code structure, bruh
Writing clean code is also a treat for you in the future, necessarily not for others
it's fine tho
^^
depends what you classify as "clean"
I said you will regret, not anybody else
I would consider my code as clean and easily readable but not the best possible way you can think of
it's very easy to read for me
clean for me is a good structure design
Yeah I guess it’s subjective to a certain degree
anyone?
See ur dm @chrome beacon
is the getBlock for BlockPistonEvent the block it's moving, or the piston itself?
It’s not an event u should use spnda
where
It’s one of the "PlayerEvent" kinds
are you using maven?
Yes I know
no
There's two subclasses of it
why not?
But they just super that definition
grandle?
Which is why I just mentioned it
hi
I didnt choose any when creating the project
It’s the piston
you should really use maven or grandle
ok thanks
no it doesnt
then something is wrong when building it
like the plugin.yml is old
is the actual plugin updating
delete the old plugin.yml and replace it manually put in a new one
ok
what compiler u use btw?
probs intelliJ build artifacts
yes, I use Build>build artifact
still the same thing
are you sure you actually changed it?
it will change if you did it manually and the plugin loaded
show me your project structure
Ctrl + Alt + Shift + S
Is your output directory in your servers plugins folder? if it is and the server it's running it might not replace the old jar
?
no its at default
No, project structure
or this?
I put my plugin.yml inside the src
hmm I was doing like that before
also download "minecraft dev" for intelliJ makes stuff 100 times faster and removes all room for error
ok
Consider using maven or grade
He's not using Maven so no need for a resources folder
But yeah
lmfao
oops
If he doesn't have a resources folder he can add the file itself to the build directly
in the project structure window, go to the artifacts, then the plus sign and add the file
what are maven/gradle for?
compiling
That would work for you but consider using gradle/maven next time
add the plugin file?
Project management, in general
ye
he noob
I know, but better be clear
gradle/maven are in charge of compiling, have and update dependencies and control the modules of your project
yet, you can use them just for compiling or have updated dependencies
choose other?
?
ok
and select the plus sign of their config to add the file
like that?
yes
ok
still, I'm not confident of leaving your plugin.yml files in the src folder
take the file out of the src folder
lol
ok, and put it where
resources
idk, it's ur project dud
I create the folder?
IJ doesn't create a resources folder by default
it does I believe
every non java file in src is just copied to the compiled jar
silly billy
no it doesn't
i created the folder and moved the file to it
u did it wrong
?
thrrr is a plugin
the resources folder is normally under src/moduleName/resources
you will have to mark it as a resource folder and make sure to add it to your compiled jar now
the folder is empty
i am telling you it is not created by default
IT FUCKING IS
make a new project then
wasnt created by default for me
precisely
It's not unless you create a maven project
ur mom is yum
thing is, the files are cached for further compilations, and since the plugin.yml is not a java file, the same cached file is always used to put in the output artifact
ofc
Is there actually a faster way for a tabcompleter than this?
you need to choose what do you want to put on it
idea doesn't create the plugin.yml lol
you don't need to create a new list each time
the mc dev plugin does it
wait resources folder should be at the root of the projects?
just have a constant list
y
it does not matter
python sucks
read my status
yes
imagine minecraft made with python
LOL
Disgusting
I'm not a python user
That would be slow
never said u were
let me sleep quietly pls
ok and now imagine it was made with C++
Bedrock
what do I choose to add the resources folder?
yes
^^
but Bedrock is not java edition
mark the folder as resources
Configure that from the module configs
What is the max language level that spiot supports ?
clean then build
depends on the host os
whatever jvm it is run as then that is the max
now I'm getting the same problem as the beginning
which is
Thanks, so what do you think is standard jvm for hostings?
the plugin.yml isn't being updated
paper enforces java 16 on version 1.17+
but the plugin itself is
clean your output and build your artifact
delete the out folder or re-use the clean option in build artifacts
you should be able to run two at a time but clean then build artifacts
no problem
hello, i need some help
i'm trying to remove some AI of mob, like his head movements, deplacement, etc...
someone have an idea ?
disable that AI will stop mob gravity too
¯_(ツ)_/¯
what?
nvm
i did it
i was just being stupid
so i want to make a plugin where when a healer hits a healable person they heal the amount of damage that should be done
so i want to make two commands
/healer
and /healable
how would i set up the commands so that i can identify players those commands have been used on
for the event detection
EntityDamageByEntityEvent
to make two commands from one
like
/healer add
and /healer remove
would i have to make them seperately
no
in the command function
theres a list of strings
which is the syntax
i forgot the name
but i think its the 4th variable in the function
lemme find it
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
use "args"
for example
in the command /healer add
"add" would be args[0]
ah ok
yeah
but make sure
u check that args[0] exists
otherwise u get error
and then if it doesnt
return like
"incorrect syntax! please use /healer add/remove"
something like that
ok
by return i mean send a message to the player
yeah
wait for the package file where i store my classes should that be in the src/main/java or in just src
ok
if u wanna do like /healer add (player)
yeah
just use args[1]
yep
yes
its how lists work
and then check if Bukkit.getPlayer(args[1]) is null
if it is
then that means the player doesnt exist
actually i think u should use getofflineplayer
yeah
cuz they neecd to be online
wait
im confused
cuz it shoudl only work with online players
ah makes sense
this returns OfflinePlayer object or null
woudl this make sure that if they dc rc it will still stay?
not really
that will never return null
use yml file
you need to like interface with hashs and stuff
idk much abt java tho
im kinda just guessing stuff
don't use getOfflinePlayer(String) unless you need to
havent done spigot in a bit
it will block the main thread as it makes a request to Mojang if they have never joined before
so what would u use
depends what you're doing
getofflineplayer(string) is deprecated anyways
theyre trying to add a player to a list from a name
okay thanks
If i try to remove something out of a hashmap, will that throw an nullpointer when its not in there?
no
oh then its an unneccesary check
update it?
so i can remove the contains part?
yes
fine
yeah after updating pom.xml
maven on the sidebar > refresh
😳
perfection
im on eclipse lol
cuz thats what the tutorial on bukkit if for
¯_(ツ)_/¯
should i use intellij
up to u
entirely a personal decision
and which one is actually better for storing players uuid? a hashlist or a hashset?
depends what you want
also hashlist isn't part of the jdk
you probably mean arraylist
uhh wait
hashset doesn't allow duplicates (which is fine for UUIDs) but does nto have a get method since it is unordered
ah yea arraylist
though since it's hash based it's contains method is O(1) rather than the arraylist O(n)
just dpeends what youre doing
i'm just using them like to store an uuid temporary until the command is handled or something
probably temporary is the wrong word
ah nvm
like in the .java file what do i import
i know implements CommandExectuor
but like is there a way to shorten this
it's in org.bukkit.command.CommandExecutor
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
you can use wildcard imports tho they are generally discouraged as it can cause namespace conflicts
when i only import the thing you said
eclipse shows CommandSender, and command with red lines
of course
and when i look at the error it says to import this
because you haven't imported it
you need to import it
unless you want to write out org.bukkit.command.CommandSender every time you need to refer to that class
the imports have 0 impact on your code readability
ok
how can I initialize a List<ItemStack> without setting it to null
by creating a new arraylist?
doesn't that give me like 10 functions I need to fill in though?
no because arraylist is an implementation of list
if you try to initialise a List what you're actually doing is creating an anonymous class which implements List
since List is an interface
I see, I kept trying new List, when I should have tried new ArrayList
Hi, how do I get the slot number from InventoryClickEvent? I mean the slot item is moved to not what slot was clicked
i believe there is a seperate event for that
How can I turn a name (for example "maxthier") into something like this: ("--------"), "conminelp" would then be for example "---------". So the number of characters in the name in the form of "-".
how is it called?
or not
I'm not entirely sure
closest thing I can find is InventoryDragEvent https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryDragEvent.html