#help-development
1 messages · Page 1804 of 1
but there definitely is a way in NMS
let's wait until someone replies who knows it
has to be done each time you load the world
I was looking aswell, but I cant seem to find anything useful past EntityDeathEvent
since md_5 is currently here, maybe he knows 😄
what exactly do you mean
getting an entities loottable
By the type alone preferably
ah
so you don't even have an entity?
you just want to get the "generic" loottable e.g. for ANY creeper, for example?
Yes, I do/can get it
yes
LootTables.XXXXX.getLootTable()
pog
:O
API 😉
same, thaught I'd needed to create a function similar to that what would be in the NMS
sick
yeah md you gotta understand that most of the entity stuff is not inside the API so people don't even try to look there 😄
I didnt even know spigot has any API for loot tables 😄
awesome
I didnt even consider the posiblity of an outside class for the loottable, rather expected it in EntityType or Entity
is there any better way to get a gameprofiles texture than this?
Field profileField;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
GameProfile profile = (GameProfile) profileField.get(headMeta);
String texture = profile.getProperties().get("textures").stream().findFirst().get().getValue();
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
exception.printStackTrace();
}
Well type is preferable in my situation rather than the mob itself
its being worked on
It’s nice that a new API for heads is finally being worked on
I think we owe thanks to choco for that one
its not him doing it
then you need more WorldCreator-Settings (Environment + GeneratorSettings)
I'd love to contribute sth to the API too one day
but I fear I'm not good enough for that rn lol
is there a planned release of the new WorldCreator-Settings (Environment + GeneratorSettings) ?
Ah, I thought it was
its your PR, which is pretty complicated
not complicated enought maybe
The bigger the PR the longer it takes to review
its just ... maybe 1500 lines of code or smth like this 😅
That’s quite a bit
you can check them out too
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/685/overview
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/969/overview
more feedback means faster&better implementation i guess
does anyone remember the name of the person with whom I talked to about allatori yesterday?
in a pom.xml moving output jars ?
hugh? no
I sent a .jar for someone to deobfuscate
and they wrote a small app in kotlin
you sended me something about allatori in a pom but dont think you mean this
yeah ... no
ah yes I remember, but no I'm not talking about that
hey there
I'm getting weird errors trying to run BuildTools: Failed to execute goal net.md-5:specialsource-maven-plugin:1.2.3:remap (remap-members) on project spigot: Error creating remapped jar: Could not find artifact org.spigotmc:minecraft-server:csrg:maps-spigot-members:1.18-R0.1-SNAPSHOT in minecraft-libraries (https://libraries.minecraft.net/)
does anybody has an idea?
(also it seems weird that buildtools seeks for a spigot file on a mojang website 🤔)
what command did you enter to run buildtools?
java -jar BuildTools.jar --rev 1.18 --generate-docs --remapped
looks fine to me
oh wait
yeah, that's a pretty weird error
I ran the same version of buildtools with the same command yesterday and it worked...
I just ran that command and I also get an error from it
lmao
I'm trying without docs and remapped
lmao indeed it also doesn't work for me now without --generate-docs
it used to work fine a few hours ago
does anyone know how i can send the PacketPlayOutGameStateChange, 5 and 0 nms packet to the player (demo screen)
@last temple
where is the problem
@sullen marlin sorry again for pinging but what's up with buildtools? it used to work fine
There’s an API method to show the demo screen
there is an API for this: Player#showDemoScreen()
Sup
BuildTools does not work either with no parameters at all, same error
what version was that added in
1.18
pretty recently, let me check
yeah i'm on 1.8.8 lol
yeah, 1.18
that was a long time ago ... is it because of the pvp ?
RIP
Too old! (Click the link to get the exact time)
shut up
One day we’ll be allowed to just kick all the 1.8 people :p
would be better if they just write the version they want to code stuff.... in 6 years so many thing got changed or added 😅
I stopped supporting 1.8 like 3 years ago lol
I don’t think this discord has ever supported it
Hell I’m pretty sure 1.8 is older than discord itself :p
yesterday someone wrote he uses 1.8 because of pvp .-.
😄
Or at least close
discord: 13. Mai 2015
1.8 pvp sucks smh
yeah but nobody used it back then
also I dont get all the "1.8 pvp is better" thing
but its already close enought 😄
Skype bro!
like.... what's worse in 1.9+?
1.19
yeah sorry typo
Is good
why is it bad?
you can disable the hit cooldown ...
some people just don't want to accept the change
Makes game less device dependent
keep spamming leftclick is better than having to actually time your hit?
the timings makes pvp much more technical, combos became much harder and variative
It also means I can compete against the people with 20 cps
yes, they can keep using Windows XP and MC 1.8 if they like. Most people however prefer to be up to date
exactly. and that's good
imho
the last part isnt really true tho
Fuck shields though
@peak granite it isn't about Pvp
That most people prefer to be up to date?
It's about software age
That is very true
And bugs
yeah ig it's time to switch
If you like old PvP install OCM
well being "up to date" of course depends
a really large amount of people stay in 1.8 because of pvp
We have trillion of plugins for that
of course it's a massive pain to use or support 1.8
BStats would disagree
indeed. 1.8 API sucks
that works trashy but
Try latest ocm
what's ocm?
Removing the hit cooldown works flawlessly
Old combat mechanics
Not sure about the other stuff
that is called loud minority
It even has old knockback
ah thx @onyx fjord
i will try
I'm new to hosting servers so I don't know all the plugins lol
lmfao
Oh you’re a server host? Name every plugin
either 1.8 pvp or 1.9 pvp but not the mess that 1.8 pvp on non-legacy plugins create
Alphabetically?
Sure
What about Among Us x????
eh forget about it
Ban them
the dream
Dream stan banner
when mc 2.0??
?eta
There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
Can I check for the item when a player interacts with my custom ItemStack like: if (event.getItem().equals(myItem)) {
??
@peak granite Lets move to #general
no
It is already here!!
https://minecraft.fandom.com/ru/wiki/2.0
2.0 was fun
Use isSimilar
What’s the difference?
Use the pdc to identity your custom items
every plugin I'm running?
Well yes preferably this
depends on the server. most servers don't have ANY plugins installed
isSimilar ignores stack size
No no, every plugin
does isSimilar ignore durability too?
Why should I use PDC if isSimilar works fine?
No
because it would not work fine if player will break or rename your item
Or enchant
and the pdc is faster. You dont have to compare the entire itemstacks, just check if it has a single tag.
Gotcha 👍🏻
Ok thanks
thx
Those are only the ones you use :p
true but I won't scan my clients files lol
Real owners can name every single plugin on spigotmc
btw is LeGuernic still alive?
a few months ago, someone messages me, claiming there's a LeGuernic dude on spigotmc who stole his identity / real life picture etc
and I was like " yeah of course I know LeGuernic. It's the dude who always claims he's the very famous 1.4.6 dev bla bla" lmao
leguernic is a legend troll
but he didnt answer in months, maybe he's dead or sth
bold
Basically did a fresh install of my pc yesterday when i installed a new NVMe
Now with a fresh install of IntelliJ it feels so clunky?
Whenever i click once, it select 20 million freaking lines
and then its not finding any classes i create either... even after a restart/invalidating caches
And these classes have public access
strange
Have you tried uninstalling using the Intellij Idea tool?
is there any way to delay code execution without plugin instance
i know i can use something like SingleThreadDelayExecutor
I havent i think thats my next step from here
but it feels overkill for one lambda expression
Whats the issue with having a plugin instance?
Just create a static instance like i did in mine
i don't have plugin instance
start a thread and sleep?
you know what
Just sleep the main thread
yeah
:D
^
give it a low priority also
1000iq
is there a way to stop thread lock?
You’d be surprised how many still do that
dead lock?
or like thread lock as just a lock?
Use reentrant locks
well java has some interruption mechanics for awaits
I have been testing my socket library and my problem is that when a connection its received the new thread (the one who handle the connection) get locked and the data stream never open
But why cant you use a plugin, dovidas?
for only one line of code
i need to delay packet and packet future listener still executes too fast
Or accept that you need a plugin instance
Fine, I was using CraftScheduler's scheduleInternalTask method but that's cursed
im using it for different purpose
you could probably use thread pool tho
^
why do people do this
I dont understand
the scoreboard API has been a complete replacement of packets forever
high chance of creating a thread internally
not necessarily
yea you can provide your own executor
it has an executor which creates a new thread per runnable if the parallelism of the common pool is below 2
so what are you saying to me to do
or if it was 1 iirc
Will scoreboard api support text components???
Is there a page that talk about client server connection packets?
I mean r u sure you only it temporary?
else a single threaded scheduled executor service could suit you
What would components even do for a scoreboard
if only temporary, just prepare a thread should be fine?
Because i have done a program for fake player proxy connection but i dont know how to connect them to a specific server
i've preconstructed packets inside the class instance
you can optimize the thread a bit if you want to by daemonizing it, lowering its priority etc
wdym by temporary
for a short amount of time merely
the task
any idea?
tick isnt enough
2 ticks
i tried it
5 ticks
Cached thread pool + single threaded scheduled executor maybe?
or (possibly a fork join pool instead of a cached one if you know the blocking coefficient)
man im too dumb yet to do complex concurrency
Just send it after 5 ticks
Then just get a plugin instance?
Right
let me just provide you with a cool example then
😎
Dont complicate your self. Get the plugin instance by doing:
MainClass plugin = JavaPlugin()#getManager()#getPlugin(plugin name)
Ew
I really want to make it encapsulated. My class is the subtype of abstract class which doesnt use JavaPlugin instance at all
Just use JavaPlugin#getPlugin
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {}, 5L);
What i have say before. BTW
Just pass Plugin in constructor
That’s also an option
If you need to schedule stuff, you need plugin as well
I mean you don’t, but it’s the easiest way
And what does it have to do with encapsulation
I'm creating instances of classes via factory method
Ok
Maybe you shouldnt schedule tasks from those instances if you want to keep them independent??? Single Responsibility principe and bla bla bla
Just pass the plugin in your factory
it really works without plugin instance its just that the fucking client doesnt catch up with the server that fast
so annoying
I'm currently setting the PlayerInfo packet for an NPC and removing it after the entity has spawned, since it would hide the NPC from the tablist
problem is that Client removes the playerinfo packet first then renders the player skin
so i need some sort of delay to compensate that
runTaskLater
ExecutorService executor = Executors.newCachedThreadPool(
new ThreadPoolBuilder()
.setDaemon(true)
.build()
);
ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(
1,
new ThreadPoolBuilder()
.setDaemon(true)
.build()
);
scheduler.setRemoveOnCancelPolicy(true);
void execute(Runnable runnable,Duration delay) {
scheduler.schedule(() -> executor.execute(runnable),delay.toMillis(),TimeUnit.MILLISECONDS);
}
could do smtng similar with executor but with ScheduledThreadPoolExecutor::scheduledAtFixedRate iirc
was some time since I touched java's concurrency stuff
but that should give u a hint
I've previously used connection.a(#Packet<?> packet, #GenericFutureListener<> listener) to delay the packet but still its not enough
runTaskLater
runTaskLater
pass plugin in the constructor
pass plugin in the constructor
im gonna try this
thanks
👍
also
might wanna terminate the executors in onDisable
(altho they're daemon)
but to make sure no new tasks can be submitted
JUST
USE
THE
BUKKIT
SCHEDULER
or well ExecutorService::shutdown (to be specific)
I WILL NOT CREATE NEW SEPARATE METHOD DOING THE SAME WHICH WORKS FINE FOR JUST ONE LINE OF CODE
BUT INSTEAD A CUSTOM EXECUTOR WHICH ALSO HAVE TO MAINTAIN?
When in doubt, over complicate
its called the common pool to be picky
but yeah
great pool
altho heavily abused in the spigot community
🤢
((CraftScheduler)Bukkit.getScheduler()).scheduleInternalTask(() -> connection.sendPacket(this.infoRemovePacket), 5, "npc-tablist-task");
doing this rn
but this is not ok
eh
maybe i should change this
IDK
Today or Tomorrow
this will still be removed someday
That’s what they all say :p
😄
From Season 7 episode 23: Much Apu About Nothing
and only a single plugin instance will save you from all this shit...
you do realise that it does break the whole polymorphism of my class? I need to add useless plugin instance to the class interface which wouldnt be used apart of this implementation since other handler class uses interface to handle that class externally too
1/4 of classes would use JavaPlugin instance
and only just for this
how to rotate entity while sitting on it?
idk if there's a method for it in the api
sounds like rotation to me
ok
Sounds like a variation of a very old insult.
wdym?
Hello, is there any existing list of DeclaredFields for HumanEntity at the version of 1.17?
?xy
Asking about your attempted solution rather than your actual problem
oh nice I didn't know we had a xy command
uffff help i only wnt to know the DeclerationField for permissions and here are so many people, one of these know that please XD
?xy
Asking about your attempted solution rather than your actual problem
Hey, I have a basic problem. I tried to import the new jar into my Project but it just doesn't work. It also doesn't work to create a new project with the new spigot.jar but it still works for me with the old 1.17.1 one
Are you using the proper jar? In 1.18 it changed to needing to use a different one or having maven handle it
The jar you should be using is called "spigot-api-1.18-R0.1-SNAPSHOT-shaded"
and why need this?
WorldServer world = ((CraftWorld) Bukkit.getWorld(player.getWorld().getName())).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Ispeakweeb");
EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager (world);
This used to work on later versions of Minecraft, I might just be using really outdated ways of handling this but if you know how I can handle this without getting an error that would be helpful. Error: 'PlayerInteractManager(net.minecraft.server.level.EntityPlayer)' in 'net.minecraft.server.level.PlayerInteractManager' cannot be applied to '(net.minecraft.server.level.WorldServer)'. The usage of this is trying to create a NPC that spawns into the world
hmm try check the constructor of this class "EntityPlayer"
Sorry, I am new to programming in Java so I don't know what that means, if you don't mind can you give me a resource
No Im not using it. I also don't have maven in my main projects. Where do I get this jar?
you try creating EntityPlayer but the values passed are incorrect... the PlayerInteractManager i think is not needed...
In your folder you created your build tool go into Spigot then into Spigot-Api then into target and you should find it there
Okay thank you
Im also unable to use spigot-1.18.jar for creating a server . I tells me it is unable to open the jar. I already checked that I have java 17 installed. Since it din't work I updated to java 17.0.1 and it still doesn't work.
Unable to access jarfile server_latest.jar
check the name of the JAR this error can show if the file not exists
you mean convert bind to enchant or what?
I would like to test a little bit with it. I have Field f = HumanEntity.class.getDeclaredField("perm"); but hey say thats not correct. The errors are these java.lang.NoSuchFieldException: perm and at java.base/java.lang.Class.getDeclaredField(Class.java:2549)
well you need check if this field exists in this class... not sure why need access to this field if can use in the Player with ::isPermissionSet or another methods
yeah but i dont know where to search
using buildtools and get the NMS for search... but maybe can use the current API for what need to do.. i mean if need check perms or any you can use the methods in Player and not use NMS
ok thx i try it
ok i cant find anything and i watched a lot of tutorials XD
RROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Matchmaker: Fatal error compiling: invalid flag: --release -> [Help 1]
What's going on here? My dependencies aren't compiling now. They did in the past
again, wtf are you doing
please answer or no one will help
?xy
Asking about your attempted solution rather than your actual problem
your maven is configured for a newer java version than you have installed
Bukkit.getLogger().info("World name is: " + worldname);
Bukkit.unloadWorld(worldname, true);
WorldCreator worldcreator = new WorldCreator(worldname);
if (Objects.equals(config.getString("pregame.seed"), "random")) {
int seed = new Random().nextInt(2000000);
worldcreator.seed(seed);
Bukkit.getLogger().info("The seed is: " + seed);
Bukkit.getLogger().info("The seed gotten from worldcreator is: " + worldcreator.seed());
} else if (Objects.equals(config.getString("pregame.seed"), "preset")) {
List<Integer> seeds = config.getIntegerList("pregame.presetseed");
if (seeds.toArray().length == 1) {
worldcreator.seed(seeds.get(0));
Bukkit.getLogger().info("The seed is: " + seeds.get(0));
Bukkit.getLogger().info("The seed gotten from worldcreator is: " + worldcreator.seed());
} else {
int seed = seeds.get(new Random().nextInt(seeds.toArray().length - 1));
worldcreator.seed(seed);
Bukkit.getLogger().info("The seed is: " + seed);
Bukkit.getLogger().info("The seed gotten from worldcreator is: " + worldcreator.seed());
}
}
world = Bukkit.createWorld(worldcreator);
File oldworld = new File(Bukkit.getWorldContainer().getAbsolutePath() + "/" + worldname);
if (!FileUtils.deleteQuietly(oldworld)) {
Bukkit.getLogger().severe("Unable to delete the old world! Sometimes, the problem fixes itself after a server restart. idk why, but try that");
}
Bukkit.getLogger().info("regenWorld complete!");```
im trying to delete the current world and remake a new one, but the world sometimes fails to delete, sometimes it works, idk why, also the world seed from /seed doesnt match the worldcreator
What is the current way to get a Channel from a CraftPlayer entity?
It used to be nmsplayer.getHandle().b.a.k;
But now I'm using the mojang mapping, what's the Mojang Mapping method for it?
Seeds use a long
Use random.nextLong
oh ok, but what about the deleting?
Make sure it’s unloaded
"Bukkit.unloadWorld(worldname, true);" this should do it right
could i use Thread.sleep() ?
You shouldn’t sleep the main thread
Use a runnable and keep going until its unloaded I guess
so like loop delete the files until its confirmed deleted?
Pretty much
Not sure if there is a way to check if the world is unloaded, that would probably be more ideal
yeah, but thanks
public class PlayerInteract implements Listener{
int delay = 0;
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event){
Block block = event.getClickedBlock();
ItemStack tool = event.getItem();
if(block != null && tool != null && tool.getItemMeta() != null && tool.getItemMeta().getLore() != null){
if(block.getType() == Material.BEDROCK ){
if(tool.getItemMeta().getLore().contains("Breaks Bedrock")){
if(delay >= 30){
delay = 0;
block.setType(Material.AIR);
}else{
delay += 1;
}
System.out.println(delay);
}
}
}
}
}
how do I make the int delay per player rather than per triggered event
Use a map
wdym ?
Use a map to store an int for each player
how would I do that I'm new to making plugins
?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.
Does low RAM affect a server's TPS?
It can
In what way?
If there isn’t enough space in RAM the server has to spend extra time garbage collecting
Ahhhhhh got it
for some reason my plugin isnt loading. Its in the plugin file, but the config.jar file doesnt generate, and it just doesnt load.
Read the startup log
Well if it’s in the plugins folder and it didn’t load then they’ll be an error
Why is your log so long
I don't think I did the hash map right
public class PlayerInteract implements Listener{
Map<UUID, Delay> map = new HashMap<UUID, Delay>();
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event){
map.put(player.getUniqueId(), 0);
Delay delay = map.get(player.getUniqueId());
Block block = event.getClickedBlock();
ItemStack tool = event.getItem();
if(block != null && tool != null && tool.getItemMeta() != null && tool.getItemMeta().getLore() != null){
if(block.getType() == Material.BEDROCK ){
if(tool.getItemMeta().getLore().contains("Breaks Bedrock")){
if(delay >= 30){
map.put(player.getUniqueId(), 0);
block.setType(Material.AIR);
}else{
d = delay+1
map.put(player.getUniqueId(), d);
}
System.out.println(delay);
}
}
}
}
}```
not my, server owner has a bunch of plugins
nvm i was spelling it wrong
What is delay
Did you make a custom class for this?
Delay is suppose the be the value I'm storing
at com.github.ukraine1449.kronteq.Kronteq.<init>(Kronteq.java:26) ~[?:?] does this mean that the error was caused by line 26 in the Kronteq file?
Yes
ok copy ty
Delay isn’t a java type that I know of
Why not just store an Integer
so like this
public class PlayerInteract implements Listener{
HashMap<UUID, int> map = new HashMap<UUID, int>();
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event){
map.put(player.getUniqueId(), 0);
int delay = map.get(player.getUniqueId());
Block block = event.getClickedBlock();
ItemStack tool = event.getItem();
if(block != null && tool != null && tool.getItemMeta() != null && tool.getItemMeta().getLore() != null){
if(block.getType() == Material.BEDROCK ){
if(tool.getItemMeta().getLore().contains("Breaks Bedrock")){
if(delay >= 30){
map.put(player.getUniqueId(), 0);
block.setType(Material.AIR);
}else{
int d = delay+1
map.put(player.getUniqueId(), d);
}
System.out.println(delay);
}
}
}
}
}```
how do I fix
Cannot resolve symbol 'HashMap'
Cannot resolve method 'put(?, int)'
Cannot resolve symbol 'player'
Cannot resolve method 'get(?)'
Have you tried importing HashMap
Actually wait
More private 👍
I still have Cannot resolve symbol 'player'
it needs to be capital Player
Hey so I have a slight problem. My plugin does not load, and in the error log it says this Caused by: java.lang.NullPointerException at com.github.ukraine1449.kronteq.Kronteq.<init>(Kronteq.java:26) ~[?:?] that line of code is as follows. ```java
Location defaultStoredLOC = getServer().getWorld("Practice").getSpawnLocation();
what should I do?
if I put map.put(player.getUniqueId(), +1); will it add 1 to the current value
nope
how can I add 1 to the current value ?
map.put(player.getUniqueId(), map.get(player.getUniqueId() + 1));
its always 1
its not increasing
public class PlayerInteract implements Listener{
HashMap<UUID, Integer> map = new HashMap<UUID, Integer>();
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event){
Player player = event.getPlayer();
map.put(player.getUniqueId(), 0);
Block block = event.getClickedBlock();
ItemStack tool = event.getItem();
if(block != null && tool != null && tool.getItemMeta() != null && tool.getItemMeta().getLore() != null){
if(block.getType() == Material.BEDROCK ){
if(tool.getItemMeta().getLore().contains("Breaks Bedrock")){
if(map.get(player.getUniqueId()) >= 30){
map.put(player.getUniqueId(), 0);
block.setType(Material.AIR);
}else{
map.put(player.getUniqueId(), (map.get(player.getUniqueId())+1));
}
System.out.println(map.get(player.getUniqueId()));
}
}
}
}
}```
how can I get the spawn location of the world I spawn in when I first join the server?
because you always set it to 0
public static boolean isArmor(ItemStack item) {
return (CraftItemStack.asNMSCopy(item).getItem() instanceof ItemArmor);
}``` no longer works, is there a sane substitute?
Inconvertible types; cannot cast 'net.minecraft.world.item.Item' to 'net.minecraft.world.item.ItemArmor'
bruh
UUID uuid = player.getUniqueId();
map.put(uuid,
map.containsKey(uuid)
? map.get(uuid) + 1
: 1
);
@grave hound
I gtg for now I'll work on this more later
you're using NMS for this ?????????
bruh
lol
Do we have an armor tag?
Best solution I could find online haha, used to work in 1.17
I'll check it out
EnchantmentTarget.ARMOR.includes(..)
md_5 your hair looks pretty today
well what other reason do you need to know if something is armor
Mmm true
Big thanks for this
I was just expecting it to be a tag, never thought to look at enchantment target
can ask mojang why there's no tag
tags are weird af tbh
another odd design choice
Hullo
I mean spigot could always make custom tags
thats even sillier
How so
deciding what tags to add and what to put in them is an API nightmare
Hey, anyone here well-versed with multi-module Maven projects that can lend a hand?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
I'll start a thread so not to crowd the chat, then.
probably less likely to get an answer, but you do you
Hi
ok so if i wanted to get the block the entity is standing on would i do
Block bottomEntBlock = entity.getLocation().getBlock().getRelative(BlockFace.UP);```
No, you want down
Down is... down
yeah but wouldnt it be the top of the block
No?
ok so
a block has six faces, if i wanted to get the top of the grass block (the green part) I would do BlockFace.DOWN since its the top of the block
thats stupid
relative to what
The block you currently have
can u further explain this
Block.getRelative(BlockFace.DOWN) gets the block downwards(below) from Block
If you will it gets the block touching the downward face of Block
ScoreboardTeam team = new ScoreboardTeam(
((CraftScoreboard)Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(),player.getName());
team.setNameTagVisibility(ScoreboardTeamBase.EnumNameTagVisibility.b);
Error: Cannot resolve method 'setNameTagVisibility' in 'ScoreboardTeam'
Usage: I am trying to make a specific player and/or entity created to not show it's name tag
If you either know what is wrong or a better method I would appreciate the guidance
Why craftbukkit
oh ic
ty
public class PlayerDeath implements Listener {
public static void setMaxHealth(Player player, double hearts) {
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hearts);
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
System.out.println("hi");
Player killed = event.getEntity();
Player killer = killed.getKiller();
if (killer == null) return;
setMaxHealth(killed, killed.getMaxHealth() - 2);
setMaxHealth(killed, killer.getMaxHealth() + 2);
}
}
i have this listener that removes a heart from the killed player and adds a heart to the killer when a player dies
when the killed player respawns, the max health is set to the default value and it takes about a second before it gets set to the correct value
anyone know how i can get around this delay?
Even if you do that the client's probably going to show max health for at least a fraction of a second.
Does someone know why when I try to build my artifact it says my main class/files don't exist
Can't tell in your project view whether or not the MyPlugin class actually exists but if it does try right-click project and Reload from Disk?
Same thing
Maybe delete the import lines and repopulate?
Btw it's bad practice to use underscores in your package/class names like that
NO
DO NOT USE NMS FOR SCOREBOARDS
I have zero clue what i am doing man
daily md_5 message
Thank you
Oh cool it has a wiki page
i like how the
NMS on different versions (without reflection)
wiki uses actionbar NMS to showcase it
this is what happens when md_5 doesn't instantly add support for all the fancy features
but scoreboards have literally had support forever
pretty sure action bar has since at least 1.9 too
though wouldnt surprise me if it was 1.8
I cant remember 6 years ago
how to fake protocol?
in client
ok i got optifine src
gonna fake protocol
for some reason my server im playing dont really like 1.8 (which i dont like too, but im pretty good at old combat so i still use it), so i think i have to fake protocol to 1.9
People probably find old tutorials that use NMS
And then they use NMS, and then the cycle continues
md_5 needs to make it so certain parts of NMS just can't be accessed, ezpz
gonna sell it as DLC
<cash register ca-ching noise>
Do not provide any mappings at all 
md more like mea
mojang provides mappings, md_5 is just nice enough to make the tool for us to use
I'm sure someone else would
silly mojang
how did people even get mojang to provide them
was it the mod community
Obfuscate the spigot jar two times so even mojang mappings will not hekp 
Not sure
pog
Originally they were still ARR so nobody could really use them
But then Mojang changed the licensing on them
public class Scoreboard {
public void setScoreBoard(Player player) {
Scoreboard Tab = (Scoreboard) Bukkit.getScoreboardManager().getNewScoreboard();
Objective obj = Tab.registerNewObjective("ServerName", "dummy", "Build Server");
}
}
Error: getNewScoreboard is underlined with error "Method invocation 'getNewScoreboard' may produce 'NullPointerException' " and registerNewObjective is underlined with "Cannot resolve method 'registerNewObjective' in 'Scoreboard'"
Okay at this point idk what I am doing wrong because using exactly what you guys say to use it still doesn't work
intellij definitely doesn't have potential NPE as an error, just a warning 🤔 what ide is this
Well the first one is just a warning
intellij lets you decide if you ignore, warn, or error for everything
sounds like he has it on error
but you just have to null check then
Idk I just used what I was told is best and this is what I got
Man, I am just trying to make an npc not have it's tag get shown
I am so confused on why none of this is working
is it possible to make a new custom economy with vault ?
Sure?
hey, someone help me with some math rq
i have an enum for ranks, each rank has its own Index, for example "Owner" is 100, and Member is 0
I'd like to automatically sort them in tab, alphabetically...
so i have a List<String> that is the alphabet, now how should i get their priority in tab? should i start with a loop increasing the number each rank, and .get(the number for each rank that was increased); from the list?
oh
i knew there was a Comparator or Collections for that, idk why i didnt think of that
thanks md <3 love u
No worries
nice pfp 
public class PlayerInteract implements Listener{
HashMap<UUID, Integer> map = new HashMap<UUID, Integer>();
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event){
Player player = event.getPlayer();
Block block = event.getClickedBlock();
ItemStack tool = event.getItem();
if(block != null && tool != null && tool.getItemMeta() != null && tool.getItemMeta().getLore() != null){
if(block.getType() == Material.BEDROCK ){
if(tool.getItemMeta().getLore().contains("Breaks Bedrock")){
if(map.has(player.getUniqueId())){
if(map.get(player.getUniqueId()) >= 30){
map.put(player.getUniqueId(), 0);
block.setType(Material.AIR);
}else{
map.put(player.getUniqueId(), map.get(player.getUniqueId())+1);
}
}else{
map.put(player.getUniqueId(), 0);
}
System.out.println(map.get(player.getUniqueId()));
}
}
}
}
}```
Cannot resolve method 'has' in 'HashMap'
don;t try and invent methods. You can only use those that actually exist
then how can I check if it contains a value or equals null
I tried map.get(player.getUniqueId()) == null
but that ended up giving me an error
Think you want HashMap#containsKey
Hi,
I added a spigot-1.18.jar to Java Build Path but I can't import any packages for plugin.
yes
*Eclipse
its a bundler jar now
the jars you want to import will be in a bundler-dir when you run the jar at least one time
Use a proper build tool
Use a proper build tool
run "spigot-1.18.jar" (start the server)
then a dir named "bundler" will be created with all the libs you want to use
or just use maven
lots of jars i see and i have to add this all?
probably.... maybe some of them are never used (by you)
quick question - in PlayerDeathEvent, when i call event.getDrops().clear() i still lose my items, but they dont spawn in the overworld
is this normal?
if you clear the drops ? yes they will not spawn
actually
if you want to keep them use something else in the Event called setKeepItems() or smth like this
PlayerDeathEvent#setKeepInventory yes
Hello! I wanna share my creations with community, so i need to publish my maven artifacts, so other's can easily depend on my libraries. How could i do this?
I already have a server. Should i post it in my own repo, or just use maven central one?
public CustomChicken(org.bukkit.World world) {
// I like to use the bukkit world since that makes thing easier
super(EntityTypes.CHICKEN, ((CraftWorld) world).getHandle());
}
public void spawn(Location loc) {
this.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
this.world.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
} ```
I found this code in https://www.spigotmc.org/threads/adding-a-custom-entity-into-the-game.415812/.
i understand most of it but What is EntityChicken? Is it related to NMS?
Yes it's NMS
Thanks :D
does anyone know why item.getItemMeta().getLocalizedName(); returns an empty string for me?
because the name changed?
what's even the difference with the name and the localized name?
would it be empty running server-side then
ah yes i understand, if you use a texturepack with a lang file which replaces the item name
pretty sure that only returns a String if a custom name has been set
so client side iirc
how would i get the localized name server-side then?
Plugins should check that hasLocalizedName() returns true before calling this method.```
why is this painful
audio clips run fine in my ide
and not as a jar
ive tried everything in stackoverflow
literally everything
same path?
once its in the jar it needs to be accessed as a resource via the ClassLoader
What happens if you give LivingEntity NoAI and use a loop to specify a target like Player?
nothing
Then, is it possible to make a LivingEntity immobile without using NoAI?
I sucks at minecraft too
custom AI or add it as a passenger to an invisible object
Thanks :D
after some debugging
it seems
getClass().getResourceAsStream("/jitter.wav")
is null
h o w
same thing
yeah
its the same level as src
and in my src
and literally with my classes
open teh jar and physically check
7zip
sounds like common problem you can find on stackoverflow
nope, alr searched
ok il ltry 7zip
right click jar and open with 7zip
how to fake protocol client-side?(not spigot-related question btw)
i wanna fake protocol to have some more permission in a server that only give you if you use 1.9+
i see something like C00HandShake
Idk about the / but getClass usually means it has to be in the same folder as the class
Try getClass.getClassLoader.getResource instead
Or that hah
yep, you have to specify what to include when you export
depends on how you are exporting
im using maven if thats what you mean
if maven, use the resources folder
good question, I usually spcify mine
I have a problem with my Chunkloading system, idk how to set the ChunkGenerator again after a restart using the world variable :/
Code:
@Override
public void onEnable() {
getCommand("plot").setExecutor(new p());
new java.util.Timer().schedule(
new java.util.TimerTask() {
@Override
public void run() {
int worldInt = 0;
while(getConfig().isSet("Plotwelt" + worldInt)) worldInt++;
Bukkit.getServer().broadcastMessage("ConfigWorlds: " + worldInt);
int serverWorldInt = 0;
for(int i = 0; i<worldInt; i++) {
World world = Bukkit.getServer().getWorld("Plotwelt" + i);
if(world != null) {
serverWorldInt++;
WorldCreator creator = new WorldCreator("Plotwelt" + i);
creator.generateStructures(false)
.type(WorldType.FLAT);
ChunkGenerator chunkGen = new CustomGenerator();
creator.generator(chunkGen);
}
}
Bukkit.getServer().broadcastMessage("ServerWorlds: " + serverWorldInt);
}
},
3000
);
}```
I appreciate your help! 🙂
so
everything in resources shoudl auto be dumped in the root of yoru jar
you can control it ```xml
<build>
<defaultGoal>clean package</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<!-- Include all resources -->
<resource>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>.yml</include>
<include>.txt</include>
<include>.json</include>
<include>.properties</include>
</includes>
</resource>
</resources>
</build>```
why do you use a schedule to run a world ?
I was the german guy again xD
i know but this is english-chat
@spiral light i use a scheduler because the plugin is getting loaded before the worlds are getting loaded
thats why i use a 3 second delay
is this intended ? a delay for that is terrible solution... you could start the plugin later in the plugin.yml - load: POSTWORLD
or smth like this
same thin
?paste your pom
using that you will probably have to alter the <directory>resources</directory> Thats just a sample from one of my projects, its resources is in a different place
probably main/resources
yeah but do i add that to my pom xml? if so where
yes
there won't be
the contents of resources is copied to teh root of yoru jar, IF your pom is correct
run with ide will use a different path to running as a jar
with IDE your wav files are in the resources folder
should i send u my class cuz maybe i fucked up somewhere
btw
i just tried with cmd
and its still null
?Paste
?paste
ignore that its messy, ive tried like 12 different methods from stack overflow
s = getClass().getClassLoader().getResourceAsStream("jitter.wav");
this is null
if that is in your ide you will need ClassLoader.getResourceAsStream("./resources/jitter.wav")
oh right mb
@grim ice i did this to load a language translation file for my server
s = getClass().getClassLoader().getResourceAsStream("./resources/jitter.wav");
still null
the "en_us.json" is already in the resources-dir
is there a guava Cache<T> class but not for a map, just a list?
s = getClass().getClassLoader().getResourceAsStream("/jitter.wav");
did you try this ?
try ./src/main/resources/jitter.wav
that won;t work for him as he is running it in his ide
okay
i tried it in and outside of the ide
lol
and didnt work
it will never work outside yoru ide as you havn;t yet got your includes correct
sec let me test in my ide
btw still null
Just use Integer as a key ?
s
i'm using a Cache<UUID, Long> now where i use long objects as dummy values
i just tried
InputStream s = getClass().getClassLoader().getResourceAsStream("./jitter.wav");
but
it doesnt return null anymore
but the audio just doesnt play @eternal oxide
how can i edit this to something else?
AsyncPlayerChatEvent
xd gamer arent you on paper
should i use 'spigot-api' or just 'spigot' as the artifact-id for the dependency in the pom.xml?
spigot-api
k thanks
both if you wanne do nms and stuff like this
at main.java.Util.play(Util.java:25)
Clip clip = AudioSystem.getClip();
InputStream s = getClass().getClassLoader().getResourceAsStream("./jitter.wav");
AudioInputStream aInputStream = AudioSystem.getAudioInputStream(s); // this is line 25```
UnsupportedAudioFileException: could not get audio input stream from input stream
btw
wav not supported?
hey i found out what the issue with my javadoc is
the argument --generate-javadoc might produce a ...-javadoc.jar file in the target folder
but it's actually at users/<you>/.m2/org/spigot/<what you're building>
or rather only that file actually contains javadoc
WorldCreator worldcreator = new WorldCreator(worldname);
if (Objects.equals(config.getString("pregame.seed"), "random")) {
long seed = new Random().nextLong();
worldcreator.seed(seed);
Bukkit.getLogger().info("The seed is: " + seed);
Bukkit.getLogger().info("The seed gotten from worldcreator is: " + worldcreator.seed());
} else if (Objects.equals(config.getString("pregame.seed"), "preset")) {
List<Long> seeds = config.getLongList("pregame.presetseed");
if (seeds.toArray().length == 1) {
worldcreator.seed(seeds.get(0));
Bukkit.getLogger().info("The seed is: " + seeds.get(0));
} else {
long seed = seeds.get(new Random().nextInt(seeds.toArray().length - 1));
worldcreator.seed(seed);
Bukkit.getLogger().info("The seed is: " + seed);
}
Bukkit.getLogger().info("The seed gotten from worldcreator is: " + worldcreator.seed());
}
world = Bukkit.createWorld(worldcreator);
im trying to create a new world, but the seed from worldcreator doesnt match up with the actual world being generated. the world itself is regenerated, but the seed of it doesnt change, whats wrong
w

