#help-development
1 messages · Page 1715 of 1
There is something i can't make with spigot so idk what to do
I just pushed it, but yeah that should give you an idea
You get the src when running buildtools
Anyone?
hey there quick question is there any way to add custom text on this screen?
since i would like to check my sql db there so it dosen't disturb ingame
ok so uhm, can someone help me, I'm trying to make a plugin where I'm trying to use modules to create an EnchantmentAPI using Bukkit's api, but I cannot make it work using modules...
is it gradle or maven?
I'm stuck because my api and the modules rely on each other, and maven for some reason, is a dumbass, and I don't know how to make maven build the revisions and api to put into a jar.
maven
Yeah, I don;t use modules I'm afraid
oh
oh fu** my life
But yeah, in short, gradle 😄
fuck gradle lol
no 😦
ye
I like maven
What issues are you having?
I actually hate my life, I've been trying to find this stupid solution for like 5 days already.
basically I have modules with specific revisions of the bukkit api, back in 1.8, but I cannot make it work.
because maven doesn't want to compile the revisions and api at the same time.
I NEED maven to compile them at the same time because I want to create shitpack (jitpack)...
well
not create
you understand me
There was a demo of multi version maven
I can;t remember the devs name. but its a well known dev
let me think a sec
just please do because I'm already having 2 mental breakdowns with this stupid maven conversations.
I can't figure out how to get all of the online players in a list of strings i have been asking for so long and I cant understand please help me
guys i want to make a sound plays when i execute my command but how to do it?
i want it like a bell sound or something
declaration: package: org.bukkit.entity, interface: Player
use something like this, java Location playerLocation = player.getLocation(); player.playSound(playerLocation, Sound.BLOCK_BELL_USE, 10, 5)
Use world.playSound if you want others to hear it
well i did something but for some reason instead of sending a message i told it, it insteads send a message of /meow in the chat
we showed you two complete bits of code to get teh names in a List
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("Meow")){
Player p = (Player)sender;
if (sender instanceof Player){
p.sendMessage(ChatColor.RED + "Playing cat meowing sound");
p.playSound(p.getLocation(), Sound.ENTITY_CAT_BEG_FOR_FOOD, 2F, 1F);
return true;
}
}
return true;
}
``` well the return true; at the bottom was false but its changed to true now so now it will be fixed right?
Bukkit.getOnlinePlayers().stream().map(Player::getName)
hello it's still me with another problem : I want that an entity AI make that the entity never go away from a chunk
@echo wharf Thank you, I was looking for how to do these for so long, and you saved me
#help-archived message
How would i add tab completion for an second argument?
I have an command, /sign
where if you use /sign copy, it does not require any arguments
but with /sign paste
it requires an UUID as argument
Same way you do it with 1 arg
and i want to autocomplete the 1st argument, ("copy" or "paste"), and the 2nd argument (the uuid)
Just check the length of args in the tab complete method
this is my code rn https://sourceb.in/bB5dF8WBdu
im bad at math so idk what expression to make
can you help me with this?
i figured it out
I have to make the if statement args.length == 1 and the switch args[0]
[ERROR] [ERROR] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='ml.jadss:API:1.0-JadLaxyDev'}' and 'Vertex{label='ml.jadss:EnchantmentRev1:1.0-JadLaxy'}' introduces to cycle in the graph ml.jadss:EnchantmentRev1:1.0-JadLaxy --> ml.jadss:API:1.0-JadLaxyDev --> ml.jadss:EnchantmentRev1:1.0-JadLaxy @
can someone help me?
I'm having this
your modules/projects are depending on another in a cyclic way
well ... make only one depend on the other
can't
tough luck
How do I check if a material is Oak Planks?
what
what do i do ? if one depends on the other..
you refactor your code so you get a tree structure instead of a graph
so that A -> B but B -/-> A
where
also, how do I check if a string is equal to anything inside a list of strings
@eternal oxide
quick question: how can I get a compass to point to a specific location?
I've posted it twice now. just read
Player.setCompassTarget(Location)
then every compass in the player's inventory points there right?
there's https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/CompassMeta.html which you can get from the item stack and there set the lodestone
ok thank you
also, how do I check if a string is equal to anything inside a list of strings
.contains
that isn't a method... is it because I'm using the API?
it's a method on list, what are you saying
i'm doing args[0].contains it isn't a method
of course not, thatrs a String
oh, yeah, lol
I should have been doing something else, I was doing it backwards
what do I put in place of this?
Player::getName
thats completely different...
i know
you don;t put anything in place of that
and retreiving an element
its calling the getName method of Player
Are you trying to find if a player is in a list or something?
Dont check by name in that case
ok, but why two ":"s?
I have to, I'm using the args variable in a command executor
same as player -> player.getName()
yeah, I... have... no idea what, or how to use a "->" (forgot what its called)
lambda notation
yeah
well lets start of with just a normal for loop instead
if you cant do a normal for loop
dont think about the shortcuts
I can
Ok then show us first
for loops = ez
then loop over Bukkit.getOnlinePlayers() and pull all names placing them in a List
Hi i was wondering how i can use multi args like one?
like /msg hi rob
using all the args after msg like on
one*
for (int a = 0; a < 10; a++) {
//code here
}```
for (Player player: Bukkit.getOnlinePlayers())```
^
ok, then idk how to use a for loop lol
dude for loops are the second thing you learn
both of those are for loops
Maybe for you
one you are incrementing a counter, the other you are looping over player objects
?learnjava only showed me ez for loops
thats kinda dumb. Like usually they give us the problem, oh how do we print this out 100 times now?
i'm not even in high
I mean I've been in this course for 3 years and I haven't learned much above what they taught me in grade 12
¯_(ツ)_/¯
At least I get the paper
lol
People have been teaching me java for years and I still had to find out about foreach loops myself. sometimes people just dont teach you the good stuff
Java is nice that it has so many way of doing things
foreach loops
And yet there are still some things I really want :p
Okay python
python is even worse syntax arguablly
i prefer java much over python
lol
can you give me a link on the difference of a list, an array, and a stream?
Questions about lag with finding OfflinePlayer via username
anyone know if PlayerDeathEvent is cancellable
they are different data structures
an array is a data structure with a fixed length
cuz on stuff like hypixel it puts ppl in spectator when they die
got it
a list is a data structure which is a subtype of Collection and you can add or remove from it
and some other methods
Not on spigot, but you can cnacel the damage event if it would kill the player
ok
and a stream is a structure which allows you to perform many useful operations on, but not actually used in the context of storing data, but manipulating it
if that makes sense
how do u detect if it would kill tho
getHealth - event.getFinalDamage
and then like that <= 0
<=
probably would to someone who didn't skim over ?learnjava but not to my tiny brain
PLEASE tell me this would work java if (!(onlinePlayers.toList().contains(args[0]))) { return false; }
onlinePlayers is equal to Stream<String> onlinePlayers = Bukkit.getOnlinePlayers().stream().map(Player::getName);
if args[0] is a string, no
ugh
depends what onlinePlayers is and if toList() returns an actual list, and theres no case on any of that so upper/lower
I HAVE NO IDEA HOW STREAMS WORK
is args[0] like a username passed to a command?
Then don't use them
yes
Learn how to use them then 🙂
yes
List<String> playerNames = new ArrayList<>();
for (Player player: Bukkit.getOnlinePlayers()) {
playerNames.add(player.getName().toLowerCase());
}```
in fact its recommended to use it
i'm sorry, I'm just getting frustrated, so please forgive me if I'm a jerk/burden.
toList is like brand new
then if (playerNames.contains(args[0].toLowerCase()))
Its in Java 16
and it creates an immutable list
the collectors creates a mutable list
so use toList()
cause immutable good
please explain this Player player: Bukkit.getOnlinePlayers() or give me something that does, I want to learn not copy
Is there a toSet as well
Stream.collect(Collectors.toUnmodifiableList()) == Stream.toList()
its a for loop, over the Collection returned by getOnlinePlayers()
in use of streams, it being mutable usually doesn't matter so its a safe option and cleaner
what does this part do? Player player:
Seriously?
?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.
google for loops in java
it feels like you are insulting me, please stop
I'm not, this is really basic java
🧠 == small
its literally about as basic java as you can get
ok, you are being a straight up jerk right now. For loops are one of the basic things, and they are universal to any language. Not even just java. It should be a embedded into your brain how to use them
we arent insulting you, but if you are trying to say we are, we cant help you
how do you make an entity drop all of its items
They're not insulting you, a lot of this stuff comes with learning Java. Whether you're brain is small like you say or you're inexperienced or you are just new to it, all 3 of them have the important thing in common that you need to go learn ❤️ - The server here is designed to support how you implement Spigot into your existing knowledge of Java, I highly suggest to learn a bit more on Java in the mean time because that will help you make the best of your plugins, otherwise they'll just be half hacked together in a bad way
Player player: Bukkit.getOnlinePlayer() = For each(:) object Player named player in the list Bukkit.getOnlinePlayers() then do {}
lol
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.
why me
just a lol
im talking about making it drop all of its stuff without dying
(doing it for players btw if that helps)
i like how the dumbest people always have "minecraft dev" or whatever in bio .. bruh you are not a dev if you need to ask simple java stuff on here
im not rlly good at java
use the inventory class and remove each item
that message wasnt for you , it was for the other guy
😛
o
i only recently put stuff into my bio
im not trying to clear btw and theres no getInventory().dropItems()
there is player.dropItem() but i think it only drops one item
What is your goal
me?
mhm
I'm not sure and i'm tired but i guess you could iterate using getInventory().iterator() and on each iteration call
remove(ItemStack item)
and then
player.getInventory().updateInventory();
i never worked with inventories so yeah idk
||
final Location location = player.getLocation();
for (ItemStack itemstack : player.getInventory()) {
player.getWorld().dropItemNaturally(location, itemstack);
player.getInventory().removeItem(itemstack);
}
||
i dont think an update is necessary
@young knoll im sryyy
i felt lazy
I put it in a spoiler
:p
wait does remove just delete it or does it drop it
for (ItemStack itemStack : player.getInventory().getArmorContents()) {
player.getWorld().dropItemNaturally(player.getLocation(), itemStack);
player.getInventory().removeItem(itemStack);
}
Delete
would something like this work
Hence the dropItem
god discord screws up tabs so bad lol
would this work
wait will that just get the armor
lol
o
i can just do another loop with getContents()
ok so should something like this work
lol forgot the () on catch but ignoring that is it right
should this work
Do you want only armor or all?
oh yeah you want to drop , i said to remove.. lol i'm tired srry
is there any way to spawn a mob without it doing damage
like lightning
ok so ik its if(event.getCause() == something) but what is the lightning damage cause called
nvm im dumb
lol
DamageCause.LIGHTNING
anyone know why this isnt spawning anything theres no errors
all I see is player.getworld().spawnentity(player.getLocation(),...
can anyone help me with regex
i want to remove the spaces from in between <>
so /test <option1 | option2> becomes /test <option1|option2>
also how do you get what the death msg would have been
event.getDeathMessage();
pretty sure
but its in damage event
but it cant be in death event cuz technically ppl dont die
it sets them to spectator when they die and play a death effect
could it be something to do with event.getCause()
u cant cancel death event
ye
oh ye
i see
so damage event
check if the health of the player is less than or equal to 0
if so
cancel the damage event
set the gamemode to spectator
and whats the problem your having?
Does anyone know how to make an enderdragon ride a player? Like what I tried to do here EnderDragon enderdragon = e.getPlayer().addPassenger(EnderDragon.class);
...
send out a regualr message
make it yellow or whatever
or no
just white
if i want to hide all NPCs with the name Click!,
i know i do that with teams, and by adding the entry by name and setting the visibility, but who do i apply the team to? or wha. i just want Click! to be invisible to all players, but players would be able to see one another
team.addEntry("Click!");
team.setNameTagVisibility(NameTagVisibility.NEVER);
but the thing is i have to use the specific messages
like <player1> was killed by <player2>
so get the last damage cause
if it was by player
then send message plr was kiklled by plr
but theres only entity
pretty sure you gotta use packets...
bruh do i have to do all of it lol
cast it to a player
if(!(entity instanceof Player)) return;
Player plr = (Player) entity;
how do u get who the damager is
plr.getName();
but thats the person being damaged
How do i reference a spicifc world
bukkit getworld "worldname"
yep ty
IIRC you can check if the event is an instance of EntityDamageByEntityEvent
this doesnt exist
And then cast to that, which has getDamager
bruh
wait can i just like do event.getDamager().toString() and then like clip off the start
I'm back and I have done what you said to, I understand for and for-each loops now and I have calmed down.
Bukkit.getServer().broadcastMessage(ChatColor.RED + player.getName() + " was rekt by " + entityevent.getDamager().toString().substring(5));
lol thats a lot for one line
btw how do you stop lightning from starting a fire
You will still get some ugly output with that
would this work? java List<String> onlinePlayers = new ArrayList<>(); for (Player player: Bukkit.getOnlinePlayers()) { onlinePlayers.add(player.getName().toLowerCase()); } if (!(onlinePlayers.contains(args[0]))) { return false; }
and also why doesnt the lightning spawn when i do this
@young knoll ^
world has a strikeLightning method
Looks alright to me
lol
wait what is it
What is what
player.getWorld().lightningStrike lol
like is it the same as spawnEntity with the location and stuff
Why not look?
public boolean idk(String name) {
return Bukkit.getOnlinePlayers().stream().anyMatch(player -> player.getName().equals(name));
}
better code
declaration: package: org.bukkit.entity, interface: LightningStrike
why not, learning by using :d
Copying code from someone else is not learning
^ yes
^true but how should you know something exists, if no one showed you
also streams don't even work for my situation lol
There are plenty of things that will show you
I have already tried
Without writing it for you
because of what?
They do, but if you aren't comfortable with them then don't use them
oh
^ true
They are also slightly slower if you want to be pedantic
well how would I use them, I already have a solution but I would like to see
Avoid them in very hot locations, which is a trap Mojang fell in to
in this case?
now how do i stop lightning from making fire and setting entities on fire
yes
bruh
lol
There is strikeLightningEffect iirc
packets
you can manually deal damage to the player
im not trying to make it deal damage
I was typing that
just make it look like lightning strikes
packets
public boolean idk(String name) {
return Bukkit.getOnlinePlayers().stream().anyMatch(player -> player.getName().equals(name));
}
lol
then StrikeLightningEffect is perfect
does it exist in 1.8 btw?
Bukkit.getPlayer
i'm not comfortable using lambdas either lol
??
I have no idea how they work or what they do
Bukkit.getPlayer(name) != null
???
public boolean idk(String name) {
return Bukkit.getPlayer(name) != null;
}
you know that onlineplayers means only online players
ik, but he wanted a showcase for streams
yes
yea but still in his case it is just a showcase
whats DamageCause.CONTACT
I don't care if this java List<String> onlinePlayers = new ArrayList<>(); for (Player player: Bukkit.getOnlinePlayers()) { onlinePlayers.add(player.getName().toLowerCase()); } if (!(onlinePlayers.contains(args[0]))) { sender.sendMessage("That is not a player!"); return false; } is bulky, I understand it.
lol whats iirc btw u keep saying it
if i recall correctly
How would I use TabExecutor to tab complete only one argument?
Return an empty list for any other argument
Or null, but some servers will list players names if you return null
I am not familiar with TabExecutor so how do I return a list for only one argument. I assume when I return it tab completes everything in my command.
Check the args length
I think you are joking, I can't tell lol
Java is an informal North American word for coffee
yes
what this do
for(int i = 0; i < userMap.size(); i++) {
System.out.println("ur mom dumb lol");
]
well, what is userMap?
Probably throws an error because userMap is not defined
?paste
with error code Error at line 1, with error code: "You dumb lol"
no it defined here https://paste.md-5.net/elaruqotuf.py !!!!
smh!!!!
Hey it actually got the file extension right for once
tru
just a tip
if you are using player.getInventory.clear
there is no need to manually remove the item in the fors
hey, need some help :3. i have just huge chunka code durring the PlayerDeathEvent, when a player dies they don't actually 'die'. they get the respawn screen and all, but they don't 'fall' over or turn read, the player just stands there and respawns in the location they're standing in, its kinda hard to explain but..
if (!p.hasPermission()
did I do that right , I just want to double check
! = no permission
It takes a string
hasPermission("ur.mom.haha.funny.word")
I know it creates a string and the string is the name of the node . I just wanted to ask if ! was in the right place
Yes
!p.hasPermission("dawd") :drakeNo:
p.hasPermission("dawd") == false :drakeYes:
!(this.message() == true)
if (!(!String.valueOf(true).equals("false")))
oh god
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
at me.fuzyjaguar.test.items.Click.onRightClick(Click.java:40) ~[test-1.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.StaticMethodHandleEventExecutor.execute(StaticMethodHandleEventExecutor.java:38) ~[patched_1.17.1.jar:git-Paper-266]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:624) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:542) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:505) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:500) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:496) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2295) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.network.protocol.game.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:25) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.network.protocol.game.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:7) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$1(PlayerConnectionUtils.java:56) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:149) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(IAsyncTaskHandlerReentrant.java:23) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer.java:1418) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer.java:192) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:122) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.bf(MinecraftServer.java:1396) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1389) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:132) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1367) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1278) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-266]
at java.lang.Thread.run(Thread.java:831) [?:?]```
if (event.getItem() != null) {
if (Objects.equals(event.getItem().getItemMeta(), (ItemManager.eStick.getItemMeta()))) {
Player player = event.getPlayer();
Block block = Objects.requireNonNull(event.getPlayer().rayTraceBlocks(50)).getHitBlock();
assert block != null;
player.getWorld().createExplosion(block.getLocation(), 4f, true);
event.setCancelled(true);
}
}
}```
Which is line 28
Rather than requiring the block to not be null (and using an assert for some reason?)
Just check if block is null before you try and do anything with it
RayTracing always has the possibility to return null, a player may not be looking at a block
is it possible to turn a string into an int?
yes
ok tanks btw
Integer.parseInt
ok so im not sure that someone will answer this, but how do you run server, intellij and mc at the same time
yay
with 8 gb
if (Boolean.parseBoolean(new String(String.valueOf(true))) == true) {
return true;
} else if (Boolean.parseBoolean(new String(String.valueOf(false))) == false) {
return false;
}```
run intellij at your phone
and gg
wat
I don't think a string will ever == a boolean
Integer.parseInt(str); would throw an error if the string is not a number, which error is this?
so I can catch it
so i added a discord bot to my plugin, but im having some trouble with a help command
thx
I've been really struggling with this problem. I've been this to run this function (https://pastebin.com/tFxJjbns). But it keeps throwing that "players" is null. I make the variables (https://pastebin.com/EWNHKg5Q)
I'm using the API so no apache for me 🙂
public List<EmbedBuilder> registerHelpPages() {
List<EmbedBuilder> embeds = new ArrayList<>();
int i = 0;
EmbedBuilder curEmbed = new EmbedBuilder()
.setTitle("Help")
.setColor(Color.BLUE)
.setFooter("Made by Silent Program!");
for (Command c : commandList) {
curEmbed.addField(c.getName(), c.getDescription());
i++;
if (i > 6) {
i = 0;
embeds.add(curEmbed);
curEmbed = new EmbedBuilder()
.setTitle("Help")
.setColor(Color.BLUE)
.setFooter("Made by Silent Program!");
}
}
return embeds;
}
so
i have this
wich is supposed to create a list of embeds each containing at most 7 command information fields
(this is for a discord bot help command)
So it loops through the commands i have, then adds a field for each fo them. then once it reaches 7 fields, it adds the embed to a list, and creates a new embed, and repeats
but for some reason
it keeps returning a list of 0
commandList has 2 commands in it
and i know thats working
i added a print to check the size
Spigot bundles apache
StringUtils cannot be resolved
depending on the entire thing gives me a warning at module-info lol
bc its the file name
.clone() doesnt work for some reason
it says Object has protected access
bad name check
bruh
?paste
oh sori
@ivory sleet can you delete this? ^
I do
Ah
why ping a helper for something that will be gone in 2 seconds
event.getPlayer().rayTraceBlocks(50).getHitBlock();
event.getPlayer().rayTraceBlocks(50) may be null
hm
The javadocs have nullability annotations, you should look at them
if you use intellij, intellij warns you if something could be null

why does this throw an error at NumberFormatExeption? ```java
try {
int ammount = Integer.parseInt(args[1]);
} catch (NumberFormatException) {
}```
the string args[1] might not be a valid integer
You need a name
?
catch (Exception name)
NumberFormatException is the exeption name
Yes
🤦♂️
But you need a variable name
lol
ok?
NumberFormatException exception
...
name the variable
the exception is a variable
didn't know that, thanks
we really shouldnt be helping you about syntax
try/catch is part of the basic java course too
i mean
yea, but also if its a small mistake then dont be a dick about it
^ thank u
read the history and u'd understand
tru
can I just make a new user and, like, not have everyone annoyed when I ask a stupid question?
its not our job for you to learn foreach loops
before asking
after all, this is Spigot API help
not Java help
unless its a serious Java question, then sure
Self teaching is a crucially important skill, this channel should generally not be regarded as the primary goto source whenever you struggle with things, google it first, search for other people on the internet who wrote about the issues you may have, maybe even watch a video. If you then fail to understand or address the problem, ask here.
speaking of
i have been working on a thing for an hour now
if anyone wants to try and help out
What’s the issue there?
Debug it with print statements or something
try printing the list after each addition
damn im dumb
But feels like it never reaches the 7th iteration
Yeah and that explains why it’s 0
fuck
The spigot forms usually have an answer to all but the most obscure issues
i put the add in the wrong spot
🥲
is that javacord
ye
ic ic
if i wanted to get all spectator players in a server how would i do that?
Loop all online players and check their gamemode
Add the matching ones to a new list
k, ty
stream
😋
Bukkit.getOnlinePlayers().stream().filter(player -> player.getGameMode() == GameMode.SPECTATOR).collect(Collectors.toList())
If I don't see an entire plugin made in streams in the next year I will be terribly upset
Bukkit.getOnlinePlayers().stream().filter(player -> player.getGameMode() == GameMode.SPECTATOR).toList()
The bytes have been reduced
And yes, I just learned about toList today
by me using it wrong lol
yes
sad
I like lists better than arrays
just cuz
arrays are very useful aswell tho
but I would rather use lists
if possible
Lists are technically just fancy arrays :p
how would I remove a set amount of one item from a player's inventory
size?
Yes, item stacks have a stack size
ItemStack item = new ItemStack(Material.BOOK); no stack size
kek
stfu @ancient plank I didn't ask for you to join this conversation
Look at the other constructors
yikes
1/1 warnings
please
just
no
also, where do I set this amount, what if I want to clear a different ammount of the itemstack in different places?
I'm not getting this
it should be removeItem(int, ItemStack)
and I stand by that
Then you change the amount for those other locations
That would have to be a seperate method since removeItem is a vararg
Which can be quite convenient
Yes
You can pass any number of itemstacks to it, and it will be treated as an array inside the method
// Varargs declaration, must be last parameter of function.
// |
void exampleFunction(String... strings) {
for (String i : strings) {
System.out.println(i);
}
}
I typed in a correct player name and it said "That is not a player!" here is my code java if (!(onlinePlayers.contains(args[0]))) { sender.sendMessage("That is not a player!"); return false; }
thats not enough info lol
here is my class
onTabComplete is a W.I.P. So don't worry about it
I really don't want to at any1
please help
patience young padawan
lol
did you put a capital letter in args[0] because #contains() is case sensitive iirc
better yet, copy paste the command you typed to not get the result you want
So, I have a question. Does InventoryCloseEvent run whenever another inventory is opened to a player?
yeah lol
I believe so
Damn it, So there is no way to create like a menu that will go back to like a Main Menu? So I have like a menu that when you click on it it open menu3, and if you close that menu, it will take you back to menu2, and I want it to take you to menu1 if menu2 is closed but I have an issue which is that if I click on an item in menu2 to open menu3, it will call the close event on menu 2 so it will open menu1 instead of menu3, but the menu2 then will open back again because when menu3 was opened it was close to open menu1 so its a mess
I did java if (onlinePlayers.contains(args[0].toLowerCase())) { and it still isn't working with capitals 🤔
ok
well
this is a discord server about spigot
so some people yell at you for asking questions unrelated to spigot
we don't care if its like a serious not dumb java question
this is my main method
public static void main(String[] args) {
AutoRunFromConsole.runYourselfInConsole(true);
Bot client = new Bot("");
client.login();
}
pretty sure its throwing the rror on the Bot client = new Bot
no class identifier
yea, cause thats line 12
dude
Have you shaded javacord
thats a constructor
i think so, let me check
i dont think i did
thanks coll
[public/private] class Main {}
^
I gtg like very soon pls
toLowerCase will strip all caps
So if the username is meant to have some caps, it will not match
it isn't
you removed the ! from the if statement so now its checking if onlinePlayers contains args[0]
schleep time 😴
I had multiple, I added it to the wrong one lol
I had one checking if it didn't and one checking if it did so I could check if there was a random error.
go offline if you going to sleep lol
how do I only tab complete one argument
put it in this thread so I can find it bc I have to go lol
hey, need some help :3. i have just huge chunka code durring the PlayerDeathEvent, when a player dies they don't actually 'die'. they get the respawn screen and all, but they don't 'fall' over or turn read, the player just stands there and respawns in the location they're standing in, its kinda hard to explain but..
Gonna need to see the code
https://pastebin.com/CRM1aT2a <- thats the event code
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.
I would imagine it’s due to modifying their health in the death event
yeah! that was the problem, tyyy :)!
§r
meta.setName(ChatColor.RESET + "Item")
item.setItemMeta(meta)
not working
no work
gradle?
@quaint mantle can you provide your full code for that?
and is console logging any errs
is there any way to change the BlockFace in Player#sendBlockChange()
for example: stair
Yes, set up the blockdata for it
can you make an example
Stairs stairs = Material.OAK_STAIRS.createBlockData
Then modify the stairs as needed
well this thing didnt exist back in 1.8.8
No idea, I pushed the old system out of my head a long time ago
what exactly is this? the 3 rows above the hotbar, or the inventory from for example an opened chest?
the opened chest
so... what would it return when no inventory is opened? cant be null
there is always a top inventory o.O
if you open your player inventory, that would be the 2x2 crafting grid
i want to make a multiarg, how to
multiarg ?
for example /holo create test <arg>
yes
not the arg
it self
let me explain wait
if i check for <arg>
it only gets the arg
but i want the arguments in front of it
for example
/holo create test test1 test2 test3
i want the test1 test2 test3 included in my string with a string builder
Loop through all the args and join them
Then loop from where you want to start
your loop can start at an index that isn't 0
how to do that
for(int i = 1; i < args.length; i++)
so 1 is the index
would start at index 1 instead of 0
right ?
Yes
the string at that index of the array ?
how to get it
?leanjava
oh wait
this is pretty basic java/can easily be googled
ok so, not a spigot related question
but i have no where else to go
Im getting a noclassdeffounderror
wich im pretty sure is a problem with my shading
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>me.silentprogram.discordbot.MainClass</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.javacord</groupId>
<artifactId>javacord</artifactId>
<version>3.3.2</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
yes, args[i] will result in the string at index i
but my pom doesnt seem to have anything wron giwht it
yes, but remember an index starts at 0
i know
it is arg 4 i guess
/holo create <name> <update-interval> <text>
^^^ 3
?
GWAGAGAGA
i guess provided is the problem
a) why type pom
i dont know maven
wait, i forgot name
so ye it would be 4
damn i cant count 😔
?
/holo create[0] <name>[1] <update-interval>[2] <text>[3]
Provided is used for shading no?
holo is not an arg
it isn't no
hmmm
i need sleep
but first i need to figure out the maven shade thing
wdym provided
provided is also not used for shading, rather it states that the artefact/classes will already be provided at runtime
ooooooooooo
so should i let it default to jar?
or whatever it defaults to
?? you are editing a pom file
ye
yes
aha. Well a) why is the <type>pom</type> set ?
and b) set it the <scope>compile</scope>
i know plugin is limited
but can you open a gui in plugin ?
i mean gui on the server host not in game gui
i copy pasted it off of javacords github like that
interesting
it gives me this
**Invalid signature file digest for Manifest main attributes**
well no clue what the pom file you are importing there is doing
¯_(ツ)_/¯
I guess just follow their basic layout for now ?
The Javacord website
also for setting the main class, I'd recommend the maven-jar-plugin
but then i wouldnt be able to shade it
You can still use the maven shade plugin
epic gradle shadowjar
well on the maven shade plugin on the maven website
it has what i did to set the main class
You have access to a fully Turing complete language, you could probably wipe the server’s drive if you wanted to
The limitation comes from the client server relationship
i use stringbuilders to do it. is there anyway to fix the space at the end of line ?
Substring
and what is that
It’s a method in the string class
cool, so now what
Use substring to cut off the last character
ok
Actually you can probably just use .trim
idk whats wrong
im getting a noclassdeffounderror
Don’t look at me, I don’t use maven
if thats what you use?
Talking about string any have any ideas/useful info , on how to like change different chat groups (staff chat ) /f chat ect
I looked at like at least 10 different plugins , and they each have like 50+ lines just for the chat it's self
I think you can automatically convert maven files to gradle somehow
But it’s fairly straightforward, and you can find tons of samples online
ye
wew the wifi is back
Here’s the base one I use https://github.com/Coll1234567/MineTweaks/blob/master/build.gradle
Your ide probably has integration for it
Otherwise you can just run gradle build from the command line in the root folder
Is it indexing
Should do that when you open the project
i fixed it