#help-development
1 messages · Page 1904 of 1
Tbh I like langs that center around procedural more than OOP
Feels slightly ignored?
No problem were are here for learning
OOP is a bit too complicated and has not much benefit
Just use: ?paste, then paste your code, press CTRL + S and then copy the url
Idk why it doesnt work
The only thing C# does better is generic handling. Because you can actually get those at runtime.
I absolutely hate properties. And C# has so much syntax sugar that its borderline obfuscating in some cases.
?paste (:
I personally like C#, I don't find it hard to read.
no kidding, ive been trying to understand oop in java for a couple days now since ive been in quarentine
Welcome to the spigotmc discord, if your conversation is asking for code I'd recommend the forums. People don't really care to look over that stuff in here :P
I have say many times but i copied and pasted a rest api from Java Spring to C# and it worked
Maow is proficient in Java, he might be able to supply you a lesson or two MrHoneyBun
That’s because C# and Java are pretty close to the same, syntactically
Yeah I know the ins and outs of this terrible fuckin' language lmao
thats up to him, i dont wanna waste his time tho
There’s very few fundamental differences
I doubt you actually copy-pasted it
I doubt it worked
Since there's a few big syntactical differences
Allirght sorry that what the translator translated
Clear your caches and invalidate em
e.g. Spring does not exist in C#
Lol
C# has different syntax for annotations (AKA attributes in their language)
Inheritance is different, : vs extends/implements
Wait C# doesn’t have type erasure right
Yeah
It also allows you to specify generic types as primitives
That’s just nice
We both said opposite words and meant the same thing
🥲
Yes :) a good language.
English is about as good as Java imo.
And I'm proficient in both, according to a lot of people...
Same
English is my primary speaking language and Java is my primary programming language
Nah I just legitimately dislike English and Java.
alrighty maow, here is my problem regarding OOP n stuff like that
previously in my code i was using a public static boolean variable and was told this is innefficient
so someone gave me a plugins options class and said to implement it into my main class, which is where i've been stuck at
i know it might be a stupid questions but i've been trying to understand oop for days now and it isn't clicking lol
plugin options ```java
package me.mrhonbon.opmobs;
public class PluginOptions {
private boolean toggled = false;
public boolean isToggled() {
return toggled;
}
public void toggle() {
this.toggled = !this.toggled;
}
}```
I assume deleting the entire .gradle file in the project and it redownload itself doesn’t work?
So I'm guessing you also hate the language of music?
And pencils
Just cuz I use it doesn't mean I have to like it.
It's like
Stockholm Syndrome
But for your hobbies
@quasi patrol as well if you use IntelliJ you can go to File -> Restart/Invalidate sth
And invalidate caches
(;
Hopefully that solves that
I mean this looks fine as a toggleable boolean but if it's meant to represent all the options in your plugin, you should probably do something else.
So UpsertOptions in mongo Its Faster?
For one, a config file is better.
I don't fuckin' know, Verano :p
You asked me this before and I told you I don't know how Mongo works.
its just for one command, to toggle the spawning of normal mobs vs op mobs
It probably doesnt matter. But use upsert instead of just set
A glorious button 
Allright thankss
Well then you can just have a single boolean in your command.
here is my main class:
package me.mrhonbon.opmobs;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
private PluginOptions pluginOptions = new pluginOptions();
@Override
public void onEnable() {
System.out.println("Hello world!");
getServer().getPluginManager().registerEvents(new BreakBlock(), this);
getServer().getPluginManager().registerEvents(new MobSpawns(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
user
Then you'd want to read from a config file.
Or alternatively have it set up as a parameter in your command.
Now you need to pass your PluginOptions instance as a constructor parameter to your other classes
Sure. You now have a singleton instance in your JavaPlugin class.
But nobody has access to this instance.
Well it's technically not a singleton instance
Unless you mean "singleton instance" as in the instance is a singleton
But a singleton wouldn't allow you to create more than one instance so yeah
Hi! Question about yml custom config files. If I do
someFileConfiguration.set("workers.timothy.age", 13);
someFileConfiguration.set("workers.timothy.salary", 100000);
Will it be shown as
- workers
- timothy
- age: 13
- salary: 100000
Thanks in advance (:
EDIT my bad, i didnt mean if itll literally look like that second file. I was just wondering if the structure will be that way
No @little elm
All checkmarks?
Go for it
Honestly dunno if I can help @proud forum considering I don't know how his plugin is supposed to work lmao
In your yml example everything is a list
i can post my current command class if u would like
Oh ok. How would I achieve the structure I want then? tysm
command class: ```java
package me.mrhonbon.opmobs;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class MobSpawnCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0].equalsIgnoreCase("on")) {
if (sender instanceof Player)
sender.sendMessage("Overpowered Mobs has been enabled.");
this.isToggled = true;
} else if (args[0].equalsIgnoreCase("off")) {
if (sender instanceof Player)
sender.sendMessage("Overpowered Mobs has been disabled.");
this.isToggled = false;
}
}
}
workers:
timothy:
age: 13
salary: 100000
Your code would result in this
Define a constructor
public MobSpawnCommand(PluginOptions options) {
// Store the options in a field
}
Example:
public class MobSpawnCommand implements CommandExecutor {
private final PluginOptions options;
public MobSpawnCommand(PluginOptions options) {
this.options = options;
}
...
yeah i got that far but its implementing the toggle into the command where i am stuck at
i might just have to go back to watching more java tutorials lol
You also need your instance of PluginOptions in your CommandExecutor class.
And then its just a matter of using its methods.
OH
Both need a reference to the same exact Object.
okay! i think i got it, now its just the matter of implementing it into my mobspawns class using if else statements
thank you very much!!
hint: You will also need your instance there
Java in a nutshell
Getting the exact same error.
AAAAAA
Yes. But now you are ahead of 80% of this discords participants because you understood the concept of dependency injection.
Oh that is true.
Yeah a lot of shit surrounding DI/IoC tends to be
worded very confusingly
tbh I did DI patterns for a long time without even knowing
you see
the idea is that when you have a dependency between two classes
a dependency meaning class A needs (an instance of) class B
i am screenshotting this
instead of hardcoding that in your implementation
e.g. if you created your instance inside your command class instead of your main class
you "inject" it from somewhere else via your constructor
soooo if i wanted to fully understand this, or just better, should i just use the java docs for reference?
well javadocs just explain how an API work, not what certain terms mean
Just program ahead. It will come naturally. Like Maow ive also done DI way before i even knew this was a thing
im glad im not the only one
How can I know if Bukkit#getOfflinePlayer(UUID uuid) successfully returned a player? What if that UUID doesnt exist?
Eventually over time you start to pick up on shit and form connections between different concepts
@NotNull
public static OfflinePlayer getOfflinePlayer(@NotNull
UUID id)
Gets the player by the given UUID, regardless if they are offline or online.
This will return an object even if the player does not exist. To this method, all players will exist.
Parameters:
id - the UUID of the player to retrieve
Returns:
an offline player
^ javadoc for reference
im trying to learn java through spigot becuase minecraft and plugin development is something ive been interested in forever and just never got into it
Lol, me 6-8 years ago
i started with skript and coded this exact same plugin i am trying to code in spigot
Oh boy, Skript
yeah... waste of time honestly LOL
I mean it probably did teach you procedural programming
It will always return an Object and you have no idea if its an actual player unless you make a request to mojang yourself (which is not recommended)
However.
You can check if this particular user has joined on the server at least once by calling
OfflinePlayer#hasPlayedBefore()
e.g. conditions and other types of statements
So I cleared Gradle Cache, and invalidated cache, and I am still getting this error. https://paste.md-5.net/nezucibeyo.pl
shoot
My knowledge of functions came from Python later on
But then Java taught me about classes and shit
we do java here sir
I will scream at my project if Gradle won't undie after I cleared cache, and invalided the caches... again...
Restart your PC. Some random file has a lock on it.
Eh you don't need to restart your PC I think you could probably just kill the daemon.
Honestly I don't know 🤷♂️
I just restarted my PC, lets see if it works.
again im back lol
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.
Didn't work.
Main.java:53
Something in this line is null.
Is it a command? Then check your plugin.yml
If its not then paste this line
f
shell script still the best bro
this.getLogger().info("Loading Lang...");
Lang.setLangage(this.getConfig().getString("Lang"));
assert Lang.getLangage() != null;
if (Objects.equals(Lang.getLangage(), "EN")) {
this.getLogger().info("Langage selected: English");
} else if (Lang.getLangage().equals("FR")) {
this.getLogger().info("Langage selected: Francais");
} else this.getLogger().info("Langage selected: error ! (" + Lang.getLangage() + ")");
loadLang();
load();```
Whats line 53?
} else this.getLogger().info("Langage selected: error ! (" + Lang.getLangage() + ")");
inside main
but in utils i have Lang.java
I doubt that this is the line that throws the exception. Compile it again, and then send the line which is
represented in the stack trace
LOL
lol
The error you posted is called a stack trace
then i run it again and again in my mc server
it isnt even hard and you should know it since you start a minecraft server lol
hey is there a DamageCause that is related to melee? I cant find it in the docs
ENTITY_ATTACK
wouldnt that be for any sort of attack?
What other attacks are there
Like by an item or by fist
Yeah those are both melee
true, is there a way to check if its just a fist?
Check if the attacker is holding nothing in their main hand
alright ill try that
Would you actually have to create a discord bot to get a user by ID in a Spigot Plugin? (Discord4J).
An insteresting question, when server goes down does PlayerQuitEvent or PlayerKickEvent get executed?
Cause I’d prefer not to.
Read the docs but I imagine depending on if it goes down via stop or task kill
yeah worked
so i want to get started coding plugins how do i start?
ill use build tools and im doing it on 1.16.5
it was the only server i could get to work on my pc without an error so
so what build tools do i get?
Use an ide interface developer environment FX like eclipse or intellij
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i would say
both
actually
quit
considering /stop
i think
Cuz i think if server goes down the events should be executed cuz if not plugins wont save player data
Error: Unable to access jarfile BuildTools.jar
@quaint mantle note the server jar is a bootrep
But in folders you can find the right jar
It couldn't find the jar file
Are using terminal?
If you are from terminal its caused because you are not on the same dir as your jar
im usin my command prompt
Make sure it jar file name is correct
You should move with cd to the directory where its the jar
And yeah prob check this
Make a bat file if you on window to run
I don't know mac
so i need a walkthrough with this because i dont know how to do any of this
https://www.spigotmc.org/wiki/buildtools/ I mean the guide is pretty good at explaining it
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
done that
right
Ok go to save as
mk
Click all files
file explorer froze again
Autocorrect being pain rn
fixed
You can also turn a text file to a bat file
If you allowed it in the options in file Explorer
Then you do. Start.txt edit to start.bat
Alright did you make the file?
So you put the jar file into same folder with ur bat file beside it
Make ur file is named BuildTools
Precisely
With upper case and everything
Then you can start your bat file
Ok
Was it a java error?
I think there's a bug in the 1.18.1 BrewEvent api
you can no longer update the resulting brewed potion, it gets overwritten by the vanilla result. This wasn't the case in 1.17 and 1.16
It was yes
did you update you system java version to java 17?
Yes
weird, what was the error? essentially
Java exception
But that was when i started it with Java 8 i used 17 and it did nothing at all
weird, normally updating should fix that
what do you get if you run $java -version in terminal?
dont include the $
It said something bout mixed mode
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
yeah so youre still running java 8
ye i had just installed limura 17 to
how do i get all the online players, select one randomly, tp him to specific coords, and everyone else that wasnt selected to other specific coords
done
Issue: When starting the server, PlayerEvent doesn't work but onBlockBreak does; but when I reload the server it begins to work. As this breaks other plugins, this is an obvious issue.
Use: This code is for enchantments with onBlockBreak being a magnet enchantment and PlayerEvent being used for summoning lightning.
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
//Magnet code here
}
@EventHandler
public void PlayerEvent(PlayerInteractEvent event) {
//Lightning code here
}
still showing this java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
Get a list of all online players, and then iterate through each player and teleport them to random locations
weird
thnx
how do i get a event player name in a string
so i can use it in a death message
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
ty
thats weird, are you on windows?
for(Player OnlinePlayer : plugin.getServer().getOnlinePlayers()) {
}
yes
hmmm
idk if theres something different when downloading java versions on windows or not
Java on windows is pretty easy to get the right version
For linux it is a bit annoying
thats what i figured
tell me about it
i had to update it through command line only
Linux updating version isn't easy
Yeah, I love using command line but it's annoying if you get the wrong download
its a pain
well i gotta go to bed in a bit
i think i spent like and hour trying to get it to actually work
ubuntu server
ahhhhhh
20.something
that's why
yeah
Did all go well?
Does anyone have any ideas on this?
im to lazy to set up a nice server system, im jsut kinda roughing it with ssh
ill talk to yall ye it booted everything in
yes i think
It booting?
Buildtools?
Yes
Yea
Awesome!!
is maven easier than build tools?
is there any way to colour death messages with the setdeathmessage function?
Computer just timed out because I got a time limit on it from my parents
rip
So this is gonna be interesting to wake up to
See yall tomorrow at around like 8:30 ish
I am so confused why some parts of my plugin require me to reload the server to work
ya!
Hopefully
what parts?
@EventHandler
public void PlayerEvent(PlayerInteractEvent event) {
if (!(event.getAction() == LEFT_CLICK_AIR || event.getAction() == LEFT_CLICK_BLOCK))
return;
if (!event.getPlayer().getInventory().getItemInMainHand().hasItemMeta())
return;
Random rnd = new Random();
int n1 = rnd.nextInt(-11,11);
int n2 = rnd.nextInt(-11,11);
int n3 = rnd.nextInt( 11);
if (!(event.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasEnchant(Enchants.LIGHTNING)))
return;
if (n3 <= 9) {
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation().add(n1, 0, n2));
} else {
event.getPlayer().getWorld().strikeLightning(Objects.requireNonNull(event.getClickedBlock()).getLocation());
}
}
Don't mind the terrible code
Is it possible when using TextComponents hover event that I can pick and choose certain parts of the string to be hoverable, like a string "AT" is the only hoverable thing.
It's so weird how another event works but ONLY this specific part needs me to reload
like reload the server?
yeah
what happens if you dont reload?
I was thinking maybe it had to do something with unoptimized code?
If I don't reload the enchant doesn't work but the weird part is the other enchants do
Why not if Action == an action?
Well I am trying to make it only activate the enchant when you swing the item with the enchant
is there any way to colour death messages with the setdeathmessage function?
becuase i cant use chatcolour 🤔
Does ChatColor.translateAlternateColorCodes() work?
hmm ill check
Trying to look through your code a bit weeb but I don't see how it wouldn't work
Yeah, I have zero idea why
I'm comparing it to older stuff
All the other code works
could it be the way youre registering the event?
Maybe?
Your trying to get it to strike lightning on a block aimed and clicked on right?
Well it randomizes a random area around the player to have lightning strike or a 10% chance of striking the actual thing they are attacking
btw the way I am registering the event is this.getServer().getPluginManager().registerEvents(this, this);
cant i just use &c before the string to make it red?
In Minecraft, there are color codes and format codes that you can use in chat and game commands. Here is a list of color codes and format codes that are available in Minecraft:
thnx ill check if it works :DDDD
Weeb you said you had others that work perfectly fine are there any similar to this one in like randomizer setting?
So far I only programmed this enchant and another which just has items go into your inventory instead of on the ground
CraftPlayer{name=PureEnderman}&cWas Shot By Hunter! wasn't what i was expecting lmao
var deadplayer = event.getEntity();
event.setDeathMessage(deadplayer + "&cWas Shot By Hunter!");
Ok just asking to see a comparison that way I could see if there was a change
You need to do ChatColor.translateAlternateColorCodes(deadplayer + "&cWas Shot By Hunter!"));
At least I am pretty sure
Yeah, imma try that and see if maybe that is the issue
hmm ill try thnx
so like this?
var deadplayer = event.getEntity();
ChatColor.translateAlternateColorCodes(deadplayer + "&cWas Shot By Hunter!"));
event.setDeathMessage(deadplayer + "&cWas Shot By Hunter!");
No
ChatColor.translateAlternateColorCodes('&', deadplayer + "&cWas Shot By Hunter!")
thx sm
Removing randomization still leaves it needing me to reload the server
so once you reload it work?
Yup
thats really weird
Imma try to remove other code instead to see if maybe that it interfering
var deadplayer = event.getEntity();
ChatColor.translateAlternateColorCodes('&', deadplayer + "&cWas Shot By Hunter!");
event.setDeathMessage(deadplayer + "&cWas Shot By Hunter!");
didnt work lmao
i should maybe learn java also
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.
this returns a string, put it in the setDeathmessage method
lmao thnx
event.setDeathMessage(ChatColor.translateAlternateColorCodes('&', deadplayer + "&cWas Shot By Hunter!"));```
yay thnx
Hey I'll be back on tomorrow at around 8:30-11:00ish EST so I can get some things done want to get back into coding but it's been years and java had been long forgotten so yqll have a good night
you too!
Will do loki
Alright I removed all other code, ONLY that part needs me to reload the server
ok im closer now
CraftPlayer{name=PureEnderman}<this next part is red>Was Shot By Hunter!
Are you referencing the wrong thing for deadplayer?
Alright, im getting off for the night, cya!
Goodnight
gn!
What's a good place to share plugins? Is there like a forum for that?
So far ive found curseforge
Haha where exactly? All I could find is the archived forums for plugins
So... how can I have multiple configs? I was able to to create a custom (main one) but I need another YML file to store data (player name).
I don't think I can use the .reloadConfig() for the second one because its being used by the first (main) config. Here's what I have:
Issue: Only this section of code requires me to reload the server, after reloading if I spam the server enough with lightning it gives me the error code of "Could not pass event PlayerInteractEvent to CustomEnchants"
Use: If the player has the enchant Lightning it randomly has lightning spawn around the player with 10% chance of hitting the thing they are attacking
@EventHandler
public void PlayerEvent(PlayerInteractEvent event) {
if (!(event.getAction() == LEFT_CLICK_AIR || event.getAction() == LEFT_CLICK_BLOCK))
return;
if (!event.getPlayer().getInventory().getItemInMainHand().hasItemMeta())
return;
Random rnd = new Random();
int n1 = rnd.nextInt( 11);
if (!(event.getPlayer().getInventory().getItemInMainHand().getItemMeta().hasEnchant(Enchants.LIGHTNING)))
return;
if (n1 <= 9) {
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation().add((rnd.nextInt(-11, 11)), 0, rnd.nextInt(-11, 11)));
} else {
event.getPlayer().getWorld().strikeLightning(Objects.requireNonNull(event.getClickedBlock()).getLocation());
}
}
Hopefully with this error it gives you a hint
Which Minecraft versions besides 1.18 are commonly used today? I'd like to make my plugin backwards-compatible and I'm wondering what versions to focus on
Check bstats
^
How can I get InventoryView of an inventory?
I fixed it, I either had too many checks or making it all one check for some reason fixed it
boolean randomChosen = false;
int randomIndex = 0 + Bukkit.getMaxPlayers() + (int) (Math.random() * ((Bukkit.getMaxPlayers() -0) +1));
var hunter = list.get(randomIndex);
does hunter contain the name of a radom player out of the online ones?
assuming list is Bukkit.getOnlinePlayers(), yes
well the Player variable, not the name
int randomIndex = 0 + Bukkit.getMaxPlayers() + (int) (Math.random() * ((Bukkit.getMaxPlayers() -0) +1));
List list = new ArrayList(Bukkit.getOnlinePlayers());
var hunter = list.get(randomIndex);
onlinePlayer.sendMessage(hunter + " Is The Hunter!");
Gives a lot of errors when i execute it in minecraft any ideas
you can't use var in java
you have to also define what type of list it is
you are just using a generic list
*hmm
You can, but in Java 10 lol
and theres no point adding Bukkit.getMaxPlayers() onto 0
ah yeah i forget that
I didn't know that, Sound's bad
ok i just wanna store a variable or string with list.get(randomIndex); so i can use it in a message
List<Player> players = Bukkit.getOnlinePlayers();
Random rand = new Random();
Player hunter = players.get(rand.nextInt(players.size()));```
this should do the same trick
and is much simpler
OooOO thnx
i really advise getting to know java better it will help you a lot
Didn't this guy ask the same question before?
deadplayer.getName() if no one figured it out yet
How can I make a hover effect for multiple words in a string?
nobody did thnx
Reason being is because in Java when you print out a variable it will just print out the object
And yeah this, I was losing my mind on somethings trying to do bukkit when I didn’t learn Java yet
Speaking from experience it’s probably more beneficial to learn Java first
bungee's chat component api?
yup
wdym then
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I wanna make it so that two words in a string can be hoverable, so take for example this:
Would you like to buy or sell this item?
Where buy and sell are on the same line and both hoverable, so far I can only get the entire line to be hoverable
make them separate components and append them together
that will make them on the same line?
should yeah
alright give me a bit to set that up
it would be addExtra i think
not append
TextComponent buy = new TextComponent("buy");
buy.setHoverEvent(...);
TextComponent sell = new TextComponent("sell");
sell.setHoverEvent(...);
TextComponent question = new TextComponent("Would you like to ");
question.addExtra(buy);
question.addExtra(new TextComponent(" or "));
question.addExtra(sell);
question.addExtra(new TextComponent(" this item"));```
probably like that
alright ill try that out, I broke my code so im trying to fix it now lmao
Oh awesome it works, I legit just spent 3 hours trying to find that on my own... never tried the simple solution
welp that's coding for you sometimes
Don't worry guys. I figured it out.
What plugins that allow not to break and place block?
What is the comment anyway @quaint mantle
hey how can I make a hover able item in chat
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I've looked through that already, didnt help
Show what you tried
Right now I have it setup as a ShowText thing, but I tried this:
new HoverEvent(HoverEvent.Action.SHOW_ITEM,new BaseComponent[]{new TextComponent(CraftItemStack.asNMSCopy(ItemStack).save(new NBTTagCompound()).toString())});
^ this one throws errors
I found that one online and am currently trying to make my own since im not too fluent in NMS
alright let me look into that
what is IChatBaseComponent?
The NMS version of a chat component
^
how do use
Quick question why do you need it
for tablist header and footer
There’s API for that
What version are you on
1.8.8
Sigh, never mind
Uhh how do I spawn lightning in the direction the player is facing?
Get the players facing vector, multiply it, and then convert that to a location
Which you can then use with World#strikeLightning
Ah
why not p.getTargetBlockExact
You can also just use the rayTrace methods if you want it to stop at closest block
Kk
You could also do that if you want to target a block, yes
yeah cuz this is what I use
I have my max distance to 100 blocks
then I just do p.getWorld().strikeLightning(location)
after getting the location of the block the player looks at
Heyo — Looking for an idea here; what would be a decent way to execute something whenever the player gets a specific amount of an item?
Currently I just check the output of item pickups and crafting but I'm not sure if there is a better way to do this
That’s probably a decent option
Do you want them to have the amount on them, or to have just obtained the amount
To have the amount in their inv, so for example if they have a total of 8 sun flowers named "flower" or something
You could check their inventory with a runnable, but that may not be ideal
Yeah :(
I suppose the current way will work, I guess since it's a rename, I should also check for anvil renames and such
I wonder if checking inventories is safe async
Just checking it maybe
Yeaaaah I think that might be fine
Yeah then you can sync back to the main thread to do whatever once the condition is met
I've done world reading async. No issues detected so far but uh I'm aware it's not ideal
:p
how send sound to player that sent command
Make sure the sender is a player, cast, and then use Player.playSound
ok thanks
how to make sure the sender is a player ._.
instanceof
not that dumb lmao thnx anyway
not that thumb 🤡
yes.
Ur a thumb
ngl coming back to Spigot after using Java 16-17 for so long was great, love the patterns and all the other new features
um but it says its a non static method (playsound)
work on a player object
Player#playSound if you prefer
get your player from a command or a listener, etc.
Yes, you need an instance, hence the casting
if(sender == instanceof Player){
Player.playSound(Player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
}
no i dont know java how did u know
if(sender instanceof Player player){
player.playSound(Player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
}
Player player = (Player) sender;
lesgo thanks
thats java 11
sorry I don't speak outdated
sorry i dont speak modern java
oh my bad
That’s not how you instanceof
LOL
lol yeah nvm
No ==
I just copied it all
lamo
there
i dont know anything 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.
nvmind
Might want to get started with some of the java stuffs
i think i should just continue making my storage 🤦♂️
Can it store memes
If it can't store memes then whats the point
hey
was wondering if there was a quick way to turn itemstack into item?
or only throwing the itemstack to do it
grr
World#dropItem
@ivory sleet 🤡
why is this working .... but the second one not ? why the heck can you set something private final to null but not to smth else ?
Is one of them static
one more question
how to detect clear weather?
i have this to detect rain and it works
pl.getWorld().getClearWeatherDuration() == 0 || pl.getWorld().hasStorm()
but reversing it does not help me detect clear weather
!(pl.getWorld().getClearWeatherDuration() == 0 || pl.getWorld().hasStorm())
idk what to do exactly
i think i tried this but fine thx
will try again
pl.getWorld().getClearWeatherDuration() > 0 && !pl.getWorld().hasStorm();
this?
Yes
ty
how can I get ItemTag from an itemstack?
google?
Use the ItemTag construtor and give it what it wants
i wish everything was googlable, it gives nbt tag results, not ItemTag
is an itemtag not nbt?
ItemTag is a separate class
doesn't have a constructor
and also this to work with
public final class ItemTag {
private final String nbt;
private ItemTag(String nbt) {
this.nbt = nbt;
}
public static ItemTag ofNbt(String nbt) {
return new ItemTag(nbt);
}
private static ItemTag.Builder builder() {
return new ItemTag.Builder();
}
public String toString() {
return "ItemTag(nbt=" + this.getNbt() + ")";
}
// removed equals and hashcode to bypass discord character limit
public String getNbt() {
return this.nbt;
}
private static class Builder {
private String nbt;
Builder() {
}
private ItemTag.Builder nbt(String nbt) {
this.nbt = nbt;
return this;
}
private ItemTag build() {
return new ItemTag(this.nbt);
}
public String toString() {
return "ItemTag.Builder(nbt=" + this.nbt + ")";
}
}
public static class Serializer implements JsonSerializer<ItemTag>, JsonDeserializer<ItemTag> {
public Serializer() {
}
public ItemTag deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
return ItemTag.ofNbt(element.getAsJsonPrimitive().getAsString());
}
public JsonElement serialize(ItemTag itemTag, Type type, JsonSerializationContext context) {
return context.serialize(itemTag.getNbt());
}
}
}
no ItemStack anywhere there
anyways, @granite burrow why do you need to do it?
using it for the Item interface, trying to make a [item] type thing with no NMS, or atleast minimal and this seems like the best way other than whenever I look up how to get the ItemTag I need to use NMS
Item thing im talking about:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Item.html
declaration: package: org.bukkit.entity, interface: Item
[item] type thing?
its basically when you type [item] into the chat it will send hoverable text showing the item
let me get you an example
Olivo told me to
yeah but you are using the spigot item here
alr that may be my issue let me check my imports
alr I was on the wrong page, I was using import net.md_5.bungee.api.chat.hover.content.Item; as my imports
yeah, I just was looking at the wrong link, was on spigot API not bungee just to clear stuff up about that lmao
I think id is for the minecraft:cobblestone thing
should i load all the homes of an user when logs in instead of having to wait until they are loaded from the db when he requests them?
Yes
when requested
then maybe save it so you dont have to make another request everytime he requests it
i didnt have the problem before cause they were saved in yaml and i could instantly load them all
yea ofcourse caching
if it is stored locally sure load them when logged in
only store them when requested if youre using a host
but i dont want to have those things like essentials have, to wait two sec before the tabcomplete options appear
so i thought maybe load them on login
and the max amount per player is 3 so
I mean unless a user has 10000 homes the amount of data in memory should be tiny
api endpoints usually respond within 200ms, so I don't know why 2 seconds
maybe their network is overloaded
Essentials uses flat file
just load them all on server startup xd
not all
i will just load them when the player logs in and cache them for a while until they logout
I mean if 3 homes is max, and assuming an average server only has 10 players, it might only take kilobytes of memory
all would mean from every player that has ever played and has atleast one home
fair point
i know what to do
this is the dumbest thing i have ever been stuck on
how to send a sound to a player that executed a command lmao
We told you
Then you didn’t execute it right
hmm yes the floor here is made out of floor
lmao i just want to give a villager disagree sound to someone that executes a command if theres 1 or less players online
Anyone know why is that? Clearly it's "spigot" not "spigot-api", it was literally working till yesterday, and yes I have built 1.18.1 remapped jar with buildtools, it's looking in the wrong path
can anyone give me an example of how to send a command executer player a sound
check if the cmd exe is player, cast it to player and then play sounid
how lmao
java ^^
yes
hmm how check if player executed (i cant remeber the bukkit.getcommandexecutor thingy)
do you know instanceof ?
yea
but whats that crappy getcommandexecutor thing
i can literally never remember it
What
nvmind
having this with a mysql and yaml implementation does that looks good?
if(sender instanceof Player player){
player.playSound(Player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
sender.sendMessage(ChatColor.RED + "You need at least 2 people to start the parkour!");
}
doesnt work and im dying inside
the only thing makes me sad is yaml implementation
the problem is just that PLayer.getLocation has decided to commit not live
im probably not doing yaml too
i was like "that depends on the user's choice"
Just do H2
then the question is what type of user do you even want to support
MariaDB tho ^^
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.playSound // bla bla bla
}```
YES
ignore those annotations
THANKS
you should better start with learning some basic parts of the api
like commands, listeners
🥣
its the same as looking on the forum
what's special for MariaDB?
did you register a command?
yes.
is your code EXACTLY the same?
yes
because if it is then your problem is that you do Player.getLocation(), not player.getLocation()
you need to check in the onCommand if the cmd.getName() equals the command name you want and then exexute the code to play your sound
player is your varibable
Hello! I try to buy a plugin but it doesn't let me because of a paypal error and I go to a server and it lets me pay.
Player is a class
I mean, its under LGPL
fixed
You can support both easily still
show your like entire class that you have
Hello! I try to buy a plugin but it doesn't let me because of a paypal error and I go to a server and it lets me pay.
i dont know much about licences lol
My current storage system relies on turning stuff into strings for storage
Usually via gson
🆗
lol
Losing all relational database advantages
It was suggested to me as it’s easy to abstract
i am now curious how many times Microsoft developers asked questions on stackoverflow
idk why
Not like various random player data is very relational
For example?
i have data that needs to be linked and date that doesnt need
Homes, balance, punishment info
It’s relational to the player, but not really anything else
I don't see any problems of storing this in tables
It will be stored in tables
does h2 uses the same sql syntax as mysql?
I’m just doing the lazy method of turning it into strings so I don’t need to write adapters for each object type
nvm it doesnt
Adapters for each storage medium and each object type at that
Unless you have suggestions to remedy that
the amount of storage solutions is sometimes overwhelming
!verify
Usage: !verify <forums username>
then you can
how can I create this?
to showcase my config in this format
I just know [SPOILER]
is this valid yaml?
create a config.yml file in your resources folder
if you want to specify default options
then create what?
a spoiler on the description that showcase the config in this format
nms Material to bukkit Material ??
The editor has a button for that
oi
wait wha-
🍆
some people on my server are picking up water and it is making ghost air, is there a way to send a block update to revert it back to water/lava on their screen?
other players cant see the gaps in the water
so its something client side
block.getState().update();
get the block, the blockstate and update it?
yed
do you block it?
Alternatively you can use player#sendBlockChange
why dont they fix that bug
would that work
try and see?
if it doesnt work try
ok ill go see
:D
CraftMagicNumbers
Help me pls
'${project.version}'
${project.version}
ty
this was the correct answer!
Tap the + in the top menu and select </> code
:)
jesus
someone tell me some plugin to put the /premium on your minecraft server is that all are not premium ie they do not have to autologearte
wut
Offline mode is not supported here
autologearte
bungeecord :(
Okay, Piracy is not supported here*
Can I know where the player's damage is coming from?
Check the damage cause of the damage event
wait does yaml needs ' ' for strings?
?jd-s
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
Yaml does not need ‘ or “ for strings
Or BlockDmaage
oh
I’m sure there are other cases to use them too
how do i check a event player's gamemode
Pretty sure it’s just Player#getGameMode
thnx
You really should use the javadocs
this is faster
Not when we stop helping you answer basic questions
just google
hmm
java docs just doesnt tell me how to check it for a player tho
ill keep searching
;
what are you looking for
can i use this?
public GameMode getNewGameMode()
and what are you trying to do
check player gamemode
player#getGameMode()
in an if statement
ty
bro
learn java
seriously
you shouldn't be coding plugins with this knowledge of a language
the player.getGameMode() is the current gamemode of the player, event.getNewGameMode() is the gamemode the player will have if the event finished executing
how can i get an entity type from its namespace key
you can probably try to turn that namespaced key into a name
like minecraft:zombie into ZOMBIE, and then EntityType#valueOf("ZOMBIE")
should work
Interesting that there is no getByKey
yeah
Or fromKey or whatnot
only fromId and fromName
both deprecated
so yeah i think you want to turn it into an enum value
nvm i found its Registry.ENTITY_TYPE.get(
file is a parameter name iirc>
How does H2 compare to SQLite
yep:
} else if(type == StorageType.H2) {
Path path = plugin.getDataFolder().toPath().resolve("clans");
url = MessageFormat.format("jdbc:h2:file:./{0};mode=MySQL", path);
username = "sa";
password = "";
}
h2 mode = mysql wha-
idk probably support for some mysql specific syntax
so i have this:
List<Player> players = (List<Player>) Bukkit.getOnlinePlayers();
Random rand = new Random();
Player hunter = players.get(rand.nextInt(players.size()));
can i teleport or do stuff with the player hunter?
please are you still struggling with the same problem
also use ThreadLocalRandom.current() instead of new Random()
ok thnx
but can i telport and do stuff with hunter
i am just curious
do you know why you put the (List<Player>) there, or just blindly doing it because your IDE told you to?
casting isnt even needed
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.
i think he got the links for the fifth time now
the unstoppable
eigth
[16:36:30] [Server thread/INFO]: [EnderRider] Langage selected: error ! (English)
[16:36:30] [Server thread/ERROR]: Error occurred while enabling EnderRider v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
at enderrider.enderrider.utils.Lang.loadLang(Lang.java:23) ~[?:?]
at enderrider.enderrider.Main.onEnable(Main.java:55) ~[?:?]
help
wow no way u can do that
go ahead
fix it or give us the code
in your example, is "clans" a file?
Student: Hello can you help me with this problem?
Teacher: Sure!
Also Teacher: Reads problem
i'm better in coding than my teacher 🤡
is mv.db some kind of file extension?
i think so, but, you don't have to define it manually
just something like/this/should/be/fine
so if my h2 db file was called "database.h2" i should do .resolve("database")?
yes. you don't have to create a file manually
Can I just check if the player has this item and ignore the amount?
isSimilar ignores amount
Bukkit.getPlayer("whes1015").sendMessage(String.valueOf(Bukkit.getPlayer(event.getDamager().getName()).getInventory().contains(itemStack)));
ItemStack itemStack = new ItemStack(Material.valueOf(String.valueOf("WHITE_BANNER")));
containsAtLeast exists
List<Player> players = (List<Player>) Bukkit.getOnlinePlayers();
Random rand = new Random();
Player hunter = players.get(rand.nextInt(players.size()));
Is it possible to teleport everyone except the hunter?
yes
this is above my braincell capacity google come help
exists?
loop over Bukkit.getOnlinePlayers()
ok and player != hunter
Yes, the method exists
y e s
you can do List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); Player hunter = players.remove(new Random().nextInt(players.size())); // and teleport players
hmm what do i put in statement 3 of the for loop...
i have:
for (Bukkit.getOnlinePlayers(); player != hunter; propobly like list add nothunters or something){
What...
LEARN FUCKING JAVA
yes
I don't know
help me
This challenge page was accidentally cached and is no longer available.
when i go to the webiste spigotmc.org showing like this error
This challenge page was accidentally cached and is no longer available.
guys did i do something i think i did it idk
for (Bukkit.getOnlinePlayers(); player != hunter; player.teleport(new Location(Bukkit.getWorld("Game2"), 0, 65, 0)))
soo does this tp everyone that isnt a hunter to 0 65 0...?
it stops if player is hunter
hn
so
if it checks a hunter before some other players, they just dont get tp'd?
yep
for(Player player : server.getOnlinePlayers()) {
if(player == hunter) continue;
player.teleport
}
help me
This challenge page was accidentally cached and is no longer available.
when i go to the webiste spigotmc.org showing like this error
This challenge page was accidentally cached and is no longer available.
help me
This challenge page was accidentally cached and is no longer available.
when i go to the webiste spigotmc.org showing like this error
This challenge page was accidentally cached and is no longer available.
guys im dying whats wrong with this:
Player nonhunter = (Player) Bukkit.getOnlinePlayers();
hunter.teleport(new Location(Bukkit.getWorld("Game2"), -9.5, 75, -4.5));
for(Player nonhunter : Bukkit.getOnlinePlayers()) {
if(player != hunter) continue;
player.teleport(new Location(Bukkit.getWorld("Game2"), 0, 65, 0));
}
You can't cast multiple players to one
oh
Avoid casting anything if you don't know what you're doing
why
create a symlink
and having to copy and paste
nah
I just wanna compile
to that folder
how to I change it?
@boreal sparrow just loop through the players list in this
essentially is just creating a copy of the players list and removing 1 player (the hunter)
How is the packet called to give a player the freezing effect?
