#help-development
1 messages · Page 1742 of 1
I'm gonna distastefully drop the command in a moment
if I know what ur talking about, I hate it aswell
what?
what Spigot API version are you using
it isnt able to use for entity and idk why
otherwise cast it to Player as its a player anyways, like this
((Player)damager).getUniqueId();
// or (i recommend this if ur going to use it later)
Player damagerPlayer = (Player) damager;
damagerPlayer.getUniqueId();
because Entity is not Player
you need to cast it
for the compiler to know
i cant use Player in entity events also...
You can
you are literally checking if the entity is a player
you just did an instanceof check
hey if I want to log a command and it's arguments (most specifically /msg and it's content) would I use PlayerCommandPreprocessEvent?
this
yes
great thanks :D
@iron palm you should be able to get the UUID for any entity
just use damager.getUniqueId()
i saw it mentioned that it should be avoided as much as possible, is there any examples of best practice while using it?
yay it worked
can someone please help with my question here ^
how is vault API outdated
you can also just do damager.getUniqueId()
or are you using an old version
or something
idk
Many plugins will have no use for this event, and you should attempt to avoid using it if it is not necessary.
Some examples of valid uses for this event are:
Logging executed commands to a separate file
Variable substitution. For example, replacing ${nearbyPlayer} with the name of the nearest other player, or simulating the @a and @p decorators used by Command Blocks in plugins that do not handle it.
Conditionally blocking commands belonging to other plugins. For example, blocking the use of the /home command in a combat arena.
Per-sender command aliases. For example, after a player runs the command /calias cr gamemode creative, the next time they run /cr, it gets replaced into /gamemode creative. (Global command aliases should be done by registering the alias.)
Examples of incorrect uses are:
Using this event to run command logic
nah its 1.17.1
when I try to add the latest version to Maven, it bugs everything out. I don't want to use the vault API anyways
then damager.getUniqueId() should work
what exactly bugs out
I don't want to use the vault API anyways
btw i got the UUID now i need to restore it in Player Death event how ?
restore?
ok, then give me the dependency and repository
1 sec
I mean getting it in Player death event again
lemme open my project
we need to create threads rq
I'm doing 1.17.1
Gameisntover help
thats, the, uhh, spigot API
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>```
k
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>```
?paste
make sure you have the standard vault jar too
thanks 4 everything
hey so, i see there are various logging levels that you can choose to log to (info, fine, etc), so if I wanted to access fine+ levels, how would i do that?
What do you mean access
Anyone else had this issue before? https://paste.bristermitten.me/okymuxawir.properties
I did not, I added a metrics class in directly.
Well it seems it cannot be found at runtime
Check the exported jar to ensure it's there
me/untouchedodin0/privatemines/util/Metrics$CustomChart
You have the custom chart class too?
As a nested class
I don't know, I'll check
i do
I think I've fixed it by using the metrics class directly and not shading it in
as in, it’s not being logged by default in the console. how do i change x value so that it does show up in the console?
ah. thank you o7
does anyone know how to get the namespacedkey for existing structures with the new api? I'm trying to use it to create a bastion in the overworld but am a bit confused on its functionality
I had tried using StructureType.getName() but that seems to return null when using loadstructure
What would the best way be to make an entity "stick" to a player so that they have the same position at all times? I tried using a scheduler for this and while it did make the entity follow the player, it only updated the position every second or so which looks really ugly
Either with a sheduler or by mounting
Oh yeah I'll try mounting it on the player
Packets could work if you want to go that route
I think I'm going to try that last
anyone here has used redis in their cache layer?
yep
Can you please help me, I am trying to figure out how to go about it
So I am working with mariadb and redis, and from what I can tell
redis is where I should be making my read/writes/sets/gets but at what rate should I apply those changes to mariadb?
or like, the frequency at which i apply those changes in mariadb
since they are so often
So the way i usually go about doing it is read/writing directly to mongo and then saving that data in 5-10min intervals (depending on how important the data is) to the actual db
and in those intervals i usually push all data to db, flush all data from redis, and then pull data when needed again
just ensures you don't have too much useless data floating around in redis
how performant is the BukkitScheduler#runTaskTimer/BukkitScheduler#scheduleSyncRepeatingTask? I need to do something for every player every 5 minutes basically, is it better to create 1 repeating task every minute and check all players, or is it performant enough that I can create a separate interval per player?
i would go the first route, better using 1 repeating task than potentially 100
lol, fun story. Former developer on our server decided it was a good idea to spawn 200+ tasks just to summon particles. An async task for every single particle spawn
This is invoked every time the particle goes off by the way, which is on a custom enchantment
yep
i love how every p2w ultra-smart gigahacker kid complains about multithreading
boo-hoo my anarchy server with atleast 600 active lag machines isnt working well
Just in case you think I'm kidding. I'm not
https://paste.md-5.net/izaxaxusoq.js
Also, yes, it's in JavaScript. Trust me, I hate it too

