#help-development
1 messages Β· Page 1719 of 1
here-and-there usage of static is usually fine, its just when EVERYTHING is static, that's when there's problems
what is the point in dependency injection frameworks?
all you're doing is passing an instance into a constructor or method..?
it gets repetitive overtime
just like setting getters and setters
it just saves time, that's it
wait nvm
that's a different topic
idk if that would work since /scoreboard is probs minecraft brigadier command, but maybe
#Server.dispatchCommand(#CommandSender, "scoreboard players reset @a Rcd");
would work?
ok im going to try it
idk if that parses the bukkit command map or the both brigadier vanilla command dispatcher and bukkit brigadier command dispatcher
it doesnt work
does it error out?
there's another way by using NMS
tbh i'd rather reset the scoreboard via scoreboard api
how can i do that with scoreboard api?
declaration: package: org.bukkit.scoreboard, interface: Scoreboard
btw my problem is that i cant detect that a player has the score
if i do the command:
/execute if score <player name> Rcd = 1
well just get all the online players
and reset the score
that's what literally @a does internally
is it player scoreboard entry
Wouldnβt you compare the scores with βmatchesβ?
oh wait
1sec
even when i use UUID it doesnt work
the test still fails
@mortal hare
https://wiki.vg/Protocol#Teams
Friendly Flags Byte Bit mask. 0x01: Allow friendly fire, 0x02: can see invisible players on same team., how to implement this?
@outer steeple use double ==
bitwise operations
use XOR
it can;t be an int, it has to be a Byte
to flip the 0x1th byte
protocol says its a byte
Ok, and what if I want to use both options?
flip another one
this.j ^= 0x02
0x00 XOR 0x01 === 0x01
0x01 XOR 0x10 (0x10 is equal to 2 in binary) == 0x11
If I use no option, 0x00, if I choose the first one 0x01 and if I choose the last one 0x02, but what if I want both?
Then I need 0x11?
public int packOptionData() {
int var0 = 0;
if (this.allowFriendlyFire()) {
var0 |= 1;
}
if (this.canSeeFriendlyInvisibles()) {
var0 |= 2;
}
return var0;
}
ScoreboardTeam does this
yes
but the OR operation doesnt allow you to reset the byte back
Can you write an method for me explaining what I have to choose?
Not sure what you are trying to achieve. these are simple operations
There are four options, I want to know what I have to put in if I want to choose them
Or none, first one, second one, or both
option first = 1, option second = 2, option both = 3
Yes and none = 0?
yes
Ok thank you, that is what I wanted to know
it uses these weird bitmasks due to save bandwidth
since these values can only be true or false
why send them as a separate booleans for each when you can store 8 states in one byte
What do they mean with Collision Rule?
you can disable player collisions for people in the same team
this technique is used to disable player collisions like in 1.8
a.k.a you couldnt push players
honestly it was a feature in since 1.0, i don't know why it was removed and readded in 1.9
So that means, they can fight their own team members or now?
Collision rule means that they can push other players
by movement
it doesnt involve with hitboxes at all
So they can walk through them?
yes
Ah ok
that's how oldcombatmechanics plugin do it inside
Cool
root:
obj: !!java.util.UUID '2273d49b-91f4-4e93-bfb6-d9a2dde0e4cd'
} catch (InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
}
When I load this YamlConfiguration, it runs this line. (YamlConfiguration.java:188)
Are UUIDs not supported? Where can I find the supported types?
Save it as string with UUID.toString and load it with UUID.fromString
So no direct support for UUIDs then. Okay, thx. π
Just wondered why it let's save that YamlConfiguration without error.
Seems a bit error prone.
true its weird that uuids can be deserialized but not serialized
Yeah. (though you probably mean serialized)
SnakeYaml will attempt to serialize anything thats passed to it
Isn't it, that it can in most cases? So I hoped the deserialization would work too. π
https://i.imgur.com/9s2mcQG.png
Anyone knows what is the problem?
I have a question, does anyone know how I can register my event with a constructor in the Main?
public void onMobSpawn(EntitySpawnEvent e) {
List<EntityType> types = Arrays.asList(EntityType.ZOMBIE, EntityType.SKELETON, EntityType.VILLAGER);
if (!types.contains(e.getEntityType())) {
return;
}
LivingEntity entity = (LivingEntity)e.getEntity();
entity.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
}
}```
help?
how can i restore the item?
You're probably depending on a different version of Spigot, that isn't 1.8
Why? You can't instantiate your Main class anyways, Spigot does that for you. Register them in the onEnable
With...? Make sure the event is registered.
it is
Explain the problem then, you can't just send code and say help π
i honestly have no idea whats wrong with it
maybe .sethelmet is not the right thing to do?
Is the event being called? Add a print statement.
Plugin Ketchop_Tutorial v0.8 has failed to register events for class me.ketchop.pog.main.Events.MobHeads because org/bukkit/event/entity/EntitySpawnEvent does not exist.
ok cool
What version are you using
1.8
well it looks like it exists
im getting scammed
Guess the server just doesn't know about it for some reason
Using viaversion or that shit?
Hello, i need some help
this code:
p.sendMessage("Created armor stand");
p.closeInventory();
if(plugin.armorstands.containsKey(p)){
ArmorStand stand = plugin.armorstands.get(p);
stand.setVisible(true);
plugin.armorstands.remove(p);
}```
should close the menu but it doesn't
and it sends the message
im literally getting scammed
π€·ββοΈ the only thing I can think of is that it doesn't exist in the server JAR.
No idea how that would happen though
Unless you're using some fork that renamed it for some reason
idek what a fork is tbh
PaperSpigot, for example, is a fork
dessie, could you help me? π
^ That's the only thing I could think to do
how?
?scheduling
but in the video i saw he didn't need to do delay
but he does the 1.12.2 inventories code maybe is for that
1.12.2 π¬
https://gist.github.com/f37764a931dcbb230eff9302f2d0928e why does it drop all items?
did i mess up curly braces?
they are all if statements, no else
so if its less than 0.0001 it will pass every test
how to i fill a inventory with the items from a custom loot table that is added with a data pack?
Wait but do java really depending that much on the order of them?
Blame me for not reading java tutorial by oracle
how is a growing wheat called?
Wheat stage 7
Do not use .equals() for enums, enums == only!!
yeah but in code
I used world painter to make map so i only know that
with what you were doing it, it very much did depend on the order.
String a = null;
this.component = new Component(a);
a = "Me";
What do you think the string that is now saved in Component would contain now? What if you put the a = "Me" before?
You're essentially passing the values that are contained in the variables. if you re-assign the variables, it only affects those variables, not the ones you passed previously. Especially since you were passing uninitialized stuff around.
I have a data pack on my server that contains a bunch of custom loot tables for our loot system, how can i fill an inventory with the loot? I see for vanilla loot tables you can use the LootTables enum and the
fillInventory method. But how can i do with with a custom loot table. No there is no physical chest to run a command on it needs to be added to an Inventory object within code. It it helps the loot table can be given to a player like this
/loot give @s loot lms:chests/common_loot
But i need to add it to a Spigot Inventory.
How would i detect which hand a player has attacked with?
My method of getting an object returns succesfully, but won't work correctly...
public BattleData getBattleData(Location l) {
for (int i = 0; i < allBattles.size(); i++) {
Location tempL = allBattles.get(i).getKey();
double rangeX = l.getX();
double rangeY = l.getY();
double tempX = tempL.getX();
double tempY = tempL.getY();
if (rangeX < 0) {
tempX *= -1;
rangeX *= -1;
}
if (rangeY < 0) {
tempY *= -1;
rangeY *= -1;
}
if ((tempX < (rangeX + 10) && (tempX > (rangeX - 10))) && (tempY < (rangeY + 10) && (tempY > (rangeY - 10)))) {
return allBattles.get(i);
}
}
return null;
}
BattleData battleData = main.battle.getBattleData(p.getLocation());
npcs = battleData.getBattleNPCList();
The NPCs line fails because "battleData" is null
how can i check if a pumpkin/melon has been grown naturally
show us the actual stack trace
Caused by: java.lang.NullPointerException: Cannot invoke "me.WesBag.TTCore.Files.BattleData.getBattleNPCList()" because "battleData" is null
at me.WesBag.TTCore.BattleMenu.Gags.Throw.Throw.onUse(Throw.java:26) ~[?:?]
at me.WesBag.TTCore.BattleMenu.BattleMenu.onInventoryClick(BattleMenu.java:577) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7]
... 18 more
um, your rangeX isn;t actually a range, its the X cord of the Location
But I use it to just add or subtract 10 to get the range
thats not a range
how i could use the build tools ? i already run build tools
you are making any negative x,y into a positive while ignoring z
Did you build 1.12.2
Yeah I'm just checking if the player's location is nearby the object's key location
Y doesn't matter to me
x and z are teh axis. y is height
Yes
why not just use teh Location.Distance method?
Mmm thats a good idea
you never use Z
yes
I'm still facing the problem of the method returning correctly but battleData being null though...
its falling though and returning null
because your math is all wrong
for (BattleData data: allBattles) {
if (data.getKey().distance(l) < 10)
return data;
}```
But I had a debug version of the method that would return shown here: https://pastebin.com/UajYFmdH
what i need to do
your math is all wrong. you are not using Z and you are not even calculating a distance between x and y
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Any idea why my plugin still contains mojang mappings after remapping with specialsource?
register<Exec>("obfuscate") {
workingDir = project.buildDir
commandLine(
"java",
"-jar",
project.rootDir.resolve("specialsource").resolve("SpecialSource.jar").absolutePath,
"--live",
"-i", project.rootDir.resolve("out").resolve("build.jar").absolutePath,
"-o", project.rootDir.absolutePath + "/out/build-remapped.jar",
"-m", project.rootDir.resolve("specialsource").resolve("maps-spigot.csrg").absolutePath
)
}```
because you should not be using speciaSource
paper, Not spigot
wait
Why?
look again
you are using maven? @west lance
No
I did everything as said in the "manual" guide
java -cp $HOME/.m2/repository/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar:$HOME/.m2/repository/org/spigotmc/spigot/1.17-R0.1-SNAPSHOT/spigot-1.17-R0.1-SNAPSHOT-remapped-obf.jar net.md_5.specialsource.SpecialSource --live -i $PLUGIN-obf.jar -o $PLUGIN.jar -m $HOME/.m2/repository/org/spigotmc/minecraft-server/1.17-R0.1-SNAPSHOT/minecraft-server-1.17-R0.1-SNAPSHOT-maps-spigot.csrg```
can;t help there, I've not done it manually
@eternal oxide I've tried your function and even added a message when it returns correctly. It does return correctly but the null error persists. Am I adding it to the list of BattleData incorrectly?
BattleData battleData = new BattleData(players, npcs, battleKey);
allBattles.add(battleData);
Because the method is working correctly, just the object it returns is not correct
it can;t be null if it returned a BattleData
I get the returned correctly message when run though...
public BattleData getBattleData(Location l, Player p) {
for (BattleData data: allBattles) {
if (data.getKey().distance(l) < 10) {
p.sendMessage("Returned correctly!");
return data;
}
}
}
Caused by: java.lang.NullPointerException: Cannot invoke "me.WesBag.TTCore.Files.BattleData.getBattleNPCList()" because "battleData" is null
at me.WesBag.TTCore.BattleMenu.Gags.Throw.Throw.onUse(Throw.java:26) ~[?:?]
at me.WesBag.TTCore.BattleMenu.BattleMenu.onInventoryClick(BattleMenu.java:595) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.17.1.jar:3246-Spigot-6c1c1b2-dc764e7]
... 18 more
Throw.java:26
BattleData battleData = main.battle.getBattleData(p.getLocation());
npcs = battleData.getBattleNPCList();
add another debug for if it doesn't find a battle
Like doesn't return in getBattleData
yes, when it falls through to your return null
I'm going to guess you are removing teh battleData from your list/set when they click?
No, I leave it there. Will that cause update issues?
I get the returned successfully message with no message about null...
No I was just guessing as the inventory click event can fire twice
nm, I'm thinking of the interact event
Just realized the getBattleData method isn't running in the Throw.java class
I have the event: https://pastebin.com/6PE6ejH6
I get the message "done getting the first db" and thats the last thing i get before console throws the errors..
The code you are showing now and the code you showed originally does not match the error you have been showing
How do I check that? In my pom file it's 1.8.8.
I get many more errors, but it's weird since it shows just fine before finalizing it.
https://i.imgur.com/qaHYpgg.png
the getBattleData method in this Listener is a two arg method.
hi there, can I set item meta even for air?
inventory slots
inventory object
player metadata
data structures that store data whenever you do something
object instance
every Inventory has its own Inventory object
if the compared instances don't match, they're different
no matter if they're identical in item stacks, names, lores, inventory view name
that's also a solution, but I'd be more happy if there is some way to just store data into it
you want metadata for inventories?
so I can just check some boolean and get if it is protected, .....
yep, exactly
well just wrap Inventory object into custom class
which holds booleans, etc
WrappedInventory.isProtected()
hmmm, that sounds as an solution
i bet you're doing a library for guis, right :D?
and the inventory from the event will be still this class, right?
no it wont
but you can check if that particular inventory is custom one
by storing it inside hashmap
or other data structure
nope, just a plugin, but I want some better approach, than the names, so I can have some colisions there
inside some kind of InventoryManager
if InventoryManager doesnt have Bukkit provided Inventory inside its own data structure
ignore it
but from what you are saying, it gets reconstructed somewhere, so I can't just use == to check if they are still the same?
besides that return CustomInventory
if you dont want custom data
just use ==
to compare if inventories are the same
if you do
you need some kind of registry to hold your wrapped inventories somewhere
ok, hashmaps use .equals, but this doesn't have the propertys, that you said
The method with the additional player parameter is the debug version to send messages to the player
lemme give you quick example
The code itself is the same in terms of usability
wait what, this isn't possible (or it is, but it isn't something, that will happen in this case) to have the same pointer, but different class?
because when it gets reconstructed, the == won't work
public class InventoryMeta {
private final Inventory inventory;
private boolean protect;
public InventoryMeta(Inventory inventory) {
Objects.requireNonNull(inventory, "Failed to construct custom inventory! Bukkit Inventory object cannot be null!");
this.inventory = inventory;
this.protect = protect;
}
@Nullable
public Inventory getInventory() {
return this.inventory;
}
public boolean isProtected() {
return this.protect;
}
}
then
oh, so you meant to make a wrapper
but why can't i just extend the class then
because it isn't final
you can
the thing is Inventory is an Interface
and implementation is CraftInventory
ik
this makes you use OBC
internal bukkit implementations
which would require reflections to support every version
np, because it can be version dependent
even still i think you couldnt extend it
because you wouldnt be allowed to create extended inventory
via bukkit methods
Bukkit.createInventory would create #CraftInventory
not your extended class
I decompiled it and it uses new CraftInventoryCustom(owner, size);, so it's still ok probably
what you would need to do is to register your own custom class inventory to some sorts of bukkit registry
that way Bukkit Event API would return you an inventory that you extended
new CraftInventoryCustom(owner, size); is a constructor for custom notchian type chest inventory
like 9x1, 9x2, 9x3, 9x4,9x6.. etc chest inventories
its not worth it
tbh
unless you write a gui lib
even that i would probably try to write packet level guis
which are more safe from dupes
since the items don't exist on the server and they're on the receiver's client only
idk how inventories are stored in bukkit
so cant say anything besides that
I am currently having a few issues with my servers. I uploaded a plugin which does a lot of thing async and therefor always calls Bukkit.getScheduler().runTaskAsync(() -> { [...] })
However since I uploaded that I am experiencing Server crashes. Normally I would just blame it on the plugin but I took a look at the heap dump:
After the Server crashed I had nearly 1 Million org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncDebugger instances.
After I then restarted I just had 150 instances.
So I suspect this is could be related. Is there any know Issues about that? Or is it something the plugin made wrong when calling runTaskAsync?
Btw the code which runs async publishes a message though jedis, so its most likely not stuck in the Async Task.
Disclaimer I know 1.8 is outdated af. I am not asking for a fix (I dont even know if its spigot related). I just want to know if there is a known bug / issue.
what do you run in async task
How to make a player spin in random directions very fast?
change their pitch and yaw
well - it is possible there is an issue with spigot but it is unlikely. can you show what you are running?
?paste the code you are using
Bukkit.getScheduler().runTaskAsynchronously(Core.getInstance(), () -> {
String json = gson.toJson(notifyData);
try (Jedis jedis = Core.getInstance().getJedisPool().getResource()) {
jedis.publish("server:v1:notify", json);
}
}```
i don't use jedis (redis), but here's what I found: Jedis is all synchronous with the exception of pipelines. Pipelines allow asynchronous usage of Redis but, unfortunately, cannot be used alongside clustering. However, pipelines are easy enough to use:
Use a custom thread pool for that
you could always just have a new thread that you dedicate to publishing
You might unintentionally grow the cached thread pool craft scheduler is using for async tasks which is unnecessary.
Alright I will that that, thank you
is there any way to completely remove the display of a player's name (above their head)
i think you do it with teams
You can add them to a scoreboard team and set the display nametags option to false
Yep
Ok thx
If i want to constantly check in an event if a player is contained in a set, should I use PlayerJoinEvent?
Well - It only gets triggered when a player joins - what do you mean by "constantly"
If i do a specific command the player gets added to a set, now to detect whether the player is in the set or not... im not sure what event to use since playerjoinevent only triggers when the player has joined
don;t track players, track their UniqueId
You can use a runnable to loop every x ticks
the Player object can go stale, their UUID will not
hi, small question about MongoDB designing, i have multiple documents that hold different coordinates and an owner. Should i have different documents for each location or have a single document with a single owner and all the locations? what is more efficient/cleaner to access/write to?
does anyone know the damagecause of /kill?
suicide and depression π
SUICIDE - Damage caused by committing suicide using the command "/kill"
Yo how can i include the api in the plugin
So i dont have to add 3836117 apis to a server
And just put all in one plugin
nope, I only extended the craftbukkit class and it works ok
you can use maven's scope for that
But shaded includes the apis?
try to add it as a dep and see if it works even without the plugin in your folder
well if you add it as a depend with maven/gradle ofc you have the api access
i tried removing the api from the thing
and the main plugin just dies
like doesnt even show on /pl
send the error
ugh, i just booted up my pc
ok i wil
UnknownDependencyException
quite usual
means that the api is missing
remove the plugin from depend or soft depend
aights
hm now the plugin doesnt die
lets see if it works
nope now the plugin is colored red
wait nvm
the joinevent doesnt work
everything else does
joinevent contains the netherboard api thing
then i guess netherboard needs to be included as a pl
lemme check their git hold o
yeah pretty sure you need to
maven
public class BroadcastReader extends JavaPlugin implements Listener {
public JDA jda;
public String guildId;
public String channelId;
public String botId;
@Override
public void onEnable() {
guildId = "758813062848708670";
channelId = "758813063448363011";
botId = "nonyas";
getServer().getPluginManager().registerEvents(this, this);
try {
jda = JDABuilder.createDefault(botId).build();
} catch (LoginException e) {
e.printStackTrace();
}
}
@EventHandler
public void onMessageBroadcast (BroadcastMessageEvent event) {
jda.getGuildById(guildId).getTextChannelById(channelId).sendMessage(event.getMessage());
}```
my plugin is intended to trigger on a broadcast message and then send the message to my discord channel. however it is not working as intended
or at least, i'm not sure hwo to debug it
uhhm
a few questions:
- what is considered a broadcast message?
- is my event handler set up correctly to trigger on broadcast messages?
- i have 3 warnings:
a. Method invocation 'getTextChannelById' may produce 'NullPointerException'
b. Method invocation 'sendMessage' may produce 'NullPointerException'
c. Result of 'MessageChannel.sendMessage()' is ignored
- Calls to Server#broadcast(). Maybe not quite what you want. You'd be more interested in AsyncPlayerChatEvent most likely
- Yes
- a. getGuildById() will return null if a guild with the id doesn't exist. You should check for this.
b. getTextChannelById() will return null if a channel with the id doesn't exist. ""
c.You can ignore this. Your IDE is being extremely over-sensitive. Unless of course you want to send some output based on the result of that sendMessage() call
Actually, JDA doesn't want you to ignore the return value. It seems to be annotated with @CheckReturnValue. Docs say you should follow calls to sendMessage() with a call to queue() (presumably so that you don't overload the Discord API)
The message will never be sent if you donβt queue, complete, or submit it
Ye
whats your import
So everything seems fine only you'll want to change your listener to look a bit more like this:
@EventHandler
public void onMessageBroadcast (BroadcastMessageEvent event) {
Guild guild = jda.getGuildById(guildId); // Though you should only get this once and then cache it, probably
if (guild == null) {
return;
}
TextChannel channel = guild.getTextChannelById(channelId); // This too you should probably get once and cache
if (channel == null) {
return;
}
channel.sendMessage(event.getMessage()).queue();
}```
(and use AsyncPlayerChatEvent if preferred - I don't know if you're actually listening to server broadcasts on purpose)
so I have a method that makes a request to mongo and returns the value and i was wondering if there was a way to execute it async as it probably would slow down the main thread
of if i should not be worried about it
CompletableFuture is your best friend
hello
05.10 21:07:35 [Server] Server thread/ERROR Could not load 'plugins/BingoBook.jar' in folder 'plugins'
05.10 21:07:35 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: fr/frenchkiwi/bingobook/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0```
can someone explain what this means rq ?
uhh interesting, i'll give it a look
baeldung always has really good articles on everything you need
https://www.baeldung.com/java-completablefuture
i can't load my plugin
would it give issues with spigot or nah
which is sad
Your server is running on Java 8, your plugin is compiled against Java 16, frenchkiwi
how do i fix this ?
So either downgrade the version against which you're compiling your plugin, or run your server using 16
how do i downgrade the compiling version ?
Going to assume you're not running MC 1.17+ because it requires Java 16 heh
Depends on your IDE
eclipse
1 sec
and no, mc 1.16.5
- Click your project and press Alt + Enter
- Press "Java Build Path"
- Select "Libraries" in the top tab bar
- Click on "JRE System Library [JavaSE-16]" (or something similarly named to that), then press "Edit" on the right
- Select the Java 8 build environment
found it
If you don't see "jdk-8.0.275.1" (or something similar to that), you may not have Java 8 installed properly. Though I think Eclipse has it installed by default
thanks imma try rq
How do i make a runnable loop? And where would I use it?
yep - all bold
yea
where would i use it tho?
Pretty much anywhere you want. Presumably on startup if you're performing the same task such that your plugin is enabled
Can just schedule a timer to run every tick or every second in your onEnable()
are methods in methods even possible?
No, but it's not a method. It's a Runnable
you can provide a lambda
@Override
public void onEnable() {
Bukkit.getScheduler().runTaskTimer(this, () -> {
// Code written in here is run every tick
}, 0L, 1L);
}```
methods inside methods are called either anonymous functions, or lambda expressions.
Or you can have a class implement Runnable as well and create a new instance of it
If you require some instance fields and constructors, etc.
oh ok
getCommand("bc").setExecutor(new CommandTest());``` this is so basic and yet not working what is wrong with me
i figured
so i've looked into completable future but would I be able to cancel an event async with it? I'm tryna check on block break if my db contains the coords of those blocks and if they are there cancel
05.10 21:13:48 [Server] INFO at fr.frenchkiwi.bingobook.Main.onEnable(Main.java:12) ~[?:?]```
you need to register your commands in the plugin.yml
maybe
okay well thanks
sorry to ask dulb questions
dw
NPE there most likely means getCommand is returning null, did you register it in plugin.yml
my code is in a event class that implements listener, so i cant implement runnable, and i have no idea how im going to check if a player is in a set in the main class if i can't get the player without using an event
sorry if the text was confusing o_O
What do you need to do if the player is in the set>
can i set my guild and textchannel in my onenable ? it should remain the same throughout separate functions right?
p.addPotionEffect(PotionEffectType.FIRE_RESISTANCE.createEffect(999999, 1));
p.addPotionEffect(PotionEffectType.DAMAGE_RESISTANCE.createEffect(999999, 5));
p.setHealthScale(60);
Yep!
So just make a runnable that runs every say 20 ticks and give them 2 secs of those effects to allow for tps drops
But i dont know how to reference the player in the main class
Where is the set, why dont you have it as a field in the main and then just add adder / remover methods
would totally be cool to do player chats too... i just wanted to start with broadcast messages because i thought that would be a good way to get any server news over to the discord
even doing messages to and from the server would be dope
Not many plugins use broadcastMessage
i just need an easy way to debug and make sure messages are sending for now
i can concern myself with the actual content of the message after
there is no setMarker method in 1.8.8 for entityarmorstand
what to do
was that even a thing in 1.8
but i mean
implement it yourself??
just add it to craftbukkit and bukkit and then compile
you mean i should edit the whole 1.8 for a plugin ?
Or you can use NMS
im using nms
that^
what is entityarmorstand then
craftarmorstand has setMarker
but not entityarmorstand
anyway to edit its nbt
without NBTAPI
entityarmorstand probably has the methof name obfuscated
The craftarmorstand version should work
there was nothing on bukkit, spigot and..
if i want to use craftarmorstand
i simply use armorstand
i want the nms armorstand
@worldly ingot messages aren't sending... i want to assume that using /broadcast message here
would work
oh wait a second
Assuming you mean Essentials' /broadcast command, it depends entirely on how Essentials implements it
They might just loop all players and use Player#sendMessage() manually instead of Server#broadcast()
my guild is returning null
Well, that would help too π
why
If you're using the NMS stand, the method is probably obfuscated by that point because API hadn't been added until later
Take a browse through nms.EntityArmorStand and see where the field determining its marker status is being set
the code ?
Could be .h() or something ;p
Yes
Reading the entity's NBT save/load methods makes determining which field is marker much easier (because strings aren't obfuscated, for obvious reasons), then find the method that sets that field to whatever value
Is anybody using jitpack as maven repo for java 16 project?
I just cant make it work
i found a thread yesterday explaining how to make floating items with packets
but i cannot find it now. can anyone give a thread explaining how to do it
ctrl + H
What
ItemStack skull = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (byte) 3);```
this
i tried SKULL_ITEM
but the only way is the LEGACY_SKULL_ITEM
What's the difference
Anything LEGACY_ you should avoid and never directly reference
If you're using LEGACY_ constants, yes. You want to use the ones without that prefix
You'll want to set api-version: 1.13 (or higher) if you're using the new constants
what does latest spigot do if api version is older than the spigot version
i always assumed it would just deactivate the plugin
or say your spigot is too new or something
could some1 help me with it
you ran for 1.12.2?
yes and yes
nah
it doesn't care
ok
π
forge once did this and got a letter from maven
so its no different to just an ide loading really
- as in downloading it
if not in m2
Ok
It seemed like it was "you cant have access to the class loader but we will give you this instead"
@EventHandler
public void entityDamagedByEntity(EntityDamageByEntityEvent e){
if (e.getDamager() instanceof Player) {
Player damager = (Player) e.getDamager();
Entity entity = e.getEntity();
will 'Entity entity = e.getEntity();'
use a player as a entity
if you test for it
I think I just need to target blazes only
Yeah, that will call for any entity, including players
thought so
You can compare e.getEntityType() if you'd like
Or instanceof if you want some more convenient casting
if (e.getEntity() instanceof Blaze blaze) {
// etc.
}```
e.getEntityType() should just do the job
Depends on what you want, yeah
just when a players hit them , they don't take kb
is there any event fired just after inventoryclickevent? to get the resulting inventory after the server processes inventoryclickevent
Putting them side-by-side in a formatted comparison, you can see why it fails
https://paste.md-5.net/celufixoko.json
Suppose GSON is treating them as actual objects
Yeah I see the = lol
That being said, for what reason are you serializing/deserializing?
Working on my schematics
Chest items need to be saved.
something like LateInventoryClickEvent
or do I have to use schedulers in some way
Anyway to fix the gson using = instead of :?
looks like Map.toString() is doing the = not GSON
MY PLUGIN WORKS LETS GOOOO
Nice
nice
Wow... exactly 2k chars and it won't let me post it.
Gson gson = new Gson();
Map<String, Object> serializedItem = i.serialize();
String serializedString = gson.toJson(serializedItem);
Bukkit.broadcastMessage("GSON >> "+serializedString);
ItemStack is = null;
Map<String, Object> deserializedItem = gson.fromJson(serializedString, new TypeToken<Map<String, Object>>(){}.getType());
Bukkit.broadcastMessage("deserializedItem >> "+gson.toJson(deserializedItem));
is = ItemStack.deserialize(deserializedItem);
GSON >> {"v":2730,"type":"DIAMOND_PICKAXE","meta":{"displayName":"[{"text":"Testing","italic":false,"color":"gold","bold":true}]","lore":["[{"text":"","italic":false}]","[{"text":"Testing","italic":false,"color":"gray"}]"],"enchantments":{"Enchantment[minecraft:efficiency, DIG_SPEED]":5,"Enchantment[minecraft:fortune, LOOT_BONUS_BLOCKS]":3,"Enchantment[minecraft:unbreaking, DURABILITY]":3},"attributeModifiers":{},"repairCost":0,"hideFlag":5,"unbreakable":true,"damage":1560,"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":2730}}
deserializedItem >> {"v":2730.0,"type":"DIAMOND_PICKAXE","meta":{"displayName":"[{"text":"Testing","italic":false,"color":"gold","bold":true}]","lore":["[{"text":"","italic":false}]","[{"text":"Testing","italic":false,"color":"gray"}]"],"enchantments":{"Enchantment[minecraft:efficiency, DIG_SPEED]":5.0,"Enchantment[minecraft:fortune, LOOT_BONUS_BLOCKS]":3.0,"Enchantment[minecraft:unbreaking, DURABILITY]":3.0},"attributeModifiers":{},"repairCost":0.0,"hideFlag":5.0,"unbreakable":true,"damage":1560.0,"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":2730.0}}```
Besides integers being doubles they're the same now. But item still isn't the same.
but it would show as red and clyde said it was unable to be sent
yeap
I repasted the message and it said -6 chars even though originally it said 0
It will tell you if you hover over
what
cant find what
if you are using eclipse
ig you can try ctrl a ctrl x ctrl v
sometimes magically fixes problems for me
cause eclipse manages to find problems that dont even exist
btw how can i get the inventory after InventoryClickEvent? (Im talking about the βevent.getInventory()β one not the βevent.getWhoClicked().getInventory()β)
get the inventory AFTER server processes inventoryclickevent
Whats wrong with event.getInventory()
You will need to use a runnable I imagine
it gives you the inventory state before the click
My first question is. Why is that necessary?
However if it was, youβd have to store it somewhere and use it from that
but how do i know for how long, it feels like an arbitrary unnecessary wait
You would need to use the holder then and delay a getInventory()
What are you trying to do, like what problem are you solving that makes you think you need to do that
for many things, in my case im making a gui
1 tick is all you need
You donβt need to do that for a GUI
Or use High priority so it runs after everything.
is 1l 1 tick?
does that work?
im pretty sure HIGH can still cancel events
make a GUI handler class, and make guis from that. I extend my GUI class and make guis from that. All the listeners are handled through my api. If you do it manually every time, youβre just dealing with too much duplicate code
Yes but it would be the last to do so
well I do Β―_(γ)_/Β―
yes but the item is still not in e.getinventory
that goes after all events
even the HIGHEST ones
iirc
I donβt think I understand your objective
All priorities can cancel events
And I donβt think you understand what Iβm saying
so that means they run BEFORE the action is actually done in the server
yeah
yeah
anyone know how to get where the current world border is
Some of those yes
i googled but all i got was shit about how to use /worldborder
how would i know the inventory state if an event can run later (HIGHEST), and cancel the click
If it implements Cancellable then it should
Wym
Sadly there isnβt really any post events for certain actions
Youβd just have to rely on that no one is manipulating at monitor priority
And if someone actually does that then itβs out of your control
if i have a HIGH priority event i cannot determine the post state since a HIGHEST event could easily cancel it
Monitor can be used
for example inventory state after inventoryclick
But yeah highest is invoked after high
Plugins shouldn't be cancelling in monitor
Why not just set yours to highest?
ive been trying to fix that whole in a gui when you have an item thats null it giving that error to the console, I cant find anything that works anyone got any ideas?
should i just schedule for 1tick?
Plugins shouldnβt generally be doing anything considered as a mutation in monitor
if another plugin is cancelling the event it should be cancelled
^
Thatβs one way
or use monitor
I try shit like else if (e.getCurrentItem().getType() == null)
Then return it
if the item is null
the type cant be null
but how do i schedule? because e.getinv is always the same
OH
Type can never be null anyway
THAT MAKES SENSE
afaik
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
What's this for 1.13+
no matter when its run
PLAYER_HEAD iirc
, 1
magic values π
PYAYER_HEAD, got it π
@civic apex it isnβt
do you memorize data values?
Either itβs the actual instance or a delegate
So any actions made on that instance would have to be reflected onto the actual inventory
huh i tried earlier and it gave same state lemme try
Even if scheduled
I know, I'm updating a no longer updated resource.
The code's shit
can i have two plugins in one jar?
Nah I just happen to remember a lot of them
They generally match the in game name
cool
Depends on what your definition of a plugin is
But if itβs having 2 jars in one jar
Yeah in principle
Like nested jars
btw random question how should i handle compilling after a project gets big
Wym?
many classes
i was considering doing another class that extends another javaplugin
compile time high
Uh code architecture or just compiling time?
time
i guess
well the issue comes down to the fact that i cant extend two classes in one
Correct
Well you can isolate your io devices from your business rules and put them behind boundaries, each io device handler would then have its own jar such that you can independently deploy
You can implement several interfaces though
In that case not everything would have to recompile everytime
Also you can only have one class extending JavaPlugin
public class BroadcastReader extends JavaPlugin implements Listener extends ListenerAdapater
create one class that extends another, then extend that another class
ohhh
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null
this error is so annoying
}else if (e.getCurrentItem() == null) {
return;
}```
this should work right?
is it possible to get a world from a location
thx
static!
Just method reference 
i meant with spigot
I mean, you can probably modify that file with spigot
ok
But you probably shouldn't
lol someone made a library
thx google
outdated reeeeeeeeeeeeeeeeeeee
what is DedicatedServer in the new api
ah so commands don't count as playermessageevents
would something like this work?
try {
List<String> lines = Files.readAllLines(path);
for(String line : lines) {
if(line.startsWith("spawn-protection")) {
lines.remove(line);
break;
}
}
lines.add("spawn-protection=0");
Files.write(path, lines, StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
is there a generic event that handles all console messages?
i may not want it just because i want control over which events and messages are sent to discord
Path path = Paths.get(getDataFolder().getParentFile().getAbsolutePath()).getParent().resolve("server.properties");
try {
List<String> lines = Files.readAllLines(path);
for(String line : lines) {
if(line.startsWith("spawn-protection")) {
if(line != "spawn-protection=0") {
lines.remove(line);
lines.add("spawn-protection=0");
reloader.runTaskLater(this, 30L * 10L);
}
break;
}
}
Files.write(path, lines, StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
now would it work lol
(reloader is just a bukkitrunnable with Bukkit.reload)
it returns a ClassNotFoundException
nvm
i screwed up plugin.yml lol
ok so this is an issue that has been haunting me for a little while and I want to get it fixed at this point
for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(10, 10, 10)) {
entity.setVelocity(entity.getLocation().clone().subtract(eliteEntity.getLivingEntity().getLocation()).toVector().normalize().multiply(2).setY(1.5));
if (entity instanceof LivingEntity)
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 3, 2));
}
is sometimes - not always - printing java.lang.IllegalArgumentException: x not finite for set velocity
am I somehow rounding this in a dumb way because I can't really picture how x isn't finite here
I just can't picture how x isn't finite
the only way I can twist this into something I can understand is if somehow on the same tick the entity died but also still somehow got picked up in the nearby entity scan and also somehow the location of the entity is now nonsensical
how do i reference my current instance of spigot in a class outside of my javaplugin class
of spigot or of your plugin
Bukkit.getServer() gets your server
okay
is there a server class
that i can set that equal to as a variable
yes there is
... that's what that method returns
TabCompleter vs TabExecutor?
TabExecutor is just a TabCompleter and a CommandExecutor
instead of implementing both, you can just implement TabExecutor. Is just a convenience interface
really? i always implemented both
So, here's a good question.
There's a utility class that creates a bunch of items with customizable lore/display names.
What's the best way of handling that as a whole?
Make the messages config public static or what?
you can look up utility classes online and pick whichever level you want to do
some people go extra hard to make sure they're used in a specific way
I know how utility classes are, in this case it's
private ItemUtils(){}
// creation methods
}
I guess i could do constants, but it runs into the same issue since those are static π
I generally have a MessagesFile class that has methods to send messages and parse PAPI / built-in placeholders
with automatic colors and whatever
making the class constructor private is so extra I have a hard time bringing myself to do it
Then my messages.yml file looks like
messages:
prefix: "&5&lSome&d&lPlugin &8Β»&f"
some-message: "%prefix% &aHello!"
and I just call
messagesFile.sendMessage(commandSender, "some-message");
Same, but in this case it's not something that can be passed around, which is how I'd normally do it.
Hence the question
In that case
this is for storing config fields?
A constants class with a public static void load(FileConfiguration config) method
or rather to store stuff you get from config is how I should phrase it
And whatever methods you need
ItemStacks in my case, the names & lore are pulled from a config for configuration purposes
Are you using those items in enums or something?
I'll be honest, no fucking clue how the code handles them.
Going off the methods provided, they should be constants instead of getters... but I still run into the issue of how to properly handle the configuration aspect
only case I'd have to make a Constants class is if I am using enums with custom values
personally I have a setup that initializes public static non-final fields for whatever it is I need from config and they're stored in the class that does the config initialization, makes it super convenient to me
I can't really share much code but my idea is just
with some getters
and that's the only project I ever had to use such code because it's like 90% enums
Guess i could do ItemConstants and commit "bad code" and have static stuff. I could shove the constant fields in the main class as well ig
But if I need items from config
static isn't bad code
yeah
It depends
trying to not abuse it, hence the question π
for convenience
static abuse is bad, but static exists for a valid reason and it would be bad code not to use it in those instances
this sounds like one such instance
It's not abuse as you're using it for constants that are used throughout the plugin's lifespan and serve no other purpose
just make sure to call clone() otherwise you can have weird issues (when manipulating the constant objects)
Yea, no real clean way to do it non-statically in this case.
Unless i wanna pass a class around just for items that are constants π€£
sure there are clean ways to do it non-static
they're just way worse than using static
my main always acts as a sort of proxy to all getters I'll ever need
No matter the project size, all classes that need to interact with each other have access to my main
via dependency injection
Yea ik. However these items are configurable constants.
in any other case I'd just do public static ItemStack ITEM_STACK ... and call it a day
I don't see what the problem with them being configurable is
I've got literally thousands of those and it's not a big deal
actually I have tens of thousands but w/eve
r
It's done in a Util class which means I can't pass a class to it. Wasn't 100% sure on the best way of handling that hence asking
just make a public static void load(...)
Yea, most likely gonna do that.
Don't like it, but anything else is just dumb
Β―_(γ)_/Β―
Yea, this class can't be extended, implemented, or initialized π
don't get stuck picking the wallpaper
yeah just do it and move on
I'm looking at some massive projects of mine and I'm just like
Yea i know, I figured it was best to ask here first to see if there was some better way π
"how tf did I make a whole skyblock core with multi-proxy support and custom packet system in 5k lines"
3 months from now you'll look back and find a better way
maybe lol
12 months later you'll go back and find an even better way
I have yet to learn assembly, but i want to π
20 years later and you'll be too drunk from trying to forget all the bad code decisions that took you to that point in life to find better solutions
it'll pair well with https://github.com/Overv/MineAssemble
1k is nothing for an mc server
for a server jar? π
you need to review your definition of what a mc server is and how much money 1k is
Tbf, that would probably be the most optimized server jar out there π
specially in assembly
99% of people out there aren't paying $1 even if doing so gave them eternal life
but if you're reselling
Imagine the amount of click-bait i can put π€£
"100% MOST OPTIMIZED SERVER JAR ON THE MARKET"
"fully async no lag only performance best jar minecraft fortnite tik tok 2019 2022"
just toss all the keywords
"gets you all the girls"
you guys are going in the wrong direction
"gets you laid the moment you run it in kubuntu"
say hello to MineStonk, the first cryptominer mc server
play mc and get paid to do it
I get 50% of whatever you mine
I know a lot of pump and dump that were quicker than that
I'd probably want to learn C or C++ first though lol
who cares about performance when you're making that stonks money
C was fun
I do have a book on assembly though, same with python and php π
"minesupreme we sell your IP address every time you join to some swat team"
I dislike python
Yea, but if i make a super optimized jar, then i can just add a nice API and make those damn forks useless lol
it's simple to the point of autocompletes not working
minetrends please fill this form every time you join so we get 50 cents for every 1000 forms filled
optic quick question not sure if you know
If I send a new metadata packet, with 1 element, do all old values get overwritten to their default state?
am I more advanced than you π
Nah, i just don't main spigot deving lol
I main spigot deving and I don't touch packets
rip
that shit is cursed
I got bored so I made my own packet system inspired on NMS
with like 250 different ways of handling
What is the lambda way to run a Sync task inside an Async task? I forgot
you can config it to use redis, rabbitmq, plugin messaging
mysql if I can bother with querying every 5ms
and im getting Netty Server IO #1 ERROR Recursive call to appender Async
show code
trying to get nearby entities inside a ProtocolLib listener.
god that stupid reddit meme about programmer socks is stuck in my mind every time I think about having to buy new socks
if(!Bukkit.isPrimaryThread())
Bukkit.getScheduler().runTask(main, () -> fetch(idk));
fetch(idk);
mm socks
oh my god even amazon sellers are unironically doing this meme
β€οΈ u
1000 years from now people will look back at things like programming socks and I am not sure that they will know that it was meant to be a joke
because they will be standard
I am having trouble changing the game state change packet, the issue seems to be on the line packet.getIntegers().write(4, 1); but I can't seem to find any example of what I need to do instead of that, what could I use?
Decompile the NMS packet and read the fields
Not the constructor
And also look at how it serializes and what it corresponds to in wiki.vg
I am somewhat new to this and don't completely get what you are saying, how might I decompile the NMS packet and what do you mean by serializes?
Is there a way to add "custom" data to a block that can be stored inside it through restarts...?
instead of having to store info about it in lore.
PacketPlayOut<something here>
Then middle click in intellij
Example: PacketPlayOutSpawnEntity
As for serializing
There's usually a method that writes stuff to a PacketSerializer
And that stuff corresponds with wiki.vg
Helps you figure out what field is what
Hm mine does not seem to recognize anything when I do anything beyond Packet, maybe I didn't import correctly
ok
Can I use offlineplayer to get a player even if he is online?
If you want to
Have no problems generating a player using offline player?
Example:
Offlineplayer player = args[0]
if(player.isonline) {
//code
else {
// code
}
I mean that isnβt how you get an offline player, but sure
What is the best way to pull?
Any dev who want to make a plugin for me? I have Paypal DM please
Keep in mind getting an offline player by name may involve a blocking web request
Bukkit.getOfflinePlayer
Mhm
.
How do I get through uuid?
Hm that also seems to have not worked
try using IntelliJ and minecraft development plugin
that plugin is for intellij
I have done that
are entity ids/uuids persistent through restart
Entity ids, no. UUID, yes
I'm very new to this, so I am sorry if this is a bit dumb. I'm trying to add Spigot API thru gradle but it seems to be failing whenever I add 1.17 but not on other versions, any ideas as to why?
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url "https://hub.spigotmc.org/nexus/content/repositories/public/" }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation 'org.bukkit:bukkit:1.17.1-R0.1-SNAPSHOT'
implementation 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}
test {
useJUnitPlatform()
}```
You don't need the Bukkit API if you're adding the Spigot API
Though it LGTM. No reason for that not to work as far as I'm concerned
This may help, but not sure.
Yeah. Remove the Bukkit dependency
Spigot comes with Bukkit and the Bukkit API isn't hosted on the Nexus anymore

Hey, Im trying to use postgres with spigot but I get a ClassNotFoundException even Though I package it with gradle, here are my build and Postgres class files, Can anyone point out whats wrong to me? Thanks a ton! (I use Intellij IDEA)
Postgres :
https://srcb.in/IbVOKirPcd
Gradle Build:
https://srcb.in/11JAAledIA
hello, how the ItemStack works in NMS ?
Jordan's one?
invalid plugin.yml
name: Ranks
version: 1.0
author: Rithul Kamesh
main: com.rithulk.ranks.Ranks
description: The Ranks Plugin for Sniping_'s Mc Server
api-version: 1.8.8S