#help-development
1 messages · Page 1891 of 1
I don't like how bloated Notepad++'s UI is :p
And Notepad has actually gotten better in recent years
Like it works with Unix newlines now
Also for Nano
I literally don't know how to use Vim
So I prefer Nano since it's easier
oh its actually pretty simple
People make all these arguments about like
"well aliases and shit make my workflow faster"
but it takes longer to set all that stuff up than it takes to do stuff manually anyways
only time I edit options is when IDEA's defaults are shit or I need to install plugins
(also tabbed editors should auto-save by default, d@m)
vim <filename>
press I to enter insert mode (this lets u type normally to add/remove text)
press Esc to exit insert mode and enter visual? mode iirc, at this point ur done doing what u needed to do to the file
and then type either :w to write/save, :wq to write/save & quit, or :q/:q! to quit (q! ignores changes, typing just :q after modifying yells at u)
okay but
why would I bother with this when I can just
nano <filename>
type some shit
CTRL + S
i thought its ctrl+x ctrl+o when ur done
you can CTRL + S
o
idk i use vim
vim is awesome
anyone know how i can set up mvn -b for an already existing project with intellij dependencies and stuff
mvn -b?
what does it even do?
you know the one good feature of Maven is archetypes
yeah
I wish Gradle had those
although Maven always uses the shittiest terms like
intellij dependencies, is the project not already a maven one?
i mean yeaaah
but it has dependencies in iml
makes perfect sense in german 😄
then make them maven
ugh no
you MUST use maven to handle ALL your dependencies
:(
Project Template would suit it more i think
well I am not German lmao
ok
well I mean
yeah yeah template works better
I translated archetype to german and it means something like "origin"
or "starting point"
add all your dependencies to maven and it'll work
i cant tho
why not
and also yeah archetype makes sense but
why not?
I only know the definition because D&D also uses it for their fucking character classes
<scope>system</scope>
???????
Classes have different archetypes
allows you to use a file path for the dependencies
Like Rogue has stuff like Thief
Can you like explain it
haha systemPath go brrrrrrrrrr
canonically
instead of just giving random snippets of stuff assuming i know the rest?
sorry im just a little frustrated
yes
but y'know what's worse?
maven projects but fucking worse
check my pom for InvUnload - you can just use scope system and then give the file path to your dependency
#general
and you can also ALWAYS use mvn install:install-file to put ANY .jar into your local repo to use it WITHOUT system scope
if you tell how your .jars are called that are NOT in any repo, and I'll explain to you how you can use them with maven easily
ping me when you reply, otherwise I won't see it
github actions wont work since the jar is not on the server that github is on
i think
idk
oh well, but then it won't work anyway
any way to fix that?
if your dependencies are on github, you can use jitpack
upload the local artifact with the commit
lemme explain one sec
so whenever someone commits or pushes it makes sure an artifact is in a specific folder (person builds it on their own)
can i do that
and if not the push fails
possible or no
bc im lazy
Is it possible to just cast an itemstack back to your custom item ?
i dont think so
i think it might be converted to like an nms item and back or something
but ask someone else
Try it and see lol
not unless your custom item extends itemstack, but even then itd be precarious
because like
how would it even work if you like
have an item and then the plugin is removed
and then .getClass() is called on the item
what would be the best way to recognize an item with 1.12.2? NBTTags?
itll return a class that isnt there????
Try the NBTAPI
danke
So this is a interesting conundrum
The current build of fawe is supposed to support 1.16.5
But also forces Java 17
But spigot 1.16.5 does not support java versions above 15
Does anyone happen to know what the last properly compatible version of fawe is?
is == possible with itemstacks?
on pre 1.14.1: yes, NBT is the only way to go
yes, but
unreliable?
you should just use equals()
but i was thinkin more for a gui thing
I will give an example:
If you only care of the material use material. If it's a custom item use PDC
is it possible to run code on push to github?
like
when someone pushes it does a maven target on their machine first
sure, with actions 😛
Asking about your attempted solution rather than your actual problem
I am sure there is an easier way than gh actions
hello, i asked for help a couple days ago and was told to read on the java docs for assistance, and i found something. i have two classes, one is the Over powered mobs class, and the other is the command class to toggle it. My main question is, to get two classes to be able to call for each other, would i have to use the implements (classname) in it?
no
sorry to say this, but:
?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.
LOL back to learning java
i feel like this is how u learn tho mfna
i am currently reading the docs rn
like asking stupid questions is a part of the process
yes i know
If you have stuff that you need to access from another class...
you need a reference to the instance of that class
so, for example
imagine you have one listener, and one commandexecutor
first explain it in animals
you could store the reference to both of that instances in your main class
ol reliable
for example, using animals:
public class Main extends JavaPlugin {
private Dog dog;
private Cat cat;
private static Main instance;
{
instance = this;
}
public static Main getInstance() {
return instance;
}
public getDog() {
return dog;
}
Now, in your Cat class, you can do:
Dog dog = Main.getInstance().getDog();
the other alternative would be dependency injection
dependency injection is actually better in terms of structure, buuuuuuuut
it's harder and more annoying to setup and there's no real advantage over the static getInstance() method in your main class unless you actually know why there would be any advantage
I wrote a blog post about "accessing your main class from other classes", which is basically 50% of your problem right now: https://blog.jeff-media.com/getting-your-main-classes-instance-in-another-class/
so just read the blog post, and add a getter method for the object you need in your other class, then you're done
If only minecraft used c#
nothing would chance
except you could only run on windows ¯_(ツ)_/¯
Minecraft would actually be worse on C# lmao
for this reason
c# is native to windows
basically all iOS apps are written in C#
around the time Minecraft was released, pretty much only .NET existed for C#
and that was .NET Framework
not .NET Core
.NET Framework only supported Windows
Yeah but are they ever gonna get performance up with java?
here is why i am trying to do this, i am trying to make a command (the one class i talked about before) that enables and disables the spawning of all over powered mobs, and someone said insert a boolean somewhere, and that is why i am reading the java docs, to know when and where to insert true or false statements and you are right, what you just told me solved half my problem!
Java is not their performance problem
It's the fact that Mojang developers don't know how to fix the performance of an old fucking codebase
And Notch was not very good at optimizing certain parts of the game
Neither is current mojang
Yeah but I thought when they made bedrock they could fix the old shit
Instead in turned into a microtransations bs
Bedrock is also C++ iirc.
Which is shown pretty clearly by java mods making the game run so much better with comperatively little work
but basically
Only by cleaning up the rendering
Java is not slow at all
it is a disaster for performance
It's not as fast as C# or other langs
Ok, first off
But it is at least manageable
guys please not in here
i actually need to get help with smtn lol
Yes it is
Yeah true sorry 😂
There's a reason why Python is slower than other languages almost all of the time.
Interpreted moment
But anyway is using nbt tags reliable for custom item checking? (1.12.2)
@tender shard so basically i am trying to set up nightly.link so my server pulls the latest version of all our plugins automatically
Interpreter vs compiler.
JIT vs AOT.
Bytecode only? (Lua runs pretty well because of bytecode)
How well implemented is the language?
Yeah as reliable as you can get probably
From api pov
Interpreted is slower than compiled most of the time because of additional performance costs.
What other perspective can you get?
Yeah or just create a thread
Sometimes programs are just more complicated to parse, and compilers clear that up because they turn large trees of statements into sets of instructions.
I mean implementation
but yeah, #general
conclure how would i set up nightly.link with my project. i will convert all my dependencies to local maven dependencies but the jar still needs to be built on the pusher's machine
Java is mye, not a disaster for performance :3
let me know if you still have any questions or if you don't know what to do 🙂
@tender shard can you help me w/ this?
nightly.link? sorry no idea what that even means
Probably his machine place or something
nah
it's really useful https://nightly.link
but anyways
i just need upload-artifact
but
it needs to be automatic with the build artifact
so like
depended jars are local, right? so the user needs to build the target artifact to the project on their machine and then push
but i want to automate that
i use maven
any ideas?
@tender shard @ivory sleet
i have joined your discord server 😄
how to install a local repository in maven
like
i want to put a jar as a maven repo on my computer
how
@tender shard you told me to use install:install-file, what do i put as -Dpackaging?
-Dpackaging=jar
yea thanks
Where does fawe actually anchor a schematic when importing it via the api?
The to anchor that is supposed to define where the schematic is pasted into is set to the bottom left corner of the frame, but as you can tell that is not what is happening:
@tender shard
What is item supposed to be? @quaint bough
wdm?
No I'm just wondering how I would set the nbt data to the super class
I dont think it's possible
hello
i want to convert the minecraft yaw to angle degrees
my goal is to invert the angle
making something like
in degrees it would be just add 180° and it is done
but minecraft yaw is -180 -> 180
Extending ItemStack isn't going to work at all btw. CraftBukkit's implementation will be returning copies and clones of items, but it won't ever be your item
I know but still makes code more reusable for my items
Should really just make a util class or an item builder then
Extending most aspects of Bukkit is frowned upon
if you are talking about the javafx
you could add an action listener i guess
elaborate
btw help
Complex Data Storage Solution
?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.
humbling myself tonight
ight i have a question that is more just java but ima ask here anyways
so i have this code
coordinates = new double[11 + 20 * 2][];
int arrayLocation = 0;
for (double i = 0; i <= Math.PI; i += Math.PI / 20) {
double radius = Math.sin(i);
double y = Math.cos(i);
for (double a = 0; a < Math.PI * 2; a+= Math.PI / 20) {
double x = Math.cos(a) * radius;
double z = Math.sin(a) * radius;
coordinates[arrayLocation++] = new double[] { x, y, z };
}
}
but what ever i set new double[x][] to it throws an error
index x out of bounds of length x for the line with coordinates[arraylocation++]
i dont see what the issue is as it looks like it should work and it should add 1 less then the length to coordinates but dunno
if i wanted all hostile mobs to spawn with like 3x hp how would i get all the hostile mobs from the creature spawn event
I am currently getting an error for UnknownFormatConversionException when trying to use the setFormat method within the AsyncPlayerChatEvent. I've used a debug logger message and nothing looks out of the ordinary so I am not exactly sure why I would be receiving the error. I know about String.Format being needed, and it's what I have been following, but for some reason it is still not working.
The Error: https://paste.md-5.net/aropimaxoj.bash
The Code: https://paste.md-5.net/icokofivak.js
Debug Message: [14:59:36] [Async Chat Thread - #0/INFO]: [Stylizer] %s >> %s
Chat Format From Config: "%displayname% #14abc9>> #6b6b6b%message%"
I have tried using %1$s and %2$s as well as the generic %s but can't seem to find what is actually using the error. Any help would be appreciated as this error is annoying me
Easiest way is to just check if the entity extends Monster
I'm making a plugin that tracks how many deaths the player has. Can I reset my deaths so that I can test more easily?
oh thanks, that applies to all hostiles tho right
It should
ok thanks
I would double check on the gray-area mobs like zombie piglins
that sounds like itd be under monster
event.getEntity() instanceof Monster <-- that should work right
inside of my if statement
Hi ! I need the 1.6.4 spigot documentation som1 have a link pls ?
ping me if u respond
wtf...
1.6.4?
md_5 come here and help him
you probably still remember that version right
you the one who maintained the backward compat, you should remember it lol
probably not the issue but shouldnt those last two .replace's be %%displayname%% and %%message%%
in applyFormat
Doesn't resolve the issue sadly.
which one is at line 105
Move the 11+20… to the second []
basically we make a practice server for the players of a modded server but the founders of the modded server are big sons of bitch who bypass the eula with the 1.6.4 so we are obliged to make with this version to access our server with their launcher
Use statistics and you can reset / set your statistics to a value
declaration: package: org.bukkit, interface: OfflinePlayer
Wrong line, you're looking at the AsyncPlayerChatEvent class , check the line under that one, which is from my code 😛
Weird kk I’ll try it
The second one
what does defaultChatFormat equal
Chat Format From config, on my original post
Correct
if i wanted to increase the ender dragon health would i do that in the creaturespawn event or does the first ender dragon not count as being spawned
@EventHandler
public void onInvClick(InventoryCreativeEvent e) {
ItemStack item = e.getCurrentItem();
if (item != null && item.getItemMeta() != null && item.getItemMeta().getPersistentDataContainer().has(DistinguishableArmor.KEY, PersistentDataType.STRING)) {
e.setCancelled(true);
((Player) e.getWhoClicked()).updateInventory();
}
}
why the item duplicates
Creative actions are client authoritative.
try InventoryCreativeEvent#setCursor(ItemStack) with a null value.
its notnull
i tried null & air and its duping
1.17
how would i drop an item when an entity dies
i am getting yelled at for This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies.
do I just add something like
@Override
public void onDisable() {
this.getServer().getScheduler().cancelTasks(this);
}
```?
or is there a better way to cancel my async tasks
(saving my task id, then cancelling that only?)
Listen to the death event.
Get the entities World.
Call World#dropItem()
ty
Do your async tasks have deadlocks or infinite loops in them?
Nope
I tried to call event and I find two ways for this.
Bukkit.getPluginManager().callEvent();
Bukkit.getServer().getPluginManager().callEvent();```
What's the difference and which is more better(general) way? (because will use in Framework)
First one is from Paper and is just a convenience method to instantly check for cancelled events. No difference.
paper moment
Thanks
Event#callEvent()?
Bukkit.getPluginManager().callEvent(Event)
did I just read the messages out of context
Misread the question. Thought he meant Event#callEvent()
oh lol
is there any good way to check the inventory in interact event is a custom inventory created by myself?
Store your custom inventories in a Set and call contains on it
currently I do it either check title or keep a Set of inventory
https://minecraft.fandom.com/wiki/Heart_of_the_Sea
But this channel is for spigot development related questions
verify your spigot account
!verify
Usage: !verify <forums username>
how do I make commands like pluginname:commandname
This is just a more volatile way to execute a command where you specify the namespace together with the command key.
No need to specifically make this. If you register a command then you will automatically have this option to call it.
https://paste.md-5.net/ehenubukem.java does this seem correct? for detecting if it can rain on a certain block (line 40 specifically)
oh didn't know that
I think a temp of 0.15 is still included for rainstorms. But generally this checks out.
i remember another person had asked a while ago abt detecting weather type for a block and we didnt actually figure out what happened at 0.15 exactly
bc the wiki says <0.15 is snow, and >0.15 is rain, but =0.15 was.... undocumented
Your code flow is questionable btw...
Also: Dont read from configs on runtime. Read the entire config once when the server starts and call properly named variables.
questionable code flow? 
And you should probably use the thread bound random for lower contention and less overhead.
ThreadLocalRandom
One moment
Btw prevent magic numbers:
private static final int MAX_DIST = 128;
private static final int MAX_DIST_SQ = MAX_DIST * MAX_DIST;
...
if (this.distanceSqXZ(lightningLoc, playerLoc) > MAX_DIST_SQ) continue; // Player is greater than 128 blocks away
This way you just need to edit MAX_DIST instead of calculating a new sq distance every time.
And if someone reads the code he knows what that number means
i think i yoinked the 128 block think from like a wiki page or something so thats why its that
lol
it was like effective range of players to send a lightning strike or w/e
so improved readability yes but practicality of using the fields not so much
Those are not fields
last time i checked a public static final int MAX_DIST is a field
pretty sure not
I think you are right
what
i still understand where ur coming from with the readability concern btw, i just dont see why i should considering this plugin is just for an SMP that i run
so im not entirely throwing ur recommendation away
Btw wouldnt that ireration of players just strike one unfortunate player if multiple candidates are present?
If 3 players stood besides each other, with everyone having an iron sword in his hand, then one would tank all the lightning
as the order in that collection only changes when players leave/join.
this is giving me an error
perhaps
but the random in there should also kind of help mitigate that
since it (hopefully) wont always be a successful chance every time for the same player
I think this stack trace is as clear as it gets.
The return value of getNewEffect() is null
Ah overlooked that random
yeah that should be enough
And please stop reading values from a config during runtime already.
Read the entire config when the server starts and then use properly named variables.
ok
writing a config manager as speak
Another tiny bit of performance improvement:
private static final Set<Material> METTALICS = EnumSet.of(
Material.IRON_SWORD,
Material.GOLDEN_SWORD,
Material.NETHERITE_SWORD
);
...
private boolean isMetallic(ItemStack stack) {
return METTALICS.contains(stack.getType());
}
I think its a bit cleaner to just add values to a collection instead of having a 10 line boolean statement ^^
oh you shouldve saw my old biome check
Oh god...
private boolean isRainPossible(Biome biome) {
return !(biome == Biome.FROZEN_OCEAN
|| biome == Biome.FROZEN_RIVER
|| biome == Biome.DEEP_FROZEN_OCEAN
|| biome == Biome.ICE_SPIKES
|| biome == Biome.SNOWY_BEACH
|| biome == Biome.SNOWY_MOUNTAINS
|| biome == Biome.SNOWY_TAIGA
|| biome == Biome.SNOWY_TAIGA_HILLS
|| biome == Biome.SNOWY_TAIGA_MOUNTAINS
|| biome == Biome.SNOWY_TUNDRA);
}``` @lost matrix

maven hates me....
how can i use and shade a local lib that i made in a plugin for example
maven shade plugin?
the problem is that there are errors all the time
You need to use install on your other plugin. This compiles then packages then installs the dependency in your local maven repo.
After that you just use the maven shade plugin and shade in your dependencies (which dont have the scope "provided")
like this?
ok ty i will try it
something like that yeah
Sure. But from the formatting a can smell static. Try to not do that.
equals would be 100% more future save too
.equals on an enum? what do i look like? a hooligan?
How much is 5 seconds in the code Thread.sleep(int)?
5000
o.o
enum until now... it will change soon
Thread.sleep uses milliseconds
if its long yes
Okay, thank you! 😄
or i just check block temperature
like i do now
Let me stop you right there.
You will most probably crash your server with that.
Wait. Why?
any other way to add the mainClass to the manifest with maven then "maven-assembly-plugin" (which is also red but somehow still works)
Because im suspecting that you plan of freezing the main thread.
Why would you need a manifest for a plugin? You cant execute it anyways.
still shouldnt use Thread.sleep in server
It froze for 5 seconds...
Well. That was the first code I saw in the scheduling (or what), so I used that. 🥴
if u need a task to run after X time might i recommend using Bukkit tasks
?scheduling
😄 here comes the clue
i have 1 project for handling connections(socket - 1 server, multiple clients)
i want this to be the base for the dataarchieve for another project which needs to be implemented in a plugin and also to be executable
Thread.sleep actually works, but the player is actually frozen for like 7 seconds, and the TPS is down asf, so you guys were right. .-.
thread.sleep sleep the main thread
and minecraft depends entirely on it
so you sleep it = you sleep minecraft
iirc
Yeah.
Just reading the wiki, and I realised that "boring" texts are always useful.
c.c
Might be.... This the right code I need...?
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(plugin, () -> {
Bukkit.broadcastMessage("Mooooo!");
}, 20L * 30L /*<-- the delay */);
This delays the code
() -> {
Bukkit.broadcastMessage("Mooooo!");
}
For 30 Seconds
Hm.
This is good, but I still have an error. The plugin is unrecognized.
...as a variable..?
Yes you need to pass an instance of JavaPlugin. Just pass it via the constructor or create a static getter for a singleton instance.
No
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Ah ####
Why enchants not working on zombie i spawned?
z.getEquipment().setBoots(dia_boots, true);
z.getEquipment().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
Do I really need BlockBreakListener?
'cause breaking the blocks will be disabled in certain server types.
Wait...
This WIki shows that FancyLogger is a classfile, I may use, for like the join event, or the quit event, right?
What anti cheat?
well spigot has not rly anti-cheat ... just some fixes to make sure the server dont crash while player try to hack
That’s just vanilla
It keeps going back and forth, isn't it because of anti-cheating?
hello, i have entity (egg) how get itemstack display name?
I don’t think that’s stored when the item becomes an entity
"The server has not responded for 0 seconds" - wtf
and I don't know how to save it before throwing?
PersistentDataContainer
I don't think anticheats teleports you back where it teleported you from. It is probably the lag - most likely if you do not have an anti cheat installed.
And also: why is the anticheat detecting you, if you are the owner...?
thanks i try
Vanilla has a loved too quickly system
I think there is a way to up the threshold in on of the server configs
why does zombie when i give it sword do same damage as without it?
z.getEquipment().setItemInMainHand(dia_sword);
wrote a smal wrapper for config values, better? @lost matrix https://paste.md-5.net/upulazukef.java
reads config values on server start or manual config reload (via command in core plugin)
Interesting approach
But why is it public?
Wouldnt it make more sense to instantiate the entries in your config manager class?
private final ConfigurationEntry<Boolean> enableCutlasses;
private final ConfigurationEntry<Double> cutlassStrikeChance;
public WorldEventListener(SmpCore plugin) {
super(plugin);
this.enableCutlasses = plugin.configurationManager.<Boolean>getOrCreate("world.cutlasses.can-strike");
this.cutlassStrikeChance = plugin.configurationManager.<Double>getOrCreate("world.cutlasses.strike-chance");
}
didnt feel like doin something like boolean enableCutlasses = plugin.getConfig().getBoolean(/**yeah**/);
l i sten
its 6 am
ill rework it later
bc i might actually use this approach in other plugins so ill have to work on it anyway
How about sleeping
in a bit
programmers dont sleep
we get ideas and then we need to make them before we forget
yesh
this system also wouldve been absolutely horrid since i have a command to reload config in game
so id have to make a method in the listener called like
Just read from the YamlConfiguration each time
public class LightningStrikeConfiguration {
private final FileConfiguration configuration;
@Getter
private boolean lightingStrikingEnabled;
@Getter
private int maxDistance;
public LightningStrikeConfiguration(FileConfiguration configuration) {
this.configuration = configuration;
reload();
}
public void reload() {
this.lightingStrikingEnabled = configuration.getBoolean("some.path.to.stuff");
this.maxDistance = configuration.getInt("some.other.path.stuff");
}
}
Wait that wouldnt work as you need a new instance of FileConfiguration
public class LightningStrikeConfiguration {
private final Supplier<FileConfiguration> configSupplier;
@Getter
private boolean lightingStrikingEnabled;
@Getter
private int maxDistance;
public LightningStrikeConfiguration(Supplier<FileConfiguration> configSupplier) {
this.configSupplier = configSupplier;
reload();
}
public void reload() {
FileConfiguration configuration = configSupplier.get();
this.lightingStrikingEnabled = configuration.getBoolean("some.path.to.stuff");
this.maxDistance = configuration.getInt("some.other.path.stuff");
}
}
When the lom is bok
gona slep so im not completely dreading irl job later
will work on configurator after work
gud nite 

go sleep
eventually
sleeping is for losers 
i wish
im trying to write my own code to just move to the next day if 50% of people are sleeping. does this look correct?
public class SleepListener {
private int sleeping = 0;
@EventHandler
public void onSleep(org.bukkit.event.player.PlayerBedEnterEvent event) {
if (event.getBedEnterResult() == BedEnterResult.OK) {
sleeping++;
if (sleeping > event.getPlayer().getServer().getOnlinePlayers().size() / 2.0) {
event.getPlayer().getWorld().setTime(0);
}
}
}
@EventHandler
public void onWake(org.bukkit.event.player.PlayerBedLeaveEvent event) {
sleeping--;
}
}
I'm not sure if theres some smoother/better way to transition to day, other than just jumping the time to 0
There is a simple game rule for that
wait really???
if ur on 1.17+ use gamerule yeah
org.bukkit.event.player.PlayerBedEnterEvent nice
playersSleepingPercentage
omg idk how that got there 😓
i swear i imported it
is there anyway to register events without duplicating the same stuff]over and over
Define "duplicating the same stuff"
?jd for self
getServer().getPluginManager().registerEvents(new listener, this);
getServer().getPluginManager().registerEvents(new listener, this);
getServer().getPluginManager().registerEvents(new listener, this);
getServer().getPluginManager().registerEvents(new listener, this);
getServer().getPluginManager().registerEvents(new listener, this);
getServer().getPluginManager().registerEvents(new listener, this);
getServer().getPluginManager().registerEvents(new listener, this);
u could do a for loop
abstraction
how?
like let your listener classes extend a base class and let the base class register them all
i was thinking a literal reregister of the same listener for some reason but yeah what 14 said
idk why tho
Wut? You would still need instances of each class.
yea..
One "improvment" could be
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new Listener(), this);
pluginManager.registerEvents(new Listener(), this);
pluginManager.registerEvents(new Listener(), this);
i gues
hi, can someone explain to me why when i spawn new zombie with diamond sword it deals same damage as without it
z.getEquipment().setItemInMainHand(dia_sword);
what are you talking about?
wtf :(
new ListenerClass(this)
same for other modules :(
so there isno way?
kekw
smh wheres the DI
they were using singleton most of the time
public abstract class SelfRegisteringListener implements Listener {
public SomeListener(JavaPlugin plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
}
🤔
thats what im taking abt
public class SomeListener extends SelfRegisteringListener {
public SomeListener(JavaPlugin plugin) {
super(plugin);
}
@EventHandler
public void doStuff(BlockBreakEvent event) {
}
}
@Override
public void onEnable() {
new SomeListener(this);
}
i dont see any profit with doing this
Me neither
implements Listener :)
how to spigot:
- ???
- profit
nvm
ok i go bed
"hello spigot" 🥺 🥺
Thats not how you should use constructors. Prone to really nasty ClassLoader exceptions if anything happens in your constructor.
Maybe something like:
public interface PluginModule {
void enable();
void disable();
}
private final List<PluginModule> moduleList = new ArrayList<>();
@Override
public void onEnable() {
// Add modules in order here
enableModules();
}
@Override
public void onDisable() {
disableModules();
}
private void enableModules() {
moduleList.forEach(PluginModule::enable);
}
private void disableModules() {
Collections.reverse(moduleList);
moduleList.forEach(PluginModule::disable);
Collections.reverse(moduleList);
}
Oké, so the loader (main) class has the code logger = new LobbyJoinEvent(this); when registering the lobby classes, and it also has the...
public LobbyJoinEvent getFancyLogger() {
return logger;
}
``` ...code too. Now, my problem is that LobbyJoinEvent is actually... not loaded. What could destroy the process of loading the class (there are no errors against LobbyJoinEvent.java)?
why reversing 
Makes no sense. More code pls.
for module compatibility?
Because thats how you prevent dependency clashes
(some parts of the LobbyJoinEvent)
private final JavaPlugin plugin;
public LobbyJoinEvent(JavaPlugin plugin) {
this.plugin = plugin;
}
(the part that needs the "logger")
sch.runTaskLater(plugin, () -> {
if(player.isOp()) {
player.sendMessage("§4§lFIGYELMEZTETÉS §8| §7Operátor jogosultságokkal rendelkezel!");
player.sendTitle("§4§lFIGYELMEZTETÉS!", "§7Operátor jogsultságokkal rendelkezel!", 5, 100, 5);
player.playSound(player.getLocation(), Sound.BLOCK_BELL_USE, 1000, 0);
}
}, 200L);
A better way would be to maintain a Map<Class<? extends PluginModule>, PluginModule> with an abstract
interface method List<Class<? extends PluginModule>> getDependencies() and then use some graph algorithm
to find out the perfect load/unload order. Similar to how Spigot does its load order.
Or just define them manually ^^
Then just call plugin.getLogger() in there
(the code down below gives a warning to the player that they have OP, which is not allowed)
You mean like this?
public LobbyJoinEvent(JavaPlugin plugin) {
this.plugin = plugin.getLogger();
}
plugin cant be a logger ^^
Da
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.
plugin is your JavaPlugin.
And JavaPlugin has a method called getLogger()
that returns a Logger.
So just call that method where you need the logger...
🤔
OK. This article/wiki (https://www.spigotmc.org/wiki/using-dependency-injection/) makes no sense to me. How the #### does this even lets me use the plugin in the code of
sch.runTaskLater(plugin, () -> {
if(player.isOp()) {
player.sendMessage("§4§lFIGYELMEZTETÉS §8| §7Operátor jogosultságokkal rendelkezel!");
player.sendTitle("§4§lFIGYELMEZTETÉS!", "§7Operátor jogsultságokkal rendelkezel!", 5, 100, 5);
player.playSound(player.getLocation(), Sound.BLOCK_BELL_USE, 1000, 0);
}
}, 200L);
``` if it just breaks the whole ###### class?!
Show your whole class pls.
Those are absolute basics of Java btw.
Developing plugins without understanding the basics
will just handicap you.,
You are not the first to think that up. There is a library out there that does exactly that.
hmm
ill probably still take a grab at it myself since im stubborn and like to DIY everything
The class just manages the events of a player, when they join the actual server, like set their HP to 20, send them a message, and after 10 seconds it should warn the player if they have OP - because it is disabled on the server.
Im at the point where i just write a class and let Jackson generate me yml files from it.
@Data
@JsonRootName(value = "Configuration")
public class BaseConfiguration {
@JsonProperty("MaxMillisecondsPerTick")
private double maxMillisecondsPerTick = 15.5;
@JsonProperty("MachineSettings")
private MachineSettings machineSettings = new MachineSettings();
@JsonProperty("MessageFormatting")
private MessageFormatInformation formatInformation = new MessageFormatInformation();
@JsonProperty("TranslatedEntityNames")
private TranslatedEntityNames entityNames = new TranslatedEntityNames();
@JsonProperty("FirePlayerEventsForMachines")
private boolean fireEventsForMachines = true;
}
public class MachineSettings {
@JsonMerge
@JsonProperty("TriggerIntervals")
private final Map<BaseMachineType, Integer> triggerIntervals = Arrays
.stream(BaseMachineType.values())
.collect(Collectors.toMap(Function.identity(), BaseMachineType::getBaseMachineInterval));
public int getTriggerInterval(final BaseMachineType baseMachineType) {
return this.triggerIntervals.getOrDefault(baseMachineType, 20);
}
}
However, as I was following the wiki someone sent to me, it just made me break the class
Everything else works, but not the join events
And this all makes no sense, because the IDE shows no absolute errors.
And this is what I hate
?paste
Just paste your two classes pls
You mean the main and the join event?
Hey! i have been doing some code but i got stuck, how can i do to delete Player player from these methods?
public static void createNPC(Player player, String name, String skin) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) Bukkit.getWorld(LocationsFile.getConfig().getString(name + ".world"))).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.translateAlternateColorCodes('&', name));
EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
npc.setLocation(LocationsFile.getConfig().getDouble(name + ".x"), LocationsFile.getConfig().getDouble(name + ".y"),
LocationsFile.getConfig().getDouble(name + ".z"), LocationsFile.getConfig().getInt(name + ".yaw"),
LocationsFile.getConfig().getInt(name + ".pitch"));
String[] name1 = getSkin(player, skin);
gameProfile.getProperties().put("textures", new Property("textures", name1[0], name1[1]));
addNPCPacket(npc);
NPC.add(npc);
}```
private static String[] getSkin(Player player, String name) {
try {
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
InputStreamReader reader = new InputStreamReader(url.openStream());
String uuid = new JsonParser().parse(reader).getAsJsonObject().get("id").getAsString();
URL url1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid
+ "?unsigned=false");
InputStreamReader reader1 = new InputStreamReader(url1.openStream());
JsonObject property = new JsonParser().parse(reader1).getAsJsonObject().get("properties")
.getAsJsonArray().get(0).getAsJsonObject();
String texture = property.get("value").getAsString();
String signature = property.get("signature").getAsString();
return new String[] { texture, signature };
} catch (Exception e){
EntityPlayer p = ((CraftPlayer) player).getHandle();
GameProfile profile = p.getProfile();
Property property = profile.getProperties().get("textures").iterator().next();
String texture = property.getValue();
String signature = property.getSignature();
return new String[] { texture, signature };
}
}```
'cause main is full of most likely codes you may see weird - which I really do not mind about 😹 -.
uhm yea..
i need to delete Player player but don't find a way
delete player?
The first method doesnt use the player variable at all. Just remove it. createNPC(String name, String skin)
that looks like codedred's code
it does
String[] name1 = getSkin(player, skin);
yea, but i'm changing it a bit
Ah i see. Then replace with createNPC(String texture, String signature, String name, String skin)
String[] name1 = new String[]{texture, signature};
should i encrypt player data
what player data lol
GameProfile probably
Do you want the npc to have skins?
hi, can someone explain to me why zombie doesnt give more damage with diamond sword in his main hand?
z.getEquipment().setItemInMainHand(dia_sword);
Then how do you want to obtain the skin without a player?
it does a web request to the profile server or how its called
yea
there is a nice website where you can create your own skins and the website gives your value+signature ^^
pls do that async
will PlayerResourcePackStatusEvent get triggered even if the server sets the resource pack from server.props?
Then simply remove the Player from the getSkin() method.
Its only used for exception handling in there.
@acoustic pendant
I want a way to detect the resource pack of a player/when the server applies the resourcepack
hmm
Yes
try and see
@lost matrixhttps://paste.md-5.net/tovohozoxu.cs https://paste.md-5.net/uxolovoxum.java
idk why is the main a cs
xD
so i have to return steve texture and signature?
yea but i have to return a string
No you dont
you need to return a String[]
just this?
you just check if the player entered a name and then apply a texture, otherwise dont?
new String[0]
private static String[] getSkin(String name) {
try {
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
InputStreamReader reader = new InputStreamReader(url.openStream());
String uuid = new JsonParser().parse(reader).getAsJsonObject().get("id").getAsString();
URL url1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid
+ "?unsigned=false");
InputStreamReader reader1 = new InputStreamReader(url1.openStream());
JsonObject property = new JsonParser().parse(reader1).getAsJsonObject().get("properties")
.getAsJsonArray().get(0).getAsJsonObject();
String texture = property.get("value").getAsString();
String signature = property.get("signature").getAsString();
return new String[] { texture, signature };
} catch (Exception e){
e.printStackTrace();
return null;
}
}
is null valid for a String[]?
null is valid for everything unless its a primitive
Read the code. Its pretty clear what happens then
oh didnt know it worked on arrays tho
well
https://www.spigotmc.org/wiki/using-dependency-injection/ - wait, why the hell would I need to log a playerjoin event, if it already logged by the server itself...? 🤨
You tell me?
its an example smh
oh 😳
yo i need help with opening a book to a player
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
if (event.getInventory().getName().equals("Updates")) {
event.setCancelled(true);
if (event.getCurrentItem() == null) {
return;
}
if (event.getCurrentItem().getType() == Material.BOOK) {
return;
}
if (event.getCurrentItem().getItemMeta().getDisplayName().equals("§a§lUpdates")) {
ItemStack book = createBook();
//open book
}
}
}```
Packets are my best guess, unless spigot has method to do so
[20:40:52] [Server thread/WARN]: handleDisconnection() called twice
What's wrong?
People say that you should store custom enchantments in the PDC, however why is that the case if Bukkit already stores this info if I were to extend the Enchantment class? Is there some catch with just using latter (outside of the enchantment not showing on the user's side)
iirc itemstack#hasEnchantment(customenchantment) can fail after reload or smth like this
I didn't even know you could do that but i'd rather handle enchantments on my own
also anvil and stuff like that dont use custom enchantments automatically
I already do that but sadly bukkit is an absolute prick and does not correctly merge stuff in the anvil, so I hoped that by overriding the Enchantment class I would get better results there
Within spigot it absolutely refuses to merge items, under paper it is a bit better but there are still a few edge cases. And I know that it is not my code because I already spent dozens of hours of debugging over the span of almost two years only to come to the same conclusion each and every time
I kinda hate anvils
I couldn't agree more
i kinda made it work with anvils and eventtriggering.... but it was pain
Why my plugin doesnt want to load?
heres code:
import me.karlo292.luckyblock.listeners.onBlockBreak;
import me.karlo292.luckyblock.listeners.onCustomMobDeath;
import org.bukkit.plugin.java.JavaPlugin;
public final class LuckyBlock extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("STARTING PLUGIN!!!!!!!!!!!!!!!!!!");
getServer().getPluginManager().registerEvents(new onBlockBreak(), this);
getServer().getPluginManager().registerEvents(new onCustomMobDeath(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
what is your log showing ?
// Plugin startup logic heheee
[14:21:22 ERROR]: Ambiguous plugin name `LuckyBlock' for files `plugins\original-LuckyBlock-1.0-SNAPSHOT.jar' and `plugins\LuckyBlock-1.0-SNAPSHOT.jar' in `plugins' [14:21:22 ERROR]: Could not load 'plugins\original-LuckyBlock-1.0-SNAPSHOT.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/karlo292/luckyblock/LuckyBlock has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 60.0
the problem is the java version you use ^^
Java 16 > Java 17
ok
idk man the error message seems really self-explanatory
safest bet is to use 1.8 compile source
yo i need help with the inventory on click event
it doesnt trigger
here are few things you might have missed:
- not registering the listener
- not adding
@EventHandlerannotation to the method - you are listening to the wrong event
- the event you are listening for has no handler
You can't listen to abstract events
ok i fixed it ty
ah in that way
has anyone used the MCPLuGINDEBUG plugin for IntelliJ? It says I dont have the latest java while I do
hey i need help again with opening a book
try {
player.getClass().getMethod("openBook", ItemStack.class).invoke(player, book);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
player.getServer().getLogger().info(e.toString());
}
i have tried this and it doesnt work (like everything else)
already tried packets?
what error?
isnt this something?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#openBook(org.bukkit.inventory.ItemStack)
declaration: package: org.bukkit.entity, interface: Player
nope
which event is fired when a player right clicks an item frame?
PlayerInteractAtEntityEvent
maybe ^^
the interact event 🌛
why useless O.o
prob not useless but it gets fired for a various amount of reasons
and it wont get change since it will always stick to support ancient versions too
are there multiple Player interfaces for versions?
nope
wym
well the 1.15 api has the openBook method for a player
so?
and @shell prism cant find that method
I very much believe it still exists as of today
the interface only adds stuff and never removes stuff
the 1.14 one doesnt have the method
well then its clear that in some snapshot version in 1.15 ::openBook was added
as freesoccerhdx said, spigot scarcely remove methods
but I mean 1.15 sounds quite old
3 years old iirc
fixed
in which way is the clicker of an inventory not a player?
i think thats Bukkit claiming its a HumanEntity
which is annoying
i always just cast it 💀
in my experience a humanentity is always a player
until now its always a player
i think its just bukkit being dumb lol
but maybe someday it will be used somewhere else
i have never had an issue just casting the clicker to player lulz
then my check is useless
well, good practice yadda yadda 🤣
yeah... because nothing else exist that has HumanEntity ... its just good prepared
also plugins could do weird stuff with the HumanEntity class
any way to automatically parse an string to the primitive array ?
Install Java 16 at https://adoptopenjdk.net/?variant=openjdk16&jvmVariant=hotspot
17
Install Java 17 at https://adoptium.net/?variant=openjdk17&jvmVariant=hotspot
i never have to mess around with java versions 🙄
oh ok
just buy a server ^^
?
To char[] yes
Wtf is with that ignored closing bracket
Anyways copy and paste
Is there a list of images somewhere that shows every single particle and its ID
no i want to have for example '["123","123","123","132"]' (its a string)
to its representative int-array or long-array what ever
No
wha-
Just do manually
i already have done that ... just tryd to save time
what's the github action for mvn clean package
run: mvn clean package?
github
Do you know plugins for auto-ranking?
nope
unless you can host said local dependencies you won’t be able to use github actions
hmmmm
is there any way to make it run on someone's machine before they push?
or, when they push it runs mvn clean package
what are you even trying to do
alright so we have local dependencies, but i still want to upload the latest artifact
using upload-artifact
to what
can’t you just use github releases
the repo is private
is that an issue
uh yeah
so what we need to do
well i actually meant nightly.link because it needs to link the latest commit and i dont wanna have to publish every time
why do you need these jars on github
because unless you can host these local dependencies then you’re gonna have to have a ci server of your own
because they juist need to be included with every commit
Does anyone know why the NPC isn't spawned in?
Code: https://paste.md-5.net/ebimibupim.java
so there is no way to run commands on someone's machine before they push?
or yk what
i think its better they do it themself
bc what if you push something that you dont want to be downloaded immediately
i don’t think you’re understand what you’re asking here
can you have two gameprofiles with the same uuid?
on the same server
I don't know
no
So that's why
use UUID.randomUUID() then
How can I change the skin so it's using the same skin?
web request to mojang server to get some properties
i heard people talking about another site
?
It's more complicated than I thought xd
Learn how to change an npc's skin through connecting to the mojang website and using game profile!
WEBSITE CODE:
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
URL url2 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid
+ "?unsigned=false");
Patreon:
https://www.patreon.com/code...
this kinda explains it
codedred is bad but yea
what are you trying to achieve
you are trying to have github build your maven project and create a release with that on every push?
no im gonna upload the artifact and then link it
actions/upload-artifact?
no im not
im creating something that needs to be downloaded with a link and no more
^
Also If the server is offline mode and player is using non-registered name, it will not found any skin right?
nvm
what is offline mode again?
cracked or whatever
maybe just create a separate repo
Can I get the GameProfile of the Player and get the skin textures and signatures from there?
that you can join with hacked clients?
offline mode means you tell mojang to not check on your players on log in
ah
then it will not find a gameprofile on the mojang server
they are hacked
but who uses offline mode 🙄
Lots of people xd
I think getting the skin from the GameProfile is doable right?
Instead using a web request
doesnt the player has to be online for that?
In my case the player will be online to do this
yes they are
and textures ALSO need a valid signature
there's no way to change a player's texture to a random one without having it signed from mojang servers
Do you know plugins for auto-ranking?
so you will need to do a web request to the server?
I didn't read what you actually trying to do, please repeat
i think it is possible to reuse the game profile from the player
I'm trying to change the skin of an NPC.
you CAN change player's textures, but: it requires you to once upload the skin to a real MC account, then you can grab the signature from there
well basically I could just upload any skin, then log into the game and save my GameProfiles "textures" and "signature" property
now you can reuse that as often as you want
I'm struggling to get that property.
oh that's easy
one second
here's my method to get the texture of a skullmeta, which contains a gameprofile
Oh I think I got it.
@Nullable
public static String getBase64Texture(@NotNull final SkullMeta skullMeta) {
try {
final Field profileField = skullMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
final GameProfile profile = (GameProfile) profileField.get(skullMeta);
return profile.getProperties().get("textures").stream().findFirst().get().getValue();
} catch (final Throwable t) {
return null;
}
}
of course you can do the same thing to set the value instead of just getting it, and do the same for "signature" instead of "textures"
why do you need to upload the skin to a real mc acc?
to get a valid signature for that skin
aaah
there are APIs that do that for you IIRC
so thats why you need a player
yeah seems like only mojang knows how their "signature" code works
I don't know If it's correct or not. https://paste.md-5.net/ovireqofas.nginx
unless someone cracks it, people will have to upload it
that looks correct
just try it 🙂
mineskin.org automatically gets you a signature for any skins you upload
helo
im having some problem in plugin
i mean i made a plugin but it works only one time
errors?
Do you need other than that to change NPC's skin?
it works when i upload it and when server closes and starts again the plugin jar becomes 1 kb and throws this error
[20:14:16 ERROR]: Could not load 'plugins\icecube.jar' in folder 'plugins' org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:158) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:422) ~[paper-1.18.1.jar:git-Paper-152] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:285) ~[paper-1.18.1.jar:git-Paper-152] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[paper-1.18.1.jar:git-Paper-152] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-152] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml ... 7 more
idk are you sure its in the resources?
hello how can I set max durability of some tool to 1?
and it is valid syntax?
yes, u mean in the src folder?
plugin.yml is in the src folder
i googled things but nothing worked
the jar was of 11kb when i placed it in plugins folder,
after i stopped server it became only 1 kb
and when i kill the server without stop cmd it remains same
yes
its short
main: xyz.squeek.icecubesmp.main
name: icecube
version: 1.0.1
commands:
suicide:
description: Suicide
usage: /suicide
bedrock:
description: test one
usage: /bedrock
linkdsc:
description: test two
usage: /linkdsc
It's optional
so , maybe its papermc currupting the jar?
well its a filenotfound so i assume its not there
Maybe wrong path
very confusing, it was fine at first start
Can you show us the folder structure?
Oh, you need to be verified first to upload an image
sed
Just use imgur or something
You're putting it inside the xyz.squeek.icecubesmp package, it should be outside that I think.
i see no resources folder
where can i find the list of items in a specific creative mode tab, i am trying to pick X amount of items from a specific creative mode tab
what
Like picking 5 items from the Building Blocks tab
there isnt
it's client sided..