def display_arrow_trail(loc: Location) -> None:
for i in range(100):
play_effect(calc_random_offest_3d(loc, 0.15), Particle.CRIT_MAGIC, 0, 1)
# etc...
class Timer(BukkitRunnable):
def __init__(self, event: ProjectileLaunchEvent) -> None:
self.event = event
def timer(self) -> None:
if self.event.is_cancelled or self.event.entity.is_on_ground():
self.cancel()
return
# etc...
display_arrow_trail(trail_location)
self.ticks_ran += 1
if self.ticks_ran > 10 * 20:
self.cancel()
timer = Timer(event)
trail_task = bukkit.runSyncTimer(timer, 0, 1)
Repeating task? Never heard of it
Mounting works great!
I despise the fact that Python forces you to write in self into your method arguments
Do like any sane languages does and imply that 
a bad attempt at backwards compatibility
python 2.7 extending object
it should just be a keyword
iirc,
public void myMethod(TypeOfThis this, String hello) {
}```
is valid Java
but we just imply that this argument because again, most languages are sane 
my friend was trying this with his particle system, had to step in and go "n o, s t o p!"
Author of that code coincidentally sells a server fork targeting performance improvements btw
he came to me like "why isn't this working", the whole system was jank, and I spent like an hour fixing it up 
so relatively general question here. but my plugin, once connected to a minecraft instance, also needs to connect to a non-minecraft server i'm hosting in a shell on my own computer. what libs or functions would connect?
sockets? would i have to implement spring within my plugin?
Yes! It does!
- Both of those are methods (neither is a constructor)
- The first method is an implicit
thisreferring to itself, the second is an overload accepting an instance ofThis, the type - Both methods return
this, itself because the second method refers to an instance of itself calling the no-method overload which returns itself
honestly hoping I figured that out without pasting it into my editor
Good puzzle though. I like that class
IDE confirms that I'm correct as well. 
sorry what
@ who?
This This(This this) {
how is that valid?
aren't keywords keywords no matter the scope
It's a method with no access modifier called This that returns This, with the implicit type this
It's equivalent to public This This()
this is a keyword, This is not 🙂
there's a lowercase this there
That's the implicit parameter. Every method has that implicitly
pls cite jls
It's akin to Python's self
netbeans doesnt even autoformat it correctly
My IDE gets a little confused about object highlighting when it's around as well lol
Probably for annotation stuffs
Ah that's precisely why they did it. Annotations. Not sure why you'd ever want to annotate the implicit parameter but you can!
there's probably 3 people in the world that use type annotations
annotations = reflection daddies
I've recently used annotations to automatically register stuff
Much nicer than having to remember to do it for each new class I make
Spring uses too many annotations.
Is it more than heretere
is there a way to avoid this? https://i.imgur.com/CaeVnNi.png
Your server might me running.
yea ik that, i usually just change my artifact build path but I am shading so I cant do that
is there a way around the blocker?
how can i make a sky world with only air
create a new world with a cursed worldcreator :op:
You can still change the output directory
Or copy the output jar with maven/gradle
Hi, I am trying to make a command but it just keeps on giving me this error:
GUI.CommandGames isn't a valid name for a class
oh
Just CommandGames would suffice
You've probably changed the name in your .java file but not of the .java file itself
Or you're going some really... strange... access?
No
public class CommandGames implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
openNewGui(player.getPlayer());
}
return true;
}
}
Also, hi Borlea, I feel like long time no see your name around
This is the code that is the executing the command
public class CommandGames implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
openNewGui(player.getPlayer());
}
return true;
}
}
This is the code that is trying to access it
package me.Elyas207;
import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.java.JavaPlugin;
public final class GUIMaker extends JavaPlugin{
public void onEnable() {
getServer().getPluginManager().registerEvents(new GUI(), this);
this.getCommand("Games").setExecutor(new CommandGames());
}
Asking because of the indentation. Is your code structured like this in a single file?
public final class GUIMaker extends JavaPlugin {
public void onEnable() {
getServer().getPluginManager().registerEvents(new GUI(), this);
this.getCommand("Games").setExecutor(new CommandGames());
}
// etc.
public class CommandGames implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
openNewGui(player.getPlayer());
}
return true;
}
}
}```
Or are they in separate files/packages? If they're in separate packages, there's no import
If in the same package, disregard
They are in the same package
Well those two files look fine. Though your most recent error indicated that there was something wrong in the GUI class
?paste it if it's too long:
Ah
Two options:
- Move your CommandGames class into its own file outside of GUI (preferred)
- Make CommandGames a static class, though that may come with other implications
At the moment however you have no way of creating more than one instance of your gui so if more than one person wants to open the GUI at once you're going to have some issues
oh ok
#help-server Help please
👋 I sit in my corner and help here a bit
if(args.length < 3 || args.length > 5){
sender.sendMessage(ChatColor.GOLD + "/spawnboss [worldname] [Location]");
}
Bukkit.getServer().getWorld(args[0]);```
lmao will this work?
well you probably want a return after the sendMessage
and you probably want to do something with the result of getWorld
Hello on gradle I run my server using a task (after plugin compilation) with
mainClass = "org.bukkit.craftbukkit.Main"
workingDir = "server/"
standardInput = System.in
}```
But i have to add in dependencies
> compileOnly 'org.bukkit:craftbukkit:1.17-R0.1-SNAPSHOT'
Can I use spigot-api main class instead ?
org.spigotmc:spigot is probably what you want?
and idk enough gradle to tell you if its possible to put a dependency only for an exec task
||oh it's the real md5 😮 ||
Thanks I'll try, I'm new at java development
i just want when player type the command /spawnboss [worldname] [location]. I can get the worldname/cords and use it
is there a listener built in Essentials that checks if the /eco command was successful?
need that for a plugin that trades lives & depends on Essx's Eco
yes
there is a method
do plugins get bumped when updates are pushed or anything like that on spigot resources?
which one? also how do i implement it?
EconomyResponse response = economy.depositPlayer(player, 5000000);
this is a example
this video has all those explained:
ok ty! i was looking for a documentation for Essx!
ah someone help me dude
i am trying to get world name from players entered command
like /spawnboss [worldname] [location]
this will work?
getMessage?
String world = args[0];
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/AsyncPlayerChatEvent.html @last ledge this will get chat messages u can maybe even setup a command
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
Yes, make sure you use both a null and size check on the args list tho
Should work theoretically
just realised something is wrong in my code
now i stored world name as String world = args[0];
now i want to spawn one mob in that world how do i use that world name?
yes
World world = Bukkit.getWorld(world);```
error: Variable 'world' is already defined in the scope
error: Variable 'world' might not have been initialized
you need to change one of the variable names
k then
World world = Bukkit.getWorld(worldname);```
now how do i get location from commmand like x, y, z postion
what
you are trying to set spawn or something like that right?
no i want so spawn a mob
first i am getting world name
then the x, y , z location
to spawn the mob
i have an example code for u and it is way easier for set spawn
but you can just modify the code a little bit for it to work
as what u want
ok send me
please guy dont call me a spoonfeed that is very simple code
bruh
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player p) {
if (p.hasPermission("risingcore.spawnsystem")) {
if (args.length == 1) {
String locationName = args[0];
if (!locations.getConfig().contains("Locations-Data." + locationName)) {
locations.getConfig().set("Locations-Data." + locationName, p.getLocation());
locations.save();
language.setSpawn(p);
return true;
}
language.alrName(p);
return true;
}
language.noArgs(p);
return true;
}
language.noPerm(p);
return true;
}
language.playerOnly(sender);
return true;
}```
wait
wait
maybe it is kinda uhhh
bruh
bruh
bruh...
oh ok...
it should be like this if u want to spawn a mob in p location
wait a bit
k
i have custom made mob
i will spawn that
i will be using its metadata to spawn
so its easy
ye
do u needs any args for the plugin or only the cmd and it will spawn it anyway?
gave it the repo & still getting th error
location?
only 1 args is needed lol
and spawn on specific location not player standing location?
hmmm
whatever the user inputs in args[2] will be x location
args[3] y location
args[4] z location
ig
ok
Does the pom output say anything abt it?
also what repo are you using
uhhh @last ledge i will only check if the lengths of the args is 4 (4 args), if u want more specific check for the lengths the feel free
kk
Hey, I have a question related to writing code that is supported through multiple Java Versions.
Basically, I used Java 8 for compiling all versions prior to 1.17, at that point they switched over to Java 16. I already have my maven project setup to support all versions using different modules for each version, however I am running into one problem. Essentially, I made an Abstract Class that every single version class extends, at that point I have one singular class that will detect the version your server is running on and makes sure to select the correct version.
Example:
private AbstractNBTItem abstractNBTItem;
public NBTItem(ItemStack itemStack) {
super(null, null);
String version = Version.getVersion();
switch (version) {
case "v1_7_R4":
abstractNBTItem = new AbstractNBTItem_1_7_R4(itemStack);
break;
case "1_8_R3":
abstractNBTItem = new AbstractNBTItem_1_8_R3(itemStack);
break;
case "v1_9_R2":
abstractNBTItem = new AbstractNBTItem_1_9_R2(itemStack);
break;
case "v1_10_R1":
abstractNBTItem = new AbstractNBTItem_1_10_R1(itemStack);
break;
case "v1_17_R1":
abstractNBTItem = new AbstractNBTItem_1_17_R1(itemStack);
break;
default:
throw new UnsupportedOperationException("This version is not supported");
The issue comes in with the AbstractNBTItem_1_17_R1.class being compiled in Java 16, with the other classes being compiled in Java 8. This leads to the entire class being compiled in Java 16 and therefor unusable in a Java 8 environment. For a temporary fix I went ahead and used reflection for 1.17, I was just wondering if anyone knew a better way.
im using vault 1.7
hover over it, what does it say
w8
Did you restart IntelliJ
No worries
Well, things are weird
i dont think so, i think he didnt reload the pom.xml file ya know
Basically, restarting intellij will fix your mistakes for you... but not really but also kinda
Nah, wrong lol
Works for me, even if it doesn't do anything it gives me a few seconds to stop being smooth-brain
You can just reload the pom.xml file manually. When editing the pom.xml it would show an icon
reload pom.xml
so it can take changes and download every vault file needed
Hi im using intelij for developing plugins
my plugin version is for 1.17
but i also wanna compile it for 1.16.5
how can i do that?
(i have java 16 and 1.8 both)
use Java 16 all versions > 1.17 use java things should remain same for the most part!
@iron palm
oh so if i change the project java version ... then will it work for other versions?
yes hopefully
sounds good thanks
np!
so i gone to afk then i reloaded the server but
server wasnt detecting my plugin still...
does it say anything in your console
like plugin.yml load failure
It'll be towards the top
that could be why
You could, idk how though
event class: https://paste.gg/p/anonymous/ef322d7ee31e4fcba7891270bd87ab5a
main class: https://paste.gg/p/anonymous/eb248b282bb84eba9e4779899c911637
Problem: Event class not working
version: 1.3
main: de.sabbelsocke.projekt1.main.Main
commands:
heal:
description: Dieser Command heilt dich.
dead:
description: Probiers mal aus.
kit:
description: Kit Inventar.
setspawn:
description: Setze den Spawnpunkt.
spawn:
description: TP dich zum Spawn.
partystart:
description: Starte eine Party auf der Bühne.```
Hi can someone say me whats wrong with this plugin.yml?
you need an api-version
What version of MC is it
1.16.5
then @restive tangle is correct
event class: https://paste.gg/p/anonymous/ef322d7ee31e4fcba7891270bd87ab5a
main class: https://paste.gg/p/anonymous/eb248b282bb84eba9e4779899c911637
Problem: Event class not working
Am I doing this correctly? I'm giving a player a glowing effect for one second, but it doesn't show up on the player.
((Player) entity).addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING, 1, 1, false, true, true)
);
``` if i type ```bash
/effect give <player> minecraft:glowing 1 1 true
``` it works just fine
javadocs regarding this: https://papermc.io/javadocs/paper/1.17/org/bukkit/potion/PotionEffect.html
declaration: package: org.bukkit.potion, class: PotionEffect
your package is incorrect, but i dont think thats the issue
roteSpMeta.displayName(Component.text(ChatColor.translateAlternateColorCodes('&', "&cRotes &7Splitter"))); wtf did you do here
something not good
just use the proper formatting for components
@quaint mantle hmmmmm
yes
set a breakpoint on the events that you think arent being triggered and run the server in debug mode
hey there im getting a few errors for this code:
Killstreak.get(damager.getName()) ,Killstreak.put(damager.getName() + 1);
'put(java.lang.String, java.lang.Integer)' in 'java.util.Map' cannot be applied to '(java.lang.String)'
damaer is my entity and Killstreak is the hashmap
Map<String,Integer> Killstreak = new HashMap<>();
LegacyComponentSerializer.legacySection().serialize(str) should work assuming you don’t want to use the verbose appending of components
Actually thats not even the worst part
anyway, regarding this, what do y'all think the issue is
Idk I don’t use paper
bro if you weren't here, this problem wouldn't have been solved, tysm dude...
alright
sorry... i didnt test...
do not trust me then
ducks
🦆
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player p) {
if (p.hasPermission("Ur perm here!1!!!!1!!1!!1!!!!")) {
if (args.length == 4) {
Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON));
}
language.noArgs(p);
return true;
}
language.noPerm(p);
return true;
}
language.playerOnly(sender);
return true;
}```
@quaint mantle error in language
cannot resolve symbol
ur entity 👀
remove one ) after the skeleton entity type
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player p) {
if (p.hasPermission("Ur perm here!1!!!!1!!1!!1!!!!")) {
if (args.length == 4) {
Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).Metadata("SkeletonKing");
}
language.noArgs(p);
return true;
}
language.noPerm(p);
return true;
}
language.playerOnly(sender);
return true;
}
}```
wait
did you change the language LOL?
the language is my class
so just replace it with ur message
how long have you been doing java
im newbie in java
thats maybe because why i cant understand hashmaps
you're currently doing this: Killstreak.put(String) when it wants Killstreak.put(String, Integer)
you're adding 1 to a string here Killstreak.put(damager.getName() + 1)
hm
you need
Killstreak.put(damager.getName(), Killstreak.getOrDefault(damager.getName(), 0) + 1);
getOrDefault just sets the returned value to 0 if its null
oh ok thanks
?paste
I must be mentally challenged... java.lang.IllegalArgumentException: The embedded resource 'config.yml' cannot be found in plugins\pluginname.jar
I figured it out
I am mentally challenged indeed. Thank you 🙃
someone break something so I can help
im like really bored
either this or go to a maths study session for stuff I already know cause I got nothing to do
i want to spawn Skeleton with meta data "SkeletonKing"
This is my current code, but doesnt spawn skeleton with the meta data, how do i do it
Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).getMetadata("SkeletonKing");
Ok there is a lot wrong with that
many opportunities for NPE
and NumberFormatExeptions
then you are also getting the metadata and not setting it
Okay I need some help wrapping my head around this
what do i do
is AsyncPlayerChatEvent deprecated in newer versions?
Everyone understands try {} catch{}. But was does finally exactly do? It's mentioned that it always executes. But isn't this true for code AFTER a try catch too?
I think this is a cleaner way of doing it
just a suggestion though
oh maybe
No?
If you put a return, break, continue or any other java keyword that changes the sequential execution of code inside the catch block (or even try block), the statements inside the finally block will still be executed. StackOverFlow to the rescue
since when has Map::merge existed??
How do you test your plugin in development ? Do you have something mechanical for test faster your plugin ?
MockBukkit
Says since java 8
well what's it do?
Yeah that higher order function has been there for quite a while
It takes the second param and and the already existing value, applying it with the binary operator to yield a new value which gets stored into the map
iirc
My full code: https://paste.gg/p/anonymous/7d6bc09c2b864869b9666e9b224f693b
error: Could not pass event EntityDamageByEntityEvent to BossMobs v1.0
thanks i'll take a look
Show the full error
It tells you the errors
Caused by: java.lang.IllegalArgumentException: No enum constant org.bukkit.Sound.ANVIL_LAND
can't have health above 300
Anyone need help in here?
I have a mob Skeleton with meta data "Skeleton King", and made a command to spawn it but its not working
Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).getMetadata("SkeletonKing");
The skeleton spawns but
but the normal one
i want to spawn the skeleton with its metadata
^
error: 'setMetadata(java.lang.@org.jetbrains.annotations.NotNull String, org.bukkit.metadata.@org.jetbrains.annotations.NotNull MetadataValue)' in 'org.bukkit.metadata.Metadatable' cannot be applied to '(java.lang.String)'
code: Bukkit.getWorld(args[0]).spawnEntity(new Location(Bukkit.getWorld(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])), EntityType.SKELETON).setMetadata("SkeletonKing");
It does tell you, you have the parameters wrong
It takes a string and a metadata instance
hi how can i check the permission of a player? with if(player.hasPermission("Projekt1.Kit")) { and he has the permissions it doesnt work
If its not working they don't have the permission
Is it possible to resolve an Entity type to a Player type?
https://i.imgur.com/hACgwHH.png mhh strange
use lowercase in permissions. Some plugins will ignore case
Check and cast
uhhh why integer in hashmap isnt working??
https://paste.md-5.net/ezuzerolom.cs (the code)
what do you mean "integer in hashmap isnt working??"
Killstreak.put(damagername,+1);// the integer stays in the 1!!!!
because you always set it to "+1"
you have to set it to do this:
Killstreak.put(damagername,Killstreak.get(damagername)+1)
also pls stick to proper variable names. Killstreak should be lowerCamelCase
e.g. killStreak
oh thanks
guess you are right...
yeah using "Killstreak" suggests that it's a class, but of course it should work anyway^^
...
The no profile picture is tripping me up
me too lol
but he's right. Adhering to naming standards makes code readability far better
According to your bio you write in C#! You should know about naming standards being important! :((
I lost my first unity game 😦 it was on a backup that I cannot find anymore
but it's no loss, it was shit anyway
You're right
Isnt working
what isnt working
Caused by: java.lang.NullPointerException
at PlayervoidDeath(deathlistener.java:52) ~[?:?]
killStreak.put(damagername,killStreak.get(damagername)+1);
actually
whats damagername?
you have sent us something different
to what you code is
killStreak.put(damagername,killStreak.get(damagername) + 1);
we have literally told you this 10 times
or use the merge thing I sent you killStreak.merge(damagername, 1, Interger::sum);
you have to check whether the map contains that key already
e.g.
killStreak.put(damagername, killStreak.contains(damagername) ? killStreak.get(damagername) + 1 : 1)
I haven't read the prior conversation
ah ok
werent working btw
?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.
im already learning java with some youtube tutorials
btw what's your code supposed to do anyway?
you are creating a new hashmap in every event so it will always be empty
i wanna create a killStreak system
okay but
then you must only use ONE hashmap and not create a new one every time
the hashmap should not be a local variable but instead a field of your listener class
you do know what a field is, right?
yee
okay, so make the hashmap a field and it should work
ok i'll try thanks
did you get it working?
im using a EventHanlder on PlayerAdvancementDoneEvent but it runs even when you unlock a recipe
how can I fix it?
I'd probably just do it like this, I think it's cleaner to use own methods for adding kills:
public class Test extends JavaPlugin implements Listener , CommandExecutor {
private final HashMap<UUID, Integer> killStreaks = new HashMap<>();
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
if(killer == null) return; // No PvP death
addKill(killer);
if(getKills(killer) == 5) {
killer.sendMessage("Yo yo yo bro you did the kill thing 5 times dude");
}
}
private int getKills(Player killer) {
return killStreaks.getOrDefault(killer.getUniqueId(), 0);
}
private void addKill(Player killer) {
killStreaks.put(killer.getUniqueId(), getKills(killer) + 1);
}
}
are you sure? try to print out the Advancement's key and tell us which one it is pls
Yeah recipes use advancements
You can probably check if the key contains recipe or something
hm then I'd simply check if Bukkit.recipeIterator contains the key and if yes, it's a recipe
Different key
Wonder what discordsrv does
org.bukkit.craftbukkit.v1_17_R1.advancement.CraftAdvancement@3763200b
with System.out.println(event.getAdvancement());
That’s not the key
Namespaced key
cast the advancement to Keyed
then use getKey
Keyed keyed = (Keyed) event.getAdvancement();
System.out.println(keyed.getKey());
You don't have to cast it
if (keyed.getKey().toString().contains("minecraft:recipes/")) {return;}
something like this can work?
Hello i need help. I try add to pom.xml:
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
this is not work
Use triple back tick
true, my brain is tired
Change spigot-api to spigot
probably
but as already mentioned, the cast is unnecessary
You can do just event.getAdvancement().getKey()
I rememebered the cast is necessary because it indeed is when using Recipes
somehow recipes have to be cast to Keyed before you can access getKey
no idea why though
Because Recipe doesn't extend Keyed, but ShapedRecipe and ShapelessRecipe do
There are some Recipe implementations which aren't keyed
For instance, MerchantRecipe
Advancements however are already direct children of Keyed
yeah I just checked
all Recipes implement Keyed except the MerchantRecipe
makes sense now
actually I should have known that because I just recently added a recipe parsing class to my lib lol
Cheers, thank you!
Any idea why the check for the advancements before the player join?
Like a player can get the advancement before they join if the server don’t save player advancement and players already did it
why would a server not store the advancements?
https://cdn.tooty.xyz/LyZV xml <dependency> <groupId>com.mitch528.sockets</groupId> <artifactId>Sockets</artifactId> <version>1.0</version> </dependency>
https://haste.powercord.dev/narudawiki mvn install -Dfile=C:\My\Long\Path\to.jar -DgroupId="com.mitch528.sockets" -DartifactId=Sockets -Dversion="1.0" -Dpackaging=jar
Just disable saving it lol
I dont see anything wrong
shade it
do what now
why would a server disable saving it?
you must shade the dependencies. add the maven-shade-plugin to your plugins
ohhh ty
And set the scope to compile (even if it is the default)
any way to get the last entity to exit a boat
FoR sMaLleR sToRaGe
And remember to set spigot's scope to provided
is there any uh resources on this
listen to EntityDismountEvent and store it somewhere
spigot is on provided yes
otherwise you'd get a 50 Mb jar
k
I have an example pom-generator, just use it and copy paste the shade section: https://pom-generator.jeff-media.com
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<relocations>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
basically just add this inside <build><plugins>
tysm
np, did you get it to work?
but remember to add <scope>provided</scope> to ALL dependencies you do NOT want to shade
e.g. vault, worldedit, worldguard, etc bla bla
yeah i only have this and spigot rn
its compiling now
wait now ive got a -shaded one do i use that
use the one with the bigger file size
how exactly the file is called depends on your other pom config stuff
theyre the same
I'd use the third one
but they basically all should be the same lol (except the 4kb one of course)
nice
buut
you might also think about relocating that class
otherwise you might get problems when two plugins want to access the same library you are using
in the <relocations> section, add this:
<relocation>
<pattern>de.jeff_media.jefflib</pattern>
<shadedPattern>de.jeff_media.testlibs.de.jeff_media.jefflib</shadedPattern>
</relocation>
replace the pattern with the package name of the lib and shaded pattern with something containg YOUR plugins package
it's not really necessary but you should do it anyway to avoid future trouble
e.g. <pattern>com.mitch528.sockets</pattern>
and <shadedPattern>Your.Package.Name.libs.sockets</shadedPattern>
it basically just moves the dependency to your package so your plugin will not try to access the original class that was maybe shaded into other plugins that didnt relocate it either
I hope I explained it in an understandable way lol
Wtf
yeah someone explained the reason for it already
Yea I get it now
Hey, i'm using this gradle file but it throws the error attached in the paste link, anyone know where I'm going wrong? https://gist.github.com/UntouchedOdin0/d28bdf9ae7f06b4342730070587711bf
https://paste.developerden.net/ugasetatuv.css
edit: fixed
how does spigot decide which command should execute if several plugins have the same command registered?
Is it possible to have a webhook from your plugin page to a discord channel? Same idea as github webhook, but for spigot. I would like to automatically post my resource updates in a discord channel.
I have this piece of code that spawns a block in certain conditions but its taking ALOT of ram, and by this dropping the fps by a whole lot. Any ideas how to make this less laggy?
@EventHandler
public void onGenerate(ChunkPopulateEvent e) {
Double allowPatch = 0 + (Math.random() * (15-0));
int aP = (int) Math.round(allowPatch);
if (allowPatch == 5) {
final World world = e.getWorld();
final Chunk chunk = e.getChunk();
final Block block = chunk.getBlock(8, 0, 8);
block.getBiome();
if (block.getBiome() == (Biome.SWAMP)) {
Double randomLocationDoubleX = 0 + (Math.random() * (15 - 0));
int rLoc = (int) Math.round(randomLocationDoubleX);
Double randomLocationDoubleZ = 0 + (Math.random() * (15 - 0));
int rLoc2 = (int) Math.round(randomLocationDoubleZ);
Integer y = world.getHighestBlockYAt(rLoc, rLoc2);
Block check = world.getHighestBlockAt(rLoc, rLoc2);
Block structureLocation = chunk.getBlock(rLoc, y, rLoc2);
structureLocation.setType(Material.DIAMOND_BLOCK);
Bukkit.broadcastMessage(String.valueOf(structureLocation));
}
}
}
}
professional code, u won't understand :kekw:
ik its bad code but im trying some things
Great code
your random generation at the start is pointless. You round it . Just random an int
lol
y not use random class?
ik its bad what i already said but i just wanna know why it lags so much
Lastly your lag is probably caused by your Broadcast
bruh
i added the broadcast after it crashed my test server and broadcast doesnt do that much lag
Its teh pixies then
why hate, cant you just help?
what do u mean by pixies?
its him making a joke
oh
bump
ok your issue is you are using world.getHighestBlock and Y using world coords of 0-15, those are not chunk relative
also stop using Double and then rounding. Its pointless and adds overhead you don't need
Your whole code is placing structures in chunk 0,0 not in the populated chunk
well its actually checking chunk 0,0 then placing at those coords in yoru populated chunk
aah i see it now, ty, one last question tho when i use this code (a little things changed with the if statements) it did spawn dia blocks in chunks that loaded, how come that worked
nvm lmao
ty
yoru checks are on 0,0, then you spawn it in your populated chunk at the coords from 0,0
random.nextInt(15) I believe
ill try
Has anyone got protocollib to work with Paper? Trying to load the ProtocolManager class gives me this error:
java.lang.NoClassDefFoundError: com/comphenix/protocol/ProtocolLibrary
protocol lib is not on your server
Also consider using SplittableRandom
instead of just Random
Thanks, I didn't realize I needed to add it as a plugin too.
should i make instances of my configs, now i have a static method which loads all my files and getters to get thm
I got this now and i'm worried how to change it
if that were mine, I'd not hard code the names and everything in the loading code
I'd probably create an enum of teh configs
how do i disable vanilla commands / functions?
i.e, /w, /me, the stats menu
or override, that could work
but how-?
oh wait its in the spigot config lmfao
now how do i replicate time played :thonk:
p.getLocation().getWorld().spawnEntity(EntityType.CREEPER).setMetadata("BossCreeper", new FixedMetadataValue(plugin, "BossCreeper"));
Error: Cannot resolve method 'spawnEntity(org.bukkit.entity.EntityType)'
how does spigot decide which command should execute if several plugins have the same command registered?
Needs a location
Namespaces, minecraft:tp and essentials:tp, for example.
You still have to provide it to the spawn method.
yes, but if i have pluginA and pluginB, which both register /mycommand, and it's used without providing a namespace, how does spigot decide which one to execute?
Nope
why thank you
These is no way as it is depends on plugin name, and i think 2 plugin can’t start if they have the same name
The namespace key i mean
Not sure, you might just have to play around with things and see if the order they're registered matters.
They depends on the pl name
I don't think you understand what they're asking. Like in my example, how does Spigot know to run Essential's tp instead of Minecraft's?
If you just type /tp
I believe it’s whatever loads last
It's probably the order in which their registered? I'd assume the last one register is the one Spigot defaults to, but you'd have to check that.
i think plugins always override vanilla commands, but with plugins it might be in the order of registering, so alphabetical
Well they override because vanilla is loaded first
true
this better?
no
because its unnecessary static
ideally, you should have a Configuration class, and make all your configurations extend that specific class and override methods if necessary for serialization/deserialization
all methods of that class are static
You shouldn't have made them static the first place 🙂
...?
i know i should do configfile = ... but i want it in one method
So put it in one method
i do file = new File() but that is for the parameter
and i want to do it for all the files so i cant choose one
I do not understand
it isnt modifying the field
Is the method supposed to define the File?
create the file and load it into the fileconfiguration
Do it in a constructor if the user is required to pass the File in, and just have an argument for each one that's required.
bleh that class was supposed to be used static
so i should have multiple config instances in my main file?
Hm? No
I am using economy .getBalance() to get balance of a player but i want to subtract but the problem is i have to use economy.format(economy.getBalance); but this can only be in a string any good way to fix?
does Integer.parseInt() works on an untrimmed string?
fourteen why not just try and see?
bro
im not using getkiller
i have the damager which is the last living entity who damaged the damaged player
So addKill would not work
waah I don't like wasting time (I've been doing my whole life but yea 🎃 )
ah online compiler yes
ye
java.net.ConnectException: Network is unreachable um
is this a generic bukkit thing or just per hosting that you cant use http
does anyone knows if CodePen supports Java?
prob not
not going to authorize github for nothing 💀
bae it doesn't
any one can help with this problem
with gradle
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Package[] java.lang.ClassLoader.getPackages() accessible: module java.base does not "opens java.lang" to unnamed module @77cd7a0
is it wrong java
version or something
using reflection?
how can i get the slime other slimes splitted from in creaturespawnevent
Although that event only has the slime they split from and the number it will split in to
It’s just protected
Is it possible to program a tablist which is not affected when the scoreboard is updating?
Cant really do much axe
anyone know the regex to get anything before the character |
You could just use String.subString(0,String.indexOf("|"))
Well you probably want to check that indexOf doesn't return -1, but yeah
I find regex more efficient
i want the action bar to be a little lower so i thought maybe i can use \n, but it just renders that thing
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\nyour message here"));
https://cdn.discordapp.com/attachments/681582023923728494/901176033208856646/unknown.png
deam that pain
ez question: how can I call Main besides this way?
private Main main;
public SetSizeCommand(Main main) {
this.main = main;
}
(yes I know I should not call my Main Class "Main")
That’s generally the preferred way
atm for call Main class im using this:
Main.jar
public final class Main extends JavaPlugin {
private static Logger log = Logger.getLogger("Minecraft");
public static Main plugin;
private static WorldBorderApi worldBorderApi = null;
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
You could also create a static getter in your main class
But dependency injection is preferred
Why does message.split("\\|")[0] remove all of the string?
shouldn't this remove everything after |
Anyone know how to make something happen randomly?
how could i do this?
Polling -> random roll
For ex pick a item out of every item in the game?
Huh
You could use Random
You can use that for players?
Do you want something to be executed at a random point in time or do you want to select a random element from a Collection of elements?
Select a random a element from a collection
Very generic example:
public <T> T selectRandomElement(final List<T> list) {
final ThreadLocalRandom random = ThreadLocalRandom.current();
return list.isEmpty() ? null : list.get(random.nextInt(list.size()));
}
This should indeed split the String at the '|' char and give you the first entry.
yea except it's just removing all the characters from the string
String msg = "xxx|yyy|zzz";
String[] split = msg.split("\\|");
System.out.println(Arrays.toString(split));
System.out.println(split[0]);
yields
[xxx, yyy, zzz]
xxx
Isn't that just what I wrote but longer?
A hopper only tries to transfer an ItemStack to the connected Block if and only if its BlockState is of type BlockInventoryHolder.
hm
So it has to be a TileState and this state has to implement BlockInventoryHolder.
can i set a block to BlockInventoryHolder?
If this is your goal, I'd opt instead to do string.substring(0, string.indexOf('|'));
Avoids the splitting and is probably faster if all you care about is that first bit
No
Yea for me that just deletes everything from the string
:C
There is a workaround.
?note
What if it was in a player sentence?
that just creates the same problem for some reason
Actually two.
When the Chunk loads, get all TileStates and filter them so you get all the Hoppers in that Chunk.
Then for each hopper:
Either
Get their orientation and manually tick them.
Or
Go into NMS, and overwrite their implementation so they can transfer ItemStacks to your custom Blocks.
then your input string is strange.
Because Java doesn't just "not work" lol
Check the String before your change it
Im guessing that its empty to begin with
the 2nd option sounds good
Also, strings aren't mutable. So if you haven't already, re-assign it if you're trying to use the result
but i was thinking about set the block to chest
and modify it via packets for the player
Changing TileStates in NMS is possible but really tedious.
https://hastebin.com/ufiqoyabod
How should I change this code so that the player is eliminated when he dies?
please... separate... arena from a game object...
I have an example setup where i changed a furnace to be much faster and burn less fuel. Let me see if i can find it.
ok thanks
What do you mean by sentence?
I found out what was happening
anyway @plucky crow have a ondeath listener,check if your players list contains it,remove it from the list,set him as spectator?
game engine strunk
so I have java String message = ""; int i = 0; for (String s : args) { if (i >= 0) { if (message != "") message += " "; message += s; } i++; } and I was checking if i was > than 0 and that was removing the first argument
oh boy string checking with ==
public String toSentence(String[] words) {
return String.join(" ", words);
}
yall are wack if you don't use != with string
Welcome to Java
i feel like a stringbuilder might fit better..
You're wack
no
Or with a filter:
public String toSentence(String[] words) {
return Arrays.stream(words).filter(String::isEmpty).collect(Collectors.joining(" "));
}
If you use += with Strings then you can throw your saved cycles right out of the window...
Better unknow it
Allocating a new String every concat is bad mkay.
pain is fun
So I take it the compiler won’t optimize that
It actually does in some cases
But not if the logic is too convoluted
String.format is purely awful so don't use it
I know it will with standard “” + “” + “”
Sry cant find it atm
only available in paper in 1.17 afaik
it now has a api method to simply do setCookSpeedMultiplier
otherwise time tricks..
Looking for devs to help with my server (not hiring just idk help)
check how paper does it internally
stop spamming i doubt any decent dev will spend time without being payed @tight hedge
Am a self-proclaimed decent dev, here's what I can tell you:
we ain't slaves
Self-proclaimed, eh?
i proclaim that i am shit
lmao

Just saying "self-proclaimed" so people don't think I'm BSing because they expect to be better than everyone
Also comedic effect
I’m a self proclaimed self
yo guys what method should i use to store how much times a player has been punished (preferably store it on the server)
aight thanks
Preferably some SQL schema because you would then just store the punishments in SQL and could query from there
https://hastebin.com/mifevohaxi
Can you add a code to this code where players will be eliminated when they die?
PlayerDeathEvent etc..
I'll take the spoon
yeah but if i use json can the server fetch it at any time?
If you load it at runtime, sure
you made all that code so far,im sure you can handle adding bit more to it right?
Don't use YML for data storage
You use it for a bit and you suddenly have like 3 minute startup times
If you're storing on a file, use either sqlite (.db) or write your own proprietary extension
or dont be dumb to load everything at once and load it async on preloginevent..
and check there
Still good to not use yml unless needed
just make sure to query on main thread
inb4 he actually does it
lmfao i just talked with my dad who is experienced in db's and he said that yml is an actual piece of shit
true
while (true) would be better
its mostly used for very basic data storage
well storing bans kinda is basic
kinda
the server just fetches it when a new player is punished
and adds +1 to that player's punishment amount
It’s used for configuration
Because it’s easier to work with than json
Toml is nicer though
as i said you can use.. if you want to make use of the async login
however a sql can also be used in that time as well
even better as its async
Its so cold in my country that my gpu stays ingame at 35 C lol
Better formulated: It's so cold in your room
is it at all possible to connect to minehut via http https://cdn.tooty.xyz/wAXL new HTTPServer(this, 6969, handlers); ```java
public class HTTPServer {
private Logger logger;
private HttpServer httpServer;
public HTTPServer(Tooty plugin, int port, Map<String, HttpHandler> mapping) {
logger = plugin.getServer().getLogger();
try {
httpServer = HttpServer.create(new InetSocketAddress(port), 0);
for (var entry : mapping.entrySet()) {
httpServer.createContext(entry.getKey(), entry.getValue());
}
httpServer.setExecutor(null);
logger.info(String.format("Server listening on port %s", port));
} catch (IOException e) {
e.printStackTrace();
}
}
public void start() {
this.httpServer.start();
}
}
java
public class HTTPServer {
private Logger logger;
private HttpServer httpServer;
public HTTPServer(Tooty plugin, int port, Map<String, HttpHandler> mapping) {
logger = plugin.getServer().getLogger();
try {
httpServer = HttpServer.create(new InetSocketAddress(port), 0);
for (var entry : mapping.entrySet()) {
httpServer.createContext(entry.getKey(), entry.getValue());
}
httpServer.setExecutor(null);
logger.info(String.format("Server listening on port %s", port));
} catch (IOException e) {
e.printStackTrace();
}
}
public void start() {
this.httpServer.start();
}
}
it went all the way to 24s this time
ping on reply
I don't think I'd recommend com.sun.net.httpserver.HttpServer as it's sort of in-between API and Internals.
I believe Apache has their own solution.
also:
how would you connect to another server via a server? lol
You might want @little trail https://hc.apache.org/httpcomponents-client-5.1.x/
is there an easy way to parse itemstacks that are formatted like this:
acacia_boat{display:{Name:'[{"text":"My Item","italic":false}]',Lore:['[{"text":"Description","italic":false}]']},Enchantments:[{id:aqua_affinity,lvl:1}]}
?
are you sure that the properties match exactly?
?
But minehut said there's only 1 port open and that's for the host
So I don’t know if it'll work
what is that even trying to do and why is the code posted twice
this is what's used for the /give command, I'd assume that there is an automatic way of doing it
I assumed you meant pass it to ItemStack#parse
that's SNBT I'm pretty sure
essentially, NBT formatted as a JSON-like language
I see
is there an official way of parsing those
or will I have to use a json library like imaginedev said
because I'm pretty sure it's not valid JSON with some keys not having quotes
right
it's not an insurmountable problem, I'd just assume the function already exists since this is parsed for the /give command as well
Yeah find the deserializer in NMS
Hiya I've created a custom pathfinder goal for a mob (using NMS) and I've spawned the mob. It's moving all lovely, but when I disconnect and reconnect the pathfinder stops (aka the mob stands still) Why is this? when running /reload it keeps its pathfinder goals
Sounds like a bug
wdym it doesnt grow?
exactly that
it doesn’t grow up
how did you break it
ok
so try using the api
and you will have more luck i imagine
What event is fired for the Cartography Table when making a copy of maps?
ok well by using nms you are probably forgetting some method call to make it tick again
that is because it does all the extra checks to make sure it don’t break anything
well don’t look here for support with nms, look at the source code for the setType and see what method calls it does, or do some debugging first to see if it works with Block#setType
My Gs, how the heck does regex in java work? More specifically, the one in #String.split()? I've tested the regex in testers online and it seems to work perfectly, but when I copy and paste it inside the split() method, it just doesn't work. Is there some other format for it?
Here's what I tested in the regex testing website:
And here's what's in my method:
String sched = "MTWThF";
String[] weekdays = sched.split("/[A-Z]h|[A-Z]/g");
System.out.println(weekdays[0]);
// Output:
// MTWThF
// Expected Output:
// M
What regex tester is that?
Regular Expression Tester with highlighting for Javascript and PCRE. Quickly test and debug your regex.
Also tried this one here, same result https://regexr.com/
The first one isn’t for Java iirc
Nor the second one
It’s for JavaScript which follows quite a different convention
Oh, they're not all the same?
Sadly not
Dang. Do you know any websites for java regex?
Try google java regex tester maybe
Found this one: https://www.freeformatter.com/java-regex-tester.html
Free online Java regular expression tester with cheatsheet and most common solutions to common problems
Oh believe that one works
Yeah nw lol
regexr allows you to switch to the PCRE regex style
there is a cute dropdown in the top right
Ah couldn’t spot it 😆
Ohh neat, so java is the PCRE one?
PCRE is for perl apparently
I assume Java’s is based on it and therefor very similar
yea, you can read up on this in the docs of the Pattern class (https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html)
declaration: module: java.base, package: java.util.regex, class: Pattern
it is very close to perl 5 syntax
but is missing a few construct
should not matter for most usecases tho
would this be a smart place to ask for help with citizens or no
They have a discord don’t they
Bruh, the one in java still has the same format as what I'm aiming for. But now I realize the mistake
I forgot that #String.split() actually splits with the given regex, and not including it in the result
String sched = "aMbTcWdTheFf";
String[] weekdays = sched.split("[A-Z]h|[A-Z]");
System.out.println(weekdays[0]);
// Output:
// a
Like so
So I actually had the correct syntax, just not the correct method I guess?
hello, im editing blocks with packets
basically a simple player.sendBlockChange
but when he interacts at the modified block it backs to its original type
i would like to prevent this
Send the packet again using the interact event
Hi, I'm listening to the PlayerInteractEvent and trying to get Action.RIGHT_CLICK_AIR. I know docs say this: This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). so I've tried putting @EventHandler(ignoreCancelled = true) but it is never firing the event, thus I'm never catching theAction.RIGHT_CLICK_AIR, however it's catching Action.LEFT_CLICK_BLOCK etc. How do I listen to a player right clicking the air?
remove the ignore cancelled
Lol