I have it, it wasn't a HumanEntity it Was a CraftHumanEntity
how do i get the ip a player connected with?
CraftHumanEntity is a HumanEntity
SELECT *, CAST(JSON_EXTRACT(stats, '$.points') AS UNSIGNED INTEGER) AS points, RANK() OVER(ORDER BY points DESC) AS 'ranking' FROM lifetime_stats```
Is there a way, to get the same result as with that query, without using JSON_EXTRACT?
Hey Guy i need help with color-codes!
I saved the color-codes to a file, but they look like this:
I think p.getAdress() Do it
I saved uuids to, but when i get the name of the player with this uuid later, i get a NullPointerException
k
no
player.getAdress().getHostAdress() return an ipv4 string
Yeah
i want to check if the player connected with play.server.net or server.net
that wont work with getAdress iirc
i found this proxiedPlayer.getConnection().getVirtualHost().getHostString() but idk how to get the proxiedPlayer
((InitialHandler) player.getPendingConnection()).getHandshake().getHost()
ProxiedPlayer is Bungee
oh
nvm mine doesnt work
btw i converted it into aiff
which is supported too
Sorry I got taken away
is this the right way of getting the uuid of the shooter of an arrow in the entity damage by entity event?
((Player) ((Arrow) event.getDamager()).getShooter()).getUniqueId()
?
CraftHumanEntity implements HumanEntity
Anyone got maven tips for why this happens?
These repos 100% exists, i just pulled this project over from my other pc to my newer one
Was just working on this project 2 days ago as well, it imported JitPack dependencies
But it wont install anything from any other repo, eg citizens, spigot, paper etc
i dont get why maven has to go full blown retard all the time, this happens to me at least once or twice a week, getting rather god damned annoying cause there is absolutely no fix for this bs
I have a odd Issue, when I remap the spigot I not get right type of vanilla files (I get with spigot naming, i not suspect so big change to vanilla ). Is it possible get with vanilla name or do it work if open spigot jar?
hey, im trying to add a potion effect to a player every x seconds. im doing it with a scheduler. in public void run(), i want to add the potion effect but idk how. can someone help me?
can someone help me with this? worldname would ideally be the level-name in the server.properties, and the previous world would be deleted before it reaches this
player.addPotionEffect()
no need for a scheduler i think
as it stays
Are you actually deleting the old world? If not WorldCreator will read that world rather than create new
how can i make it so, i can use player because now i cant use player im bit new to all of this
are you making a command?
no just a scheduler that gives you jump boost every x seconds
and where do you start it?
in the main class?
Bukkit.getLogger().info("World name is: " + worldname);
assert worldname != null;
for (int i = 1; true; i++) {
Bukkit.unloadWorld(worldname, true);
File oldworld = new File(Bukkit.getWorldContainer().getAbsolutePath() + "/" + worldname);
FileUtils.deleteQuietly(oldworld);
if (!oldworld.exists()) {
Bukkit.getLogger().info("World successfully deleted! Only took: " + i + " attempts");
break;
}
}```
this should do it right?
in onEnable yes
Main world?
i guess you're looping Bukkit.getOnlinePlayers?
wdym?
I hope you are not trying to delete teh overworld
i should do that in the PlayerJoinEvent
right now i didnt write anything with players. when i write something else like sout it works fine.
i think what you are trying to achieve is starting a task when a player joins, which adds a potioneffect for x seconds and then removes it
yeah, whats wrong?
yes thats right
overworld and nether can not be unloaded. the code blocks it
yes
oh, i didnt know that, what should i do then?
Hello I have a problem so i am making chat system and its working with Default mc colors... How can i add HexColor support?
this is the format:
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
Player p = event.getPlayer();
event.setFormat(ChatColor.translateAlternateColorCodes('&', VaultUtils.getChat().getPlayerPrefix(p )).split("&")[0]+" "+ p.getName()+ChatColor.WHITE+ ": " + ChatColor.GRAY+event.getMessage());
}```
The only time you can delete teh overworld and nether is at startup, in onLoad before any worlds are loaded
Hey I have a quick question about attribute modifers. I try to change the attack speed of a sword in the ItemMeta with an attribute modifier. Unfortunately, based on what I found on the Internet, I still don't understand how it actually works or how I have to specify everything there. Anyone who happens to be able to help me with an example?
someone here who wanne test if a compass on a loadstone still works in vanilla minecraft 1.18 and on servers in 1.18 ?
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Bukkit.getScheduler().runTaskTimer(pluginInstance, () -> {
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, amountOfSecondsTheEffectWillStay * 20, 1);
}, 1, amountOfSecondsToWaitBeforeRerunningIt * 20)
}```
something liek this
the 1 is just start it after one tick
so i use public void onLoad() { and in plugin.yml load: STARTUP?
one tick = 1/20 second
Just let yoru plugin load as normal, no need to specify the load condition
onLoad fires before worlds are loaded, onEnable runs after, if all is default
your code will fail if its a restart
you mean /restart?
can i write you a dm? :D
or you can just write it here
reload
it can also help other people
^
alright, thanks for the help
okay, so do i need to have the extends BukkitRunnable thing still there?
Wait
no
Why are you applying potion effects in a Runnable
indeed, and he can just use events to know when to remove it, eg if they enter and area he can just cancel them
my idea was that the player gets a random strength of jump boost every x seconds
ohh fair enough then
Hello, how can I get the position all portal blocks in a portal from the position of 1?
why does the PersistentDataType class doc contain only fields for the same field type twice? Can i create a PersistentDataType<String, Integer> or no?
if you want to set the strength, work with a random for the amplifier
You can create any type you want. Look at the example in teh javadoc
do i have to implement a new class?
There is a full example included in the javadoc
okay ill do that but right now im trying to get the schedule thing to work
@eternal oxide
tree search
?scheduling
what's @literal
ignore it
how do i do that
rate
uh what is the conversion from one data type into the other for? Does that mean the PersitentDataType is supposed to store one value in two different formats?
or
they can just remove your authentication code comepletly
you can do something else btw
probably be 10x more easier, unless your sending an authentication requests every single action
Values must be boiled down to primitive types to be stored
In all honestly you will never stop someone from leaking your code if they really want to
store access in the binary jar itself
ah im using integer anyways so just do implements PDC<Int, Int> ... return Integer.class ... return other_field ?
https://i.imgur.com/Q87rmpT.png what do it have to write for plugin? @tardy delta
the instance for your main class
Isn’t there already a type for that
probably looking for dependency injection
there is
You learn about search algorithms https://www.baeldung.com/java-breadth-first-search
like java public class MyPlugin extends JavaPlugin { public void onEnable() { getServer().getPluginManager().registerEvents(new MyListener(this)); } }
public class MyListener implements Listener {
private final MyPlugin plugin;
public MyListener(MyPlugin plugin) {
this.plugin = plugin;
}
}```
no spacing be like:
embrace passing plugin instances through constructors
Reject static plugin instances
does anyone have experience with votifier api ?