#help-development
1 messages · Page 145 of 1
is there a way to get org.bukkit.Color from a string?
i don't wanna have to get the rgb codes for my config
I've only just realised that you can't actually even copy run configurations between projects (unless I code my own IDEA plugin for it which I cba to do) so I have to set it all up every time I create a new project 😭
bump
I have a system for adding teams to a player, is there any way I can fix new players not being able to see old player's teams?
// Create scoreboard and teams
public static void setNametags(Player p) {
p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
for (Rank rank : Rank.values()) {
Team team = p.getScoreboard().registerNewTeam(rank.getOrderSymbol() + rank.name());
team.setPrefix(ChatColor.translateAlternateColorCodes('&', rank.getDisplay()));
team.setColor(rank.getColor());
}
}
// Assign player to their team
public static void newTag(Player p) {
Random r = new Random();
Rank rank = Rank.values()[r.nextInt(Rank.values().length)];
for (Player target : Bukkit.getOnlinePlayers()) {
target.getScoreboard().getTeam(rank.getOrderSymbol() + rank.name()).addEntry(p.getName());
}
}
// Remove player from all scoreboards
public static void removeTag(Player p) {
for (Player target : Bukkit.getOnlinePlayers()) {
target.getScoreboard().getEntryTeam(p.getName()).removeEntry(p.getName());
}
}```
wdym
like player 1 joins and player 2 joins, player 1 can see the team and nametag of player 2 but player 2 can only see their nametag and team and not player 1's
sorry, i dont know
All good
Ntdi
You have to update the players
Im not sure how its done
But every time a player joims you need to update the nametags
java.lang.IllegalArgumentException: Invalid key. Must be [a-z0-9/._-]: PROTECTION_ENVIRONMENTAL
bruh
oh
wait it should be lowercase, huh
Hey, is there a way to disguise an entity such as a zombie as an EntityPlayer?
public void randomTP(Player p, World w) {
Random rand = new Random();
int bounds = (int) (Math.round(w.getWorldBorder().getSize()) - 5); // padding
int x = rand.nextInt(bounds * 2) - bounds;
int z = rand.nextInt(bounds * 2) - bounds;
Location loc = new Location(w, x, w.getHighestBlockYAt(x, z) + 1, z);
int tries = 0;
while (!w.getBlockAt(loc.clone().add(0, -1, 0)).getType().isSolid()) {
tries++;
x = rand.nextInt(bounds * 2) - bounds;
z = rand.nextInt(bounds * 2) - bounds;
loc = new Location(w, x, w.getHighestBlockYAt(x, z) + 1, z);
if (tries > bounds * bounds) {
break;
}
}
p.teleport(loc);
}```
the method doesn't randomly tp
its horrible i can tell
?doesntwork
what the name suggests
randomly teleports within bounds
actually i could use /spreadplayers
that might be better
First of all what its bounds
Does anyone know how can I give a potion to a player inside a BukkitTask
Pass the player to the task
it's meant to randomly teleport them from a whole different world
to a random place within the border
Ohh on
I catch 8t
He want to teleprot a player a random location without leaving the world bordes
I thought he was trying to teleprot the player to another random player
🤣
I mean he first said that
Yes
When you have issue without errores
You have to make something called debug
Which is a process Where you add Messages to see what its working or not
No reason to use the logger for debugging
Yes but it requires a plugin instance
And passing one just for debugging if you don’t already have one is annoying
Bro why are you mad lol I made a suggestion nothing to do with you :/
I would assume it’s a command so easy to dependency inject
It has the plug-in name and the time so that’s why it’s used
Cool no one asked
Using a proper logger includes class name as well
Yes, have you never used a proper logger before?
Obviously not :/
It's just something useful to have. Timestamps are important only if you need to backtrace an event to a time. If someone complains your plugin threw an error yesterday at noon and sends you a log that's thicker than a snowstorm it's great to be able to use timestamps to find it
Potentially, yes. But it's good practice to have it imo. Have you every accidentally left a println somewhere and had to track it down? It's a lot easier when it's a logger that tells you the class name
or just ctrl + shift + f search for it
Sounds like a lot of work for a problem you don't need to have
fair
can scoreboards do precise colors?
i cant post images here but i did one in chat and i did one on the scoreboard and the scoreboard one looked really messed up
?img
Not verified? Upload screenshots here: https://prnt.sc/
alright
imma post it in a sec
look at chat then look at scoreboard
something is wrong
i dont fully understand why it does this
my guess is that they do not do accurate colors maybe but i have no idea truly
'getName()' in 'org.bukkit.Bukkit' cannot be applied to '(java.lang.String)'
Player target = Bukkit.getPlayer(Bukkit.getName((args[1])));
what the fuck are you doing
A gamemode command
it's just Bukkit.getPlayer(args[1])
like Bukkit.getName() is something COMPLETELY unrelated
and why you have two damn sets of parenthesis for getName is also beyond me
to get the username it's
target.getName();
though welcome to Java & I hope you enjoy it
bro
to get the Player object using their username, you use Bukkit.getPlayer( the username, so args[1] )
then to get their name, to print it, you use player.getName()
np
yeo yall know about the slime farms at all ?
u didn't define target
I did.
that hurts my eyes
Does anyone know what enchantment can be applied to pretty much anything? I am needing to enchant an item in my gui but its yelling at me cause its an enchantment not meant for the item.
So much wrong with it. There's a reason it's so difficult to find the issue
1 error at a time 🙂
No not error. Just really bad practice
what line is that
You don't declare your target variable is the only error
why does it need to be so complicated
cause i'm new to java
your formatting is off. The entire thing is scoped really wackily
if you're in intellij spam ctrl+alt+L every 5 lines or something
bet
How can i make models
Blockbench?
I dont think it did anything
disregard. I forgot unsafe enchantment is a thing lol
like, you can condense all of these into a few lines
control alt l did nothing
Could probably shave around 75-100 lines from it
use switch() and add a setGamemode(Sender s, Player target) method
no need for a switch for that code
e
its the same thing but he just changed the strings
it would be cleaner imo
Bukkit.getServer().getConsoleSender().sendMessage("§e§lYou
wtf
just do sender.sendmessage
itll work with console
like I knew that
like you could make it smaller but 99% of the data fits in a simple function call
Look up Blockbench tutorials
Is it hard? Or texturing?
Use getDisplayName()
use item meta's addUnsafeEnchantment
will allow you to add anything with any level to anything
no need, It has no actual use other than just showing that its enchanted lol
yeah so just add protection to a sword so it wont do anything
and hide the enchant list
with an item flag
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
at sun.security.ssl.SSLSocketInputRecord.decode(Unknown Source)
at sun.security.ssl.SSLTransport.decode(Unknown Source)
at sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at org.spigotmc.builder.Builder.get(Builder.java:795)
at org.spigotmc.builder.Builder.main(Builder.java:277)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)```
help
so i need to wait?
when i open spigotmc this page is looping so i can't access spigotmc
like when its done its loading again and repeat
make sure your computer clock is set to teh correct time/date
already
site is fine for me by the way, so its local to you or specific to you
did you modify any ssl settings on yoru computer?
cloudflare
are you on a vpn?
No
Did you change anything at all since yesterday?
ofc no
Then no clue.
Why do you want 1.16.4
yess now the web working because i forget my network and connect it again
for my plugin
Isn’t it basically identical to .5
idk but it says need 1.16.4
what says
wait
> Task :version-support1_16:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':version-support1_16:compileJava'.
> Could not resolve all files for configuration ':version-support1_16:compileClasspath'.
> Could not find org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
- https://repo.maven.apache.org/maven2/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
- file:/C:/Users/Nurisantoso/.m2/repository/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
- file:/C:/Users/Nurisantoso/.m2/repository/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
- https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/maven-metadata.xml
- https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot/1.16.4-R0.1-SNAPSHOT/spigot-1.16.4-R0.1-SNAPSHOT.pom
Required by:
project :version-support1_16
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 30s
7 actionable tasks: 1 executed, 6 up-to-date```
that
no before issue is 1.12.2 and i build 1.12.2 with buildtools and solved :/
I would advise changing to 1.16.5
^^
Should be a simple edit in build.gradle
cant say ive done multi-module, so im guessing its either in the version-support1_16 build.gradle or the main build.gradle
Can you help me do this? i don't know so much Java
Looks like this is for a rank system. So when a new player logs in, you're gonna have to loop through everybody and assign their teams on that new player's scoreboard so they can see the nametags. Kind of like how you have to set the team of the new player for everyone else.
This is math. Theres nothing to help with other than do it for you. You literally need to reverse the Y iterator.
replace y1 for y2? dont hate me
yes
thanks
there are two bits you need to modify
the return of hasNext() and the value of Y in next()
in next() you need to loop from max Y to min Y instead of the current 0 to sizeY
basically reversing it and decreasing instead of increasing
Line 708 you need to set y (and only y) to its max value, not zero
line 712 you need to check for y > sizeY
Do you have a good custom config tutorial
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
alright so i need some advice
i'm working on my Minigame Library
and I want to remove boilerplate code when creating minigames
so i am thinking of having different interfaces depending on the type of game (e.g. team game, solo game),
and the custom MinigamePlayer and Minigame class to implement them
is that a good idea?
or is there a better way
Do you have load(); , save(); , get(); methods for custom configs
no
😦
.
anyone able to help?
sorry if i'm sounding desperate, i'm kinda trying to get this started
also return x < sizeX && y > 0 && z < sizeZ;
xd
You have errors because you didn;t copy the original correctly
this.w ? Thats a world but you have no w field in that class
You need the whole class
and modify precisely what I told you.
ik, I'm doing in on my phone for tmr pass it to my pc
line 28 may need to be just < and not <= but you will have to try it and see
hi anyone know a good way to
checks if the started week is the same as the current week
and if day, if the day the quest has started at is the same as the current day
if there's no match, it'll say false
so when i finish the quests of today , tmr i can't finish them .. nothing happend , its bcz of this code right here :
help
is it possible to get PersistentData of a offline player?
anyone have an idea?
Do you have configuration class
here the full logs https://paste.md-5.net/aqamewarax.cs
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git: connection failed You have internet issues
Elgar
ideas?
ah yeah now working
Saving and loading config
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
I have to call saving from onDisable(); method right?
I can hardy see my mobile screen.
anyone ?
Its been many years since I messed with a gregorian calendar. Can;t help you.
Fairly sure you can convert a timestamp into a date fairly easily
And then do some math from there
You may even be able to convert it to a calendar and then use the methods from that class
thx ..
If you want a simple way to tell if something is passed a deadline```java
Instant start = Instant.now();
Duration duration = Duration.ofDays(1);
Instant finished = Instant.now();
if (finished.isAfter(start.plus(duration))) {
// To late
}```
yes, its just millis
long startedDate = System.currentTimeMillis();
Instant start = Instant.ofEpochMilli(startedDate);
Duration duration = Duration.ofDays(1);
Instant finished = Instant.now();
if (finished.isAfter(start.plus(duration))) {
// To late
}```
You should have a quest, when it starts and how long it runs for.
then you would get teh start data/time and its duration
yes i can
no need for posudo code or smth , just tell me what i must do to get it fixed
bcz the problem right now is weird
when i finish a quests & challenges today
and i play tomrrow ,
i can't get any rewards
it stop right here :
code return right here
it worked 5 minutes ago then i reconnected my wlan and now it doesnt work anymore tf
public boolean isInTime(Quest quest) {
Instant finished = Instant.now();
long questStarted = quest.getStarted();
long durationOfDays = quest.getDuration();
return finished.isBefore(Instant.ofEpochMilli(questStarted).plus(Duration.ofDays(durationOfDays)));
}```
if you make your quest return Instants it makes it a lot easier
you didnt type it correctly
how would I return a class that implements an interface
if that's possible
I have a Team interface in my library and in each plugin using the library, it should have an Enum which implements the Team interface
you return the interface
and i have a MinigamePlayer class which should return the new Enum that implements the Team interface
yeah i know
i already do that
but surely there is a way without casting
well if the MinigamePlayer can only return the enum, then have it return the enum
public class CraftTeam implements Team { }
public Team getTeam() {
return new CraftTeam();
}```
the minigameplayer is in the library and cannot use the enum because each minigame that uses the library has a different team enum
but each team enum implements the team interface (they aren't called the same thing ofc)
oh you changed it
lol
yep
public @Nullable MinigamePlayer getMinigamePlayer(OfflinePlayer p) {
Optional<MinigamePlayer> minigamePlayer = playerList.stream().filter(mp -> mp.getPlayer().equals(p)).findFirst();
return minigamePlayer.orElse(null);
}
and is there a way to return this without having to cast it?
wait so where is the enum stuff used?
MinigamePlayer is to be extended when the user uses the library
it's abstract
yes
well this code does not know what other classes there might be , so you need to return the abstract and cast it in the implementation, that's kind of the point of making it abstract
org.spigotmc:spigot-api:pom:1.19.2-R0.1-20220922.001925-23 failed to transfer from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced. Original error: Could not transfer artifact org.spigotmc:spigot-api:pom:1.19.2-R0.1-20220922.001925-23 from/to spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): transfer failed for https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.19.2-R0.1-SNAPSHOT/spigot-api-1.19.2-R0.1-20220922.001925-23.pom
Try run Maven import with -U flag (force update snapshots)
Thats when i reload maven
can I cast a List<MinigamePlayer> to a List<ExtendedPlayer>
is that possible
or convert it somehow**
what is the relation between minigameplayer and extendedplayer
ExtendedPlayer extends MinigamePlayer
okay
well you cant cast it in one line
because a list of minigameplayers does not guarantee a list of valid extendedplayers
like you could make another class extend mp and have that list be a mix between extendedplayer and this new class
so you need to create a new list of extendedplayers
and then loop over minigameplayers
and cast and put it in extendedplayers if its valid
In theory, you could cast List<ExtendedPlayer> to List<MinigamePlayer> (tho might practically break depending on impl)
But it would yield a compile time warning
you can cast each indiviual element, i dont know if the java compiler allows (List<ExtendedPlayer>) MinigamePlayer
though this would assume every player in the list is of type ExtendedPlayer
if its not you get a runtime error
i code in pc i was just trying that on phone
Casting the whole list practically casts every element
Yeah
yes but if you dont want a bunch of nulls then converting it in your own loop might be more beneficial
The problem is that they might use an impl which derives List<ExtendedPlayer>
In which casting it to where a supertype is passed to the type param for the outer type would result in an error during runtime
But if you use for instance ArrayList
public List<ExtendedPlayer> getHexPlayerList() {
List<ExtendedPlayer> casted = new ArrayList<>();
for (MinigamePlayer p : getPlayerList()) {
if (p instanceof ExtendedPlayer ep) casted.add(ep);
}
return casted;
}
Then the type is guaranteed to be erased
would that work?
yes I think so
Yes
is it just .forEach()?
yes
or that
yes
(Doesnt filter nulls tho)
Does it?
null doesnt have a type so...
Yeah probably does speaking of which
intellij said replace with Objects::nonNull for that
so yeah i think so
Sadly you cant use collection::foreach as that is just effectively equivalent to stream::foreach
Tho it would be possible with side effects
why cant you use it then
It was worded poorly, you could use forEach just that it’d be somewhat awkward and stateful
i can't override the getPlayerList method using the List<ExtendedPlayer> so I had to create a new method unfortunately
idk it seems less clean
but oh well
He uses it alr
do i?
but I mean use more xD
Quared
You can use List<? extends MinigamePlayer>
and then for a given subclass that overrides a method that returns the aforementioned type, you could instead return List<ExtendedPlayer> if wanted
Oh then you meant a wildcard type
yes but its still part of the generic thing
but I couldnt come up with the name for it
Yes, but every type involves generics
Since every type can be passed to a (generic) type parameter (unless you restrict it)
Just use List<Object> everywhere

Heck why stop there? Just use Object.
yes I was about to say that lmao
💀
What method or way would i go about saving data of players who have been banned and then displaying it ina. Gui, so im making a punish gui, if the player has already been banned, it crosses that one out and then you click the next one (longer punishment)
Hey, how can I create paid resource on spigotmc?
Which part of this are you worried about
?premium
hi , sorry for bothering do you mean by : quest.getDuration is the current time of the quest?
iam not good at english sometimes
No thats how long the quest will run for, 1 day or 7 days etc
this is the current code
Saving the data and then grabbing it
Sql database, Mongo database, files. There are a lot of ways.
Yeah im going to use yml file i dont know how to grab data from there though and check it in if statements but i guess ill post in here when i get to that point and if i get stuck xd
Use the configuration api from bukkit. If you are quite new then i would simply load all bans
when the server starts and save it back when the server stops. And store all of this in one file.
Should be fine.
Okay thanks will give this a go
For loading files you can use class FileConfiguration from spigot api
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
?
noobs are everywhere
?
is anyone familiar with how plugins for stuff like minigames get integrated into bigger servers? like for example I am making my plugin but I intend on servers being able to use it as a minigame that can run paralell to itself etc. like are those just individual servers or whats the process for that kinda stuff
Write me an algorithm that gives me the velocity needed to throw a player from x to y, accounting for gravity and drag
you arent on copilot xD
well basically you need gravity formula of mc
or you just disable gravity for player and throw him forward
wdym
guys just install minigames and configure them on server
I have found the math for calculating the trajectory and initial velocity, but it doesn't account for drag
So the trajectory is inaccurate for longer distances
so do I then just add commands that the server can use to setup the game? because that's what I was thinking but idk if thats the common way to do it
i think most of the servers code minigames by themselves
Many use an in memory database
And a proxy
what does the database store
Data that is shared across different backends
Since synchronizing state is sometimes easier if layered behind some separate service
But also, a message broker like redis or rabbit is usually also rather crucial
Especially since plugin messaging isnt designed for independent backend to backend messaging
so is that to sync stuff like highscore or currencies or what across a server network?
Myeah
can be sessional also
Ofc you’d still use a persistency layered database also
As in memory would be wiped if you reboot
what about minigames that are really self contained, like I am making a bingo plugin and it doesnt really interact with anything, I would imagine from the players perspective you would join a lobby and then the game starts and let's say people can join mid game if they join the lobby
and when the game is over everything gets reset
what kind of sessional data would that need, or is it not applicable in this case?
Probably dont need sessional data then
But when you said minigame I imagine something like hypixel
that really scales
Pretty much
I mean the game itself is basic enough
Yuh
but then you would use whatever database stuff you described to manage scores and unlocked kits and whatever that can be used outside of teh direct minigame (instance)
Yes
okay that makes sense
yes thats a good one
Either you out those two behind your proxy
Or you have something like an in mem db such as redis
but in what way would I have to worry about that as the devloper of just the minigame
like I shouldnt care about how the players in a party get to join the same team right?
Idk depends on what exactly you are designing
beacuse I might now know the structure of the party system
Is it just the minigame?
well yes
It might be hard, but server owners would probably use other plugins for a friend system or party system, in that case you’d just have to interoperate those plugins
Either if they provide an api, or if you do
Though, what you presumably want to write is a proxy plugin, for bungeecord or velocity etc, which would manage the bed wars games life cycle
Assuming some server owner wants to have it split out and deployed multiple servers
Yea, good luck, but honestly Im gonna be genuine, writing mini game plugins is gross since you are pretty much bound to depend on poor apis of other plugins that server owners use
yes thats what I was afraid of as well, but ill see if I can find a way to be as little depended on other bs as possible xD
Minigames are not something i would write for the public to use
you mean you would only write them for actual clients
Yes where i have full control over the integration
I think that unless you're designing for a server you're going to have a bad time. You'd have to supply a massive API along with integrating a lot of others to the point where you're spending more time working on integration than minigames
hmm thats a good point as well
maybe I could just leave this plugin as it is for casual players to just play and if server owners wanted to use it in their servers charge for the integration (if its feasible for me to do)
?
Hey
Does anyone know how to make setIngredient a custom Item
Yes. Create an instance of RecipeCoice.ExactChoice
ok
should be making a customitems plugin ig
wachu know 'bout scrolling down the array
But what was the android ide?
Command not working after create recipe
When your brain goes null you can call that thread freeze :/
When there's people talking much put that shit in scheduler ay
Thank you for listening
i'm feeling like a senior dev in a dogshit
Doesn't it like create on demand
you get, set stuff and then save
There are attributes for that. Just add an attribute modifier with health on the armor
real easy tho
You can setup yml file by hand
config.set("yourArmorSet.healtPlus", 10)
now your armor has a 10 health value
Persistent
and you can get it from config
Here is an example of what you can do with attribute modifiers
lore 💀
You can always hide the attributes with a flag and create your own lore
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
But dont read/write files on runtime. Load them once the server starts and save them when the server stops.
In between do an async flush every 15mins
public boolean canBuy(Player player, int amount) {
if (getBalance(player) >= amount) {
return false;
} else {
return true;
}
}
is this a good way of doing it?
faulty logic
Also this can be simplified to just
public boolean canBuy(Player player, int amount) {
return getBalance(player) >= amount;
}
the second argument in the get is to specify a default value if the path you provided is invalid
thanks!
?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.
I hate regex.
CreateObject("WMPlayer.OCX.7")
What would be the regex to get what's in the CreateObject string?
e.g.
CreateObject("Example")
CreateObject("Example2")
\(\".*?\"\)
Regex is a fun and enjoyable experience.
I got lost at step 1 and now my computer is on fire
Wait, adding a group might help here to get the Strings inside.
(["'])(?:(?=(\?))\2.)*?\1
wtf is that xD
I hate regex
So do I but I need it for a specific non-MC project lmao
I would just use a named group
then
FREE JAVA LESSONS
CreateObject\("(?<the_string>\S+)"\)
I have a problem with my shield knockback, it keeps pulling me towards whatever I'm being hit by whenever I damage the player directly upon hit with their shield out.
And I have no clue how to fix it.
Specifying the string is not an option in this case @pseudo hazel
Have you tried turning it off and on?
Has to get any string
That doesn't work for a code issue.
<the_string>?
the \S is actually specifyng the string
Maybe hit it a few times, usually works for me
but idk if you also wanna use spaces
Un plug it, wait 10 seconds then turn back on
😒
(?<group>) is called a named capture group
I'm genuinely trying to fix the issue.
Not get told how to break my PC, reboot my router or reboot my PC.
pretty much all regex implementations then have a functio to match and get the groups by name
Did you edit the knockback already
Someone ples help https://paste.md-5.net/cevedejeqa.java
the command doesnt work and in the console it just says this
so like regex.match().group("the_string") would get you whats inside the ""
Any attempts to do that don't provide realistic knockback.
If the enemy is looking up and the player jumps, the player is launched backwards through the air.
I’m trying to work out why you’re having this issue
public static ItemStack shard;
public static ItemStack effecttoken;
Here is your first mistake. Public static mutable fields.
It's a weird bug by using .damage on the player while the player has their shield out.
It causes reverse knockback which just pulls me towards whatever's hitting me.
Hey @lost matrix can you take a look at this and see if you know why? https://www.spigotmc.org/threads/speed-up-smelting.573702/
so uhhh what am I supposed to do instead?
declaration: package: org.bukkit.event.inventory, class: FurnaceStartSmeltEvent
(I've been trying to fix this issue for hours)
Is there a way to disable spawner animation for the player?
atleast use something like shard.duplicate()
or whatever its called
clone()
Elaborate a bit more?
the libraries features not working on 1.8 server :/
?1.8
Too old! (Click the link to get the exact time)
Good
?
How can I create something that happens after like 5 seconds inside an event with listener?
?scheduling
I already told you @hasty obsidian
and also try to print to see if teh command gets executed at all
Create a method which returns a new instance of your ItemStack instead.
CraftMagicNumbers supported in no version. They are magic numbers for a reason.
So from which version I can use the libraries features? (in plugin.yml)
it doesnt rip
I think it was introduced in 1.16 or 1.17
do something like this
private static ItemStack createShard(){
ItemStack item = new ItemStack(Material.AMETHYST_SHARD, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED + "Revolution Shard");
meta.addEnchant(Enchantment.LUCK, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
return item;
}
Any exceptions in console?
when you call the method you want it to return the itemstack, not nothing which is what void essentially is
Never ever reload. This feature is not supported by spigot and will lead to errors in many cases.
what
do not use /Reload
what do I use instead then
use restart
new regex question @lost matrix
set (.+) = (.+)
How would I make it also look for set (.+)=(.+)?
Set objFSO=CreateObject("Scripting.FileSystemObject") and Set objFSO = CreateObject("Scripting.FileSystemObject")
for example
rip
Nunca recargar. Esta característica no es compatible con spigot y dará lugar a errores en muchos casos.
Ne jamais recharger. Cette fonctionnalité n'est pas prise en charge par le robinet et entraînera des erreurs dans de nombreux cas.
reload works most of the time for me, but its never a guarantee
I have literally no idea. My regex is always some frankenstein composition from things i googled. Hate regex.
lmao
Reload is fine if you're on a development server, never okay on production
how about you @pseudo hazel any ideas lmao
what do you want to match?
No es necesario que me lo digas en español, quise decir qué se supone que debo hacer en su lugar.
like what are the parts in those strings you actually care about
two examples are provided within that message.
set <variable_name> = <variable_value> and set <variable_name>=<variable_value>
The above gets both already, I just need it to look for set <variable_name>=<variable_value> too since those don't get detected
that didn't help its confusing
okay
Google is your friend, alot of great videos about scheduling
none of them helped
Then you didnt learn all the necessary language features to jump into spigot.
What exactly is confusing you?
set (.+) = (.+) works, just need it to detect set (.+)=(.+) as well lol
set (.+) ?= ?(.+)
set (.+) ?= ?(.+)
? = previous character is optional
I will explain my problem better
I am trying to make a crop regrow after 5 seconds of it being destroyed
👍
yeah
This project is gonna make me a god at regex istg lmao
run a asyncdelayedtask and set the age of the crop
what
Async?
hm
Not an easy task. You will need a lot of knowledge about scheduling, queues, serialisation etc.
ScheduleSyncDelayedTask lol
if the whitespace and stuff is inconsistent you could also consider using trim()
mb
Isn't there a simple way to just wait a bit?
wait nvm that only removed leading and ending whitespace
use the scheduler lol?
Sure but this way the crops dont regrow if the server shuts down while a crops is in a broken state.
then add a variable that you set when its growing back
that you will need to serialize/save i guess
The spawner animation run, I want to disable it, to help the player's fps
This is your "Just wait a bit" approach
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Material material = block.getType();
Bukkit.getScheduler().runTaskLater(plugin, () -> block.setType(material), 5 * 20);
}
But there are so many problems surrounding this... Really fragile.
is there a way to fix this?
Alternatively use the dedicated whitespace class
and that so it will be less fragile?
Yes of course. Just with a bit of intelligent code.
can you show me how?

But you need a whole infrastructure for this.
A manager, a data class, a scheduler, a PriorityQueue, a serializer and your data class has to implement Comparable for itself.
I can explain how to achieve this. But you will have to code it yourself.
I think its way too complex for what I'm trying to do
Letting a crop respawn is bit more complex but still not too bad. Every more trivial approach will inevitably lead to problems.
what is he even tryin to do
I'm just setting the age back to the max
Well then its not too bad.
So you need to do the following:
- Listen to the BlockBreakEvent
- Check if broken block is Ageable
- Schedule for one tick later: Set the broken block back to the original type
- Schedule for 5s (100 ticks) later: Set the age of the block to max [if the block still has the same type]
Already got the first 2 done how do I do the rest?
?scheduling
that confused me
?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.
I can do this all day
what confused you about it
What exactly confuses you? Try to quantify your problem so i can help.
The examples
Which one specifically?
When scheduling a task, you will also need to pass your main plugin class instance. Here is three examples of how it can be done:
So getting the instance of your main plugin class is what confuses you?
Objects and Instances, very basic Java
Then i cant help you. This is very basic java question. Something you usually learn in the first 1 or 2 weeks.
to get your plugin class instance, you can just do Bukkit.getPlugin(YourPlugin.class)
Getting the plugin instance is easy: JavaPlugin.getProvidingPlugin(new Object() {}.getClass())
what is provides: [] for in plugin.yml?
that is a thing now?
Worst case: Copy paste the code and replace some parts until it works.
what part about the delayed task do you not understand
the BukkitScheduler or the BukkitRunnable?
yes
scheduler.runTaskLater(plugin, () -> { in that part when I tried to follow that plugin appeared red after I did all of the previous steps like they showed
i saw some plugin use it
?stash
Never saw that. My guess it that it lets spigot know which maven dependencies are provided by this plugin
so that it doesnt have to download them for others.
isnt that libraries: ?
Its other plugins this plugins has bundled in
I.e. FAWE might provide regular WE so plugins depending on WE will not crash even though FAWE was installed
Ah ok so its not for maven dependencies but stuff like worldedit
Where your plugin basically mimics the api of another plugin
Also meant if you rename your plugin
A bit outside of the bukkit world, but fabric-api for example provides "fabric", while it's name is "fabric-api" - this grants a given degree of backwards compat as mentioned previously
After I tried following the tutorial I get an error can't resolve symbol 'plugin'
I wonder why...
You need a variable with the name 'plugin'
And it has to be of type JavaPlugin.
And it needs to be your instance of JavaPlugin.
The main class doesnt need an instance of itself...
xD
in other classes use
public Main plugin;
public ClassName(Main plugin) {
this.plugin = plugin;
}
private Main plugin; pls
Watch the spoon feeding, and don't name ur main class main
I just typed Main so he would understand that its the main class
I dont call it main

Why not name main class Main?
What is Main? What plugin is Main?
- TreeFellingPlugin
- Main
Which one is easier to understand the purpose of?
because Plugins are extensions of an App not an app themselves
I just call my Main class main as its the one with on enable, disable, configs etc then the rest i name to what they are
Not good design
Noted!
Usaully its good practice to name the main class your project name so example SkyblockPlugin.
^
how would i set the mining progress of a block
That's client side I believe
I believe there is a method to set teh stage
I think its fully client side now
There is a method in the api for that but im not sure it still works
oh-
Alright! The method is in Block right? I'll give it a try
gosh proper punctuation is hard
declaration: package: org.bukkit.entity, interface: Player
Im making a string matcher, and heres my question, how can i do something like this
given string: 123 something something 123
While 123 is never the same
is there a way to make argument X accept any string or int or whatever
real message is something like this:
Player X did X
i want it to match based on words player and did
🤔
hard to explain
whats x
X can be me or you
String message = "Player %s did %s";
message = message.formatted(player.getName(), something.getInfo());
You just want to format text?
its never the same
uwu
no no
Split and get [1] and [3]?
okay thats close
bump ig
dunno how that syntax looks lol
you know how for example this would look in code?
how do you even know where your player name is
Not at a PC rn. Just split the code by space and it becomes an array and you can just get it with [1] or w/e index you want and parse from there
is possible to add a custom "block" in spigot?
No. Only with a lot of trickery and even then its very janky. Minecraft doesnt allow any completely new additions originating from a server.
In order to add blocks you would also have to add those blocks to the client. And this is simply not possible in Minecraft vanilla.
Thats why forge exists.
well what if I create an entity and then use PlayerInteractEvent on it?
A bad trick would be to use some very rare block (if it's for a private server, just select a block that isn't used on your server), retexture it and force behavior
Then you added an entity and used the PlayerInteractEvent on it.
^
well at least I can call that a "block"
The client doesnt call that a block. So he will try to attack it and everything will look weird and out of place.
And you wont be able to walk on it
that is also true, and I think I would also need to prompt users to download a resource pack
is the logger thread safe?
I'm sure they could implement a system where a json of a block data is sent to the client and then the client registers that as a block
but that would need to be done by mojang for default client
Anyone who has a good GUI api?
?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.
Thanks!!
I'm making a economy plugin. Already have balance and basic commands such as /pay /balance and admin commands
I want to make a shop, but is there an easy way to connect price and items together
which event are you using?
Do I use a hashmap or is there any other way to again "connect" (dont know a better word for it) the item and prices
yes
how do i fetch a bow's drawback power?
you could just make a custom item wrapper that contains price on the items. Works for a global shop
Does the price change?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityShootBowEvent.html#getForce()
declaration: package: org.bukkit.event.entity, class: EntityShootBowEvent
Hello, how to clear anger of a Warden in EntityDamageByEntityEvent?
As mentioned here (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Warden.html#clearAnger(org.bukkit.entity.Entity)), I can use clearAnger, but I don't know exactly how to use it in the code.
public void onEntityDamage(EntityDamageByEntityEvent event) {
if (event.getDamager().getType() == EntityType.WARDEN) {
event.getDamager().clearAnger(); \\ this is not working
}
}
ah thanks.
No the price wont change
think u should use instanceof Warden
then cast to warden and use the #clearAnger() method
Then it depends on how and when you need a price
if you only need the price when its in a shop theres no point in keeping it permanent. Just look it up
Map would be fine
is this a good way to generate a message
how to spam goat rams
ignore what i said it works i forgot to restart server LOL
rather use pdc instead of checking display name
I know bro, I'm going to amend my code at some point and use pdc
I'm getting this error though, even tho it does work
Thank you. Could you please check my code, why the clearAnger and setAnger method cannot change the anger of Warden? Nothing is happen. Do I use the method incorrectly?
The .getAnger() and .getAngerLevel() are working.
public void onEntityDamage(EntityDamageByEntityEvent event) {
if (event.getDamager().getType() == EntityType.WARDEN) {
Entity warden = event.getDamager();
if (warden instanceof Warden) {
((Warden) warden).clearAnger(warden);
((Warden) warden).setAnger(warden,0);
System.out.println(((Warden) warden).getAnger());
System.out.println(((Warden) warden).getAngerLevel());
}
event.setCancelled(true);
}
}
Any help?:)
Love the null check after calling a method which makes it pointless
Well the IDE has highlighted a bunch of stuff. Might as well read it
Well if you've read it you can fix it
#1022549484389023885 bump
the guy helping me went offline or smth
nvm
that probably works
not a runnable
but scheduler
Untested, but try something like this
@EventHandler
public void onWardenDamage(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Warden warden) {
warden.clearAnger();
warden.setAnger(warden, 0);
event.setCancelled(true);
}
}```
or you could do this
((BukkitRunnable) () -> {
// code here
}).runTaskTimer(instance, 3L, 3L)
What would you use static for though? Like why is it bad practice
show stacktrace
same
will it commit suicide?
Hi, is there any method to find who caused a player to get damaged through a secondary event?
e.g. If they're hit with a sword that has fire aspect, Itll see fire as damaging the player after the original hit, not the person that hit them.
Is there anyway to find this info out?
DamageCause in damage event maybe
yep hosted on cdn
you cant upload it directly, it has to be hosted somewhere for people to download it
so discord hosts it
lol thats a png i was gonna paste the link to it
^
how is the thing foo ? "bar" : "baz" called?
inline if statement
Conditional operator
that is... an if statement..
yes
and if its false baz?
yes
how would i play sounds that are under a custom namespace? (resource pack sounds.json)
perfect thats what i want
ill try that
0,15s you mean
JStudio
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.
yo guys smol vote: should i get NBT-API just to check if player holds a chest with nbt
can you explain it like you are a human please
or
FREE JAVA LESSONS
or
?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.
I'm not human
Did you just assume I was human?
no i said can you axplain like human
then no answer
kk
does meta.hasLore() boolean also return true if there is a +NBT thingy in the description?
no
AUGHHHH
why do you need dis
i want a simple way to disable the uhh
middle click to get a chest with nbt data
aka a simple way to "ban" a player
https://sourceb.in/ErYnyHDev6
Question why this happens even if it is correct
https://i.imgur.com/Twk0OgR.png
How could you define spigot
still no luck. clearAnger and setAnger method give no effect, while get- method work properly. Do you have any idea why this happened? Is it possible because of the variable inside ( ) ?
ohh finally got it. The Entity variable inside () should be the target entity, not the warden.
Why would you want to do that
?paste
^ put the code there and send the link
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.
yes im asking that
i dont know how to get it to allow it
how to see all purchased plugins on spigot?
How can i add a values like
playersList:
- Player1
- Player2
in a yaml data file?
Stringlist :)
Can you send me an example?
Use your YamlConfiguration variable and there is a .getStringList(); and .set(path, value); supports list
PersistentDataContainer data = bankNoteMeta.getPersistentDataContainer();
data.set(new NamespacedKey(plugin ,"balance"), PersistentDataType.INTEGER, amount);
bankNote.setItemMeta(bankNoteMeta);
if (args.length == 1) {
amount = economyManager.parse(args[0]);
if (!(economyManager.getBalance(player) < amount)) {
player.getInventory().addItem(bankNote);
try {
economyManager.withdrawPlayer(player, amount);
ChatUtil.sendMessagePrefix(player, "&7You withdrew &a$" + amount + "&7 into a banknote!");
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
ChatUtil.sendMessagePrefix(player, "&cYou do not have sufficient balance to do withdraw this amount!");
}
}
return true;
This works but on the InteractEvent it doesnt remove or do
int amount;
@EventHandler
public void onBankNoteDeposit(PlayerInteractEvent event) throws IOException {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
amount = Objects.requireNonNull(item.getItemMeta()).getPersistentDataContainer().get(new NamespacedKey(plugin, "balance"), PersistentDataType.INTEGER);
if (!item.hasItemMeta()) return;
if (event.getAction() != Action.RIGHT_CLICK_AIR || event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (!Objects.requireNonNull(item.getItemMeta()).getPersistentDataContainer().has(new NamespacedKey(plugin, "balance"), PersistentDataType.INTEGER)) return;
player.getInventory().remove(item);
economyManager.depositPlayer(player, amount);
ChatUtil.sendMessagePrefix(player, "&7You have deposited a bank note of &a$" + amount);
}
nvm i see the problem i think
Okay so I fixed the event problem, but when I deposit lets say 100, it takes 100 from me but on the lore/banknote it says 0
as amount
if(isChatLocked == true) {
isChatLocked = false;
for(Player all : Bukkit.getOnlinePlayers()){
all.sendMessage(Utils.color(getConfig().getString("chat-unlock-success-all").replace("%player%", p.getDisplayName())));
}
} else {
for(Player all : Bukkit.getOnlinePlayers()){
all.sendMessage(Utils.color(getConfig().getString("chat-lock-success-all").replace("%player%", p.getDisplayName())));
}
isChatLocked = true;
}
the getString parts return npe, as if they dont exist in the config, although they do that, could any help me?
I was thinking, would it be possible for the plugin to start the server with a specific IP? That is, before passing the plugin, I would ask for the ip of his server, set it in the plugin, and if when he started the plugin, the server IP was not the IP set by me, the plugin would not start, it will be a good idea or can cause problems?
would be hacked out in seconds
That sounds like an awful way to do things.
public static boolean lockchat = true;
@Override
public void execute(Player player, String[] args) {
if (args.length == 0) {
ChatUtil.sendMessagePrefix(player, "&7You have &6&l" + lcStatus() + " &7the chat!");
for (Player players : Bukkit.getOnlinePlayers()) {
ChatUtil.sendMessagePrefix(players, "&e" + player.getName() + " &chas&6&l " + lcStatus() + " &cglobal chat!");
}
lockchat = !lockchat;
}
}
private final String lcStatus () {
return lockchat ? "LOCKED" : "UNLOCKED";
}
}
this is what I usally do
You haven't told us what the problem is
he literally did tho
whats the purpose of doing that even
thanks, ill try it out that
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (player.hasPermission("plugin.lockchat_bypass")) return;
if (LockchatCommand.lockchat) return;
event.setCancelled(true);
ChatUtil.sendMessagePrefix(player, "&cChat is currently locked!");
}
this is the chat event
Ig it works, thank you so much
i changed a lot of things obv thou
whatever you want brother, as long as it works
Please learn java. That entire class is an amalgamation of so many bad practices it's difficult to ignore.
will BlockBreakEvent call BlockDamageAbortEvent
A certified learn java moment
anyways um does anyone have a clue about this
Block break event happens when a block is broken, the abort event is completely different isn't it?