#help-development
1 messages ยท Page 1852 of 1
org.bukkit.entity.ArmorStand
yah thx
how to set items in off hand in armor stand?
How do I get plugin from class Main?
Plugin is just a variable name
how do I get the instance of the plugin
Inside your main class this will refer to your plugin instance
Why didnt it work when I made a method that returns this
like, I have to do this for it to work
public void onEnable(){
instance = this;
}
and return instance instead
ahh static... the beginners fav keyword
If you're implementing dependency injection, you don't really need to use static at all.
ah I get it, If code is a mess, use static to make it work ๐
That's a bad mindset to have
YES
Object oriented? Never heard of it
imagine dont say that coll ๐
How do I find out if player is in death screen or no
I'm having deaths over deaths
isAlive() mayhaps?
isDead()
How do I make a method that runs every second without stopping the server?
is there an event that fires every tick?
?jd
jd is too confusing
I find it simple
cant filter searches
Ctrl f
ctrl f overrated
Go in discord server search and type every tick
is there a jd page that displays EVERYTHING
bukkit has a jd?
no
but you can create it urself
pretty easy
- create event
- on enable plugin make a bukkit scheduler or something you want to then call the even every tick
if you not using the bukkit sheduler, bukkit runnable then 1 tick = 0.05 second
Hey guys! How can I use the SpecialSource plugin in my Gradle projects. I know that Gradle doesn't support Maven plugins, but is there an alternative.
Someone else here just made gradle exec the commands
Idk who, search gradle and specialsource
Ok thank you very much!
It was @hasty prawn
Yep lol
Dogo
You can use that task if you wish
What Should I do if I want to loop this method every 100 ticks?
I read Scheduler Programming wiki, but I didn't understood it
uhhh how can i send ActionBar to a player in 1.18? can't seem to find anything on the internet related to this topic
Bukkit.Runnable()
Runnable
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
p.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Your time: " + seconds)); am i doing this the right way?
it seems to tell me that the sendMessage() method is deprecated
p.spigot().sendMessage()
Then you are using paper
Ye
You need to get Player.Spigot via
Player#spigot()
And then call Player.Spigot#sendMessage(ChatMessageType, BaseComponent)
it still says its deprecated even when calling it that way
Use the BukkitScheduler
?scheduling
It's definitely not deprecated as I use it in my library an in a couple of my plugins
If you are using paper then its deprecated as they use adventure or whatever its called
adventure? wym exactly
i didnt hear about that
I think you can just call player.sendActionBar(Component.text("Hi"));
This is the spigot server
how do I give and get the value for each player PersistentDataContainer?
I dont understand the question. Do you want to get all entries of every players pdc?
yes
Thats a bit tricky as you no idea what PersistentDataType each entry has
String
So you dont want to get all entries but one specific entry.
Only of online players?
I want to get different values for different players
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
PersistentDataContainer container = onlinePlayer.getPersistentDataContainer();
// Do stuff with container
}
why?
Okay, I seem to get it. Thanks
It doesn't seem to fit me
If you explain your problem we can give you proper advise
NamespacedKey key = new NamespacedKey(this, "key");
String value = p.getPersistentDataContainer().getOrDefault(key, PersistentDataType.STRING, "off");
String newvalue = value.equals("on") ? "off" : "on";
p.getPersistentDataContainer().set(key, PersistentDataType.STRING, newvalue);
if (newvalue.equals("on")) {
p.sendMessage("On");
} else {
p.sendMessage("Off");
}
When entering a command, the value changes
But if any player writes a command, the value will change for all players
You should use PersistentDataType.BYTE and the values 0 / 1
I need to change the value for 1 player
separate the values for each player?
see if player is in config yet? if not create a new ddefault value?
you should also probably store a boolean
instead of a string
does config.addDefault overwrite previously manually overwritten values?
Then he would have to write a custom PersistentDataType
thats not a default type?
In general, I need to save the time that the player has played
ah alright
create a hashmap that has every each player?
Thats tracked by minecraft already
no, if restart server
well alternatively you can use a byte, thats what a boolean is behind the scenes anyway
values clear
Also you shoul use a single long value for that which represents the time in milliseconds
What for?
addDefault overwrites nothing. It just adds defaults to a MemoryConfiguration
time tracking
will they save the time that the player has played in the pdc?
Who is "they"? The pdc is a spigot API feature. Nothing vanilla related is in there.
why do you even want to save the playtime of the player
if its already done my minecraft
- create hashmap
- every player that joined first time, put in hashmap start 0
- make a loop that increases every online players by a second every second
- convert it to d h m s when needed
where do I save the fake time?
how do I edit a config value so that it cant be overwritten atleast, automatically, without a command
store it in seconds because it will be easier to maintain
Day Hour Minute Second
only convert it when needed
after restarting the server, the value is cleared?
if it is stored in a file or config no
Ill write you an example on how to manually track player time...
again, why do you need to track player time. its already done by the statistic system and you can already see how long a player has played
is it possible to do it via pdc?
pdc?
PersistentDataContainer
What is pdc?
seconds, minutes, hours, days
the statistic system stores the ticks played
oh god
all you need to do is convert
yes maybe
he said it resets... every server restart
why would it reset
if use hashmap
how?
private static String TIME_FORMAT = "%s, %s, %s";
public static String getFormattedTime(long ticks) {
long seconds = ticks / 20;
int day = (int) TimeUnit.SECONDS.toDays(seconds);
long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24);
long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60);
return String.format(TIME_FORMAT, hours, minute, second);
}
ั
huh?
ok finally i can ask my question
?paste
thanks
I want this method to repeat every 20 ticks, continuously passing the sentry to itself.
But what I made seems to make the plugin work after 10 ticks, not run() or detectNearestEntity() .
Why using a 'plugin' here? And how do I just keep repeating the method over and over?
Here's full code and it's not main -
https://paste.md-5.net/posaxegobi.java
There are 2 options:
Either recursively call the method or use the scheduler to run a repeated task
When the server starts:
Wait 40 ticks,
broadcast a message,
then every 20 ticks
broadcast a message
@Override
public void onEnable() {
startRepeatedTask();
}
private void startRepeatedTask() {
long initialDelay = 40L;
long repeatedDelay = 20L;
Bukkit.getScheduler().runTaskTimer(this, () -> {
String msg = "Im being broadcasted.";
Bukkit.broadcastMessage(msg);
}, initialDelay, repeatedDelay);
}
If that method is used multiple times in several places, won't it conflict with each other?
it will just start multiple schedulers
and youl end up with multiple broadcasting at different times
Does anyone knows the keyboard shortcut in IntelliJ to import the bukkit method (at top of file) instead of just adding it before the string when autocompleting ?
`
#Instead of this (this is when I just hit enter)
public class test implements org.bukkit.event.Listener {}
#I want this
import org.bukkit.event;
public class test implements Listener {}`
The same code just more volatile:
private void startRepeatedTask() {
long initialDelay = 40L;
long repeatedDelay = 20L;
BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
Runnable runnable = new BroadcastRunnable();
JavaPlugin plugin = this;
bukkitScheduler.runTaskTimer(plugin, runnable, initialDelay, repeatedDelay);
}
With a simple Runnable implementation:
public class BroadcastRunnable implements Runnable {
@Override
public void run() {
Bukkit.broadcastMessage("Im being broadcasted");
}
}
@rough basin
it's quite confusing but i will try to understand it myself, Thanks bro
This usually only happens if you already have another implementation of Listener imported
Ooooooh yep thanks ๐
Is there any way to put values โโin run() ? run( LivingEntity entity ) throws an error.
you can put values in the constructor of BroadcastRunnable
So the run() method comes from the Runnable interface. Each class that implements Runnable
must implement this method as-is. What you can do is adding a field in your runnable class and using the constructor
to fill it.
private void startRepeatedTask() {
String message = "Im being broadcasted";
long initialDelay = 40L;
long repeatedDelay = 20L;
BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
Runnable runnable = new BroadcastRunnable(message);
JavaPlugin plugin = this;
bukkitScheduler.runTaskTimer(plugin, runnable, initialDelay, repeatedDelay);
}
public class BroadcastRunnable implements Runnable {
private final String message;
public BroadcastRunnable(String msg) {
this.message = msg;
}
@Override
public void run() {
Bukkit.broadcastMessage(message);
}
}
That being said, its a really bad idea to have a field for live objects like Entities, Blocks, Players etc.
Do you want to have one runnable per player?
Or is this more like a boss mob runnable?
No, I'm working on making some specific snowman loop run().
This can lead to memory leaks or performance issues quite fast.
Make sure that you cancel the task as soon as the snowman unloads or dies.
Thanks bro, I'm thankful that these snowmen won't spawn much lmao
how do I insert a arraylist into config.yml?
If the list is of a serializable type then you can just throw it in there
This is a really safe and simple way to have custom snowmans:
https://gist.github.com/Flo0/8ed04989323745e7844118aea60ffa83
FileConfiguration configuration = ...;
List<String> someList = List.of("E1", "E2", "E3");
configuration.set("SomeKey", someList);
so i just chuck in in there with a random somekey
Sure. But give it a proper name ๐
hi guys, anybody knows how to deserialize a raw message of /tellraw and send it to a player?
Why do you want that?
uhm, cuz i need that i think?
Spigot has an API for everything you could do with the tellraw command.
player.sendRawMessage()
umm, i don't like very much to do that by executing the command.
what
What are you trying to achieve?
i think there should be api to do that elegantly, i just didn't find it.
What are you trying to achieve?
player.sendRawMessage()
afaik, this method has nothing to do with the json message.
Can you please tell us what you want to do? Why do you need the tellraw format.
send a clickable text to the player.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
better to have a cache for it.
TextComponent message = new TextComponent("Click me");
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org"));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Visit the Spigot website!").create()));
This sounds tricky. Movement is not fully server authoritative so it will look weird either way.
probably waaaaay to laggy
because i've coded it, or generated it as a json text.
meh teleportation is not that expensive if its within 8 Blocks or so.
no, afaik this is not for chat texts.
spigot/bukkit config or PlayerFoodLevelChangeEvent
Several ways. Simplest would be to edit the spigot.yml and increase the amount of food that is being consumed
by healing, running and jumping
you should take a look at javadocs spigot .... its rly not complicated to modify how much the player looses
it exists even before /tellraw.
Another way would be using a scheduler that just constantly chips away at a players food level
Hey ๐ Is the onEnable method sync ?
Try the following approaches:
- Try sending it via Player#sendRawMessage(String)
- Deserialize the json using
https://ci.md-5.net/job/BungeeCord/ws/chat/target/apidocs/net/md_5/bungee/chat/TextComponentSerializer.html#deserialize-com.google.gson.JsonElement-java.lang.reflect.Type-com.google.gson.JsonDeserializationContext-
Yes
Thanks ๐
?paste
i have this since a looooooooooooooooooong time: (for JSON messages)
https://paste.md-5.net/hohetubopa.java
if I add something to my disabled arraylist, does the Module get affected? ArrayList<String> disabled = Modules.disabled;
yes
how do I make it so it isnt affected
clone the list
since its not a copy of the list .... with that you just create a reference
wdym by clone?
new ArrayList<>(Modules.disabled)
pretty sure this will work
anything that isnt a copy will change the original?
a reference will altrer the original
both the disabled and the Modules.disabled variables point to the exact same List in memory.
not anything ....
?
strings, integers.... all the primitive things copy and not create a refernce
List<String> A = new ArrayList<>();
List<String> B = A;
List<String> C = A;
A.add("Hi");
System.out.println(A.get(0));
System.out.println(B.get(0));
System.out.println(C.get(0));
This prints Hi 3 times.
then new keyword creates a new Object in memory.
Then = sign lets a variable point to an Object in memory.
You can have arbitrarily many variables point to the same Object.
actually @lost matrix i have a question for you, does this work the same when storing objects in a hashmap for example
for example if i save A in 2 different hashmaps
do I have to make another class if I want to make another command?
or I can just have a Commands class and have it all there
will both point to the same place in memory ?
Yes. The keys and values in a hashmap are also just references to the actual objects in memory.
you can manage all commands in 1 class .... but this is not the proper way
how do I make it so only ops can access my command
player.isOp ?
how abt console
console is op all the time ? xd
oh i thought it would have a separate more powerful method
what does @Override do?
allows you to override a method from its superclass
replace the method of the superclass with your method
i am confused.
public abstract class Animal
{
protected String getName()
{
return "Animal";
}
}
public class Cow extends Animal
{
@Override
protected String getName() {
return "Cow";
}
}
for example ^
all the time that specific examples O.o
Animal foo = new Cow();
String name = foo.getName();
now this would get me "Cow"
since its a cow object and i have overidden the getName method to return cow instead of Animal
thanks, but im still confused, ill try to understand it later
In principle nothing, but it can only be put on a method in your class which overrides a method from one of your classโs parent classes
ah yes, but what if I keep my classes separate
Wym by separate?
abstraction = good (normally)
then override wonโt be attachable there
Like the only good thing about @Override is that it checks at compile time that you do in fact override some parent methods
can override override a Final method?
but it has not other functionality, mostly speaking annotations do not altho some libraries use them for actual code behavior but that is not the case for java
nope
you cannot extend a final class and you cannot override a final method and you cannot reassign a final variable
How does Minecraft's Names/Customnames system work?
(Please explain and do not send source code)
do you mean entity.setCustomName ?
From a Player
player=entity
I mean CustomName and Name
Custom name is just something for plugins iirc
Like changing it wonโt inherently change anything virtually
And what about Displayname?
Think itโd change the visual name
What does iirc mean?
how do I put a ArrayList into the config?
Just throw it in
throw it in?
FileConfiguration configuration = ...;
List<String> someList = List.of("E1", "E2", "E3");
configuration.set("SomeKey", someList);
For a List of Strings its simply
FileConfiguration configuration = ...;
List<String> someList = configuration.getStringList("SomeKey");
is it called ArrayList or StringList?
What does your "it" refer to?
what's the difference of the two?
For once StringList does not exist as a type...
uh, well StringList is just method name to get an Arraylist of strings
At the point of calling this method we dont know what List implementation we get.
Most probably an ArrayList. But we dont know and we shouldnt care.
aight thanks.
We simply get a List
ah yea thats true
I cant write to my config. It says it's null
How would I be able to create a DataWatcher in 1.18 with the new Mojang Mappings? This what I have so far:
// Extra Textures for Skin
DataWatcher watcher = npc.getDataWatcher();
byte bytes = (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40);
watcher.set(DataWatcherRegistry.a.a(17), b);```
I can import the DataWatcher objects and all but it keeps throwing the "Cannot Find Symbol" error at me
bytes and b?
If you are using the Mojang mappings then the class is SynchedEntityData
LivingEntity#getEntityData()
How do I save config?
FileConfiguration#save(File)
what do I put in File?
are you using the default config?
Do you load the config via JavaPlugin#getConfig()
yes
then you are using the default config setup.
what is the default config
Simply call JavaPlugin#saveConfig() after chaning it
are there contents?
not unless you add them
then how abt custom
How do you initialise a ServerPlayer?
ServerPlayer npc = new ServerPlayer(((CraftServer) Bukkit.getServer()).getServer(),
((ServerLevel) player.getWorld().getHandle()), gameprofile);
The ServerLevel keeps messing up
"keeps messing up" in terms of what
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Like it doesn't properly initialise from the Player World's getHandle() method
This what I have so far..
// Create CraftPlayer
ServerPlayer craftPlayer = (ServerPlayer) ((CraftEntity) player).getHandle();
// NPC Skin
Property textures = (Property) craftPlayer.getGameProfile().getProperties().get("textures").toArray()[0];
GameProfile gameprofile = new GameProfile(UUID.randomUUID(),
ChatColor.translateAlternateColorCodes('&', displayName));
gameprofile.getProperties().put("textures",
new Property("textures", textures.getValue(), textures.getSignature()));
// Spawn NPC
ServerPlayer npc = new ServerPlayer(((CraftServer) Bukkit.getServer()).getServer(),
((ServerLevel) player.getWorld().getHandle()), gameprofile);
// Extra Textures for Skin
SynchedEntityData sed = npc.getEntityData();
byte bytes = (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40);
watcher.set(DataWatcherRegistry.a.a(17), b);
// Set Position
npc.setPos(x, y, z);
Connection connection = ((CraftPlayer) player).getHandle().connection;
connection.send(new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, npc));
connection.send(new ClientboundAddPlayerPacket(npc));
connection.send(new ClientboundSetEntityDataPacket(((Entity) npc).getId(), ((Entity) npc).getEntityData(), true));
connection.send(new ClientboundRotateHeadPacket(npc, (byte) (npc.getBukkitYaw() * (256 / 360))));
yeah... well your getHandle is wrong
do smth like this:
((CraftWorld) player.getWorld()).getHandle()
and the Extra Textures would be:
SynchedEntityData sed = npc.getEntityData();
byte bytes = (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40);
sed.set(SynchedEntityData.defineId(net.minecraft.world.entity.player.Player.class, EntityDataSerializers.BYTE), bytes);
how do I put a string in .java into plugin.yml
what string do you want to put there and where there ?
I want it similar to /gamerule
but with disable/enable
I want to put ("playerPunchedAir", "playerTooHigh", "playerBreakTooSlow", "playerAteTooMuch", "playerOverworked", "playerSlipped", "playerTookDamage", "playerTooHealthy") but it is currently a StringArray
in your plugin.yml ???
I want to put it on the command usage
yes.
and why do you ask smth about .java ?
I could format it so it would be separated of | instead of commas, and surround it in []
just set
usage: /<cmd?> playerPunchedAir/playerTooHigh/playerSlipped ....
it is a StringArray in a class in java
how can I set it automatically?
something like '${project.version}'
How is the event named, that will be triggerd, if I write something in the chat?
uhmmm i dont think this is possible to write it automaticle in the plugin-.yml
AsyncPlayerChatEvent
aiigghht
unless...
I make a new plugin.yml
is that possible?
Just don't
k
Make the command say the usage message rather than messing with the plugin.yml
how will the users know what to type?
ah so if there is no args[1] in the command send them the list
You can tell them?
the arguments should be always the same - so dont try to do smth complicated with your skill level -> just time waste
Check If the argument length is below something, and then send the usage message.
For example, you have a command /eco give (player) (amount), If the args length is below 3, send an usage message.
seems about right
System.out.println("Nulling run");
System.out.println("<"+args[0]+">");
if (args[0] == "LIST") {
System.out.println("Usage run");
sender.sendMessage("Usage: /" + command.getName() + " [enable|disable|list] " + modules);
return false;
}
System.out.println("Wrong arg run");
Any idea why Usage run didnt fire?
args[0] is typeof string
@gentle oriole Try if(args[0].equalsIgnoreCase("LIST"))
you cant compare a String with a String with just "==" ... you will need to use equals or equalsIgnoreCase
Ooh
But whyyyyy
== is only true if they are the exact same object in memory, just not comparatively equal.
Like, same memory address??
yes
Oh.
So two strings set to the same value will not be == but will be .equals
I understood. Is java only one doing this?
Depends, C++ is all pointers so can;t really be compared
no
It literally makes no sense...
Since when did you need to compare values from the same memory address
Since always
How
it makes sense
Why not do it the other way round to make it simpler
Is because java isn't a scripting language?
? Why not have True mean False
it can be ==
only if the two objects are the same identity
strings with the same value internally are
doesnt
"might" so not reliably, Never assume
Well I said might because itโs probably not the case in older versions
But newer ones would definitely do some of these string optimizations at compile time
you can also force it with the intern() method
Best example I can find, not to use == java class Teststringcomparison3{ public static void main(String args[]){ String s1="Sachin"; String s2="Sachin"; String s3=new String("Sachin"); System.out.println(s1==s2);//true (because both refer to same instance) System.out.println(s1==s3);//false(because s3 refers to instance created in nonpool) } }
Which only gets worse on older java
Is the memory address for s1 and s2 the same?
What happens if you change one of them then changed it back
you change both
Both????
from what I'm seeing
Why both?
@hybrid spoke do you have an ide up?
the compiler may put it in a string pool but this isnt guarenteed
i dont think it works with values entered at runtime
so changing the value of s2 it no longer references the same object as s1
But those strings were entered at compile time thus the compiler can infer them as the same object just fine
Read teh post on the front spigot page about 1.18 nms
But yes itโs a very dumb assumption as it is clearly stated that string is a value based class thus any == comparisons are likely to yield an unintentional result unless you do as cipher and at runtime invoke intern to get or add if absent to the internal string pool
?paste
OK, thanks. to stop using NSM, do you have a solution to make custom heads, with custom textures without NMS? like this https://www.spigotmc.org/threads/how-to-get-the-texture-id-from-a-skull.537663/
What I'm making is that the snowman fires an arrow every 30 ticks.
But in luncharrow.shootToEntity(), Basically line 45 - isDead() works normally,
but in run(), isDead() does not working normally. Is there a way to fix this damn problem and kill the Task?
There's Full code - https://paste.md-5.net/exemiriqok.java
Is there an API method to send an action bar message?
yes... depends on version but
player.spigot().sendMessage or smth can do this
Hey ๐ What is most efficient between a JSON object and a Java Object ?
in 1.17 and earlier, are explosions in the nether generalle stronger?
e.g. when I create an explosion with power 4 in 1.17 nether, it deals twice the damage as an explosion with power 4 in the overworld
the blockstrength of netherrack is just low(er)
I am talking about the player damage only
my explosions don't do any block damage ๐
could be a bug.... you should test it in survival world too
Ok thanks. Do you happen to know how can I send a default message using minecraft keys (for instance "selectServer.delete")
anyone can help me ?
Hey quick question: I am currently programming that players can claim chunks through my plugin by placing a specific item in the chunk. This will then store the id of the chunk (chunkX + "." + chunkY) under the person's name in a MySQL data table. Now, however, for certain scenarios, e.g. if the chunk has been claimed by another player or you have claimed it yourself before, I wanted to have the player always send a message regarding this and wrote the following lines of code for this:
if(MySQLMethods.getPlayernameByChunkid(chunkID) == null) {
MySQLMethoden.addChunkId(player, chunkID);
player.sendMessage("You have claimed this area with the id " + chunkID);
} else if(MySQLMethods.getPlayernameByChunkid(chunkID).equals(player.getName())) {
player.sendMessage("You have already claimed this area");
return;
} else {
player.sendMessage("This area was already claimed by another player");
return;
}
The getPlayernameByChunkid method searches the database for which player this chunkid was stored under, based on the given chunkid.
My problem now is that the code right after the first if query is never executed. Even if no player was saved under this chunk. So the plugin doesn't seem to identify an empty table row as null. Does anyone maybe know how I can do this correctly?
maybe jsut test it `?
Don't use Player names, they can change
TranslatableComponent iirc
can someone help me?
login to "{@token}" with the name "{@bot}"
it says cant understand this event
idk why it dont work because it worked some time ago on another server but now it dont work
what worked where ? that doesnt look like spigot
Skript
is it the wrong channel to skript help?
"Serious Spigot and BungeeCord programming/development help | Ask other questions here"
isnt skripting something of a plugin ?
yea? there is no room to skript so i figured i could use this
it is... its spigotMC's plugin i need help to understand
Does anyone know the placeholderapi?
No it isnโt
They have their own discord
okay sry
Pretty much no one here uses skript
looks like disky or vixio
Oh yes right that makes sense
Hey someone know how to fix NMS i saw the Message from md_5 for remapping but it dident worked (i am using MacOS)
do you use notepad for coding or smth else ?
I use IntelliJ IDEA
run buildtools for 1.18.1
so how does your pom looks like ?
Here u see
do you want to use 1.18.1 or 1.18 ?
i did, some packets working but i can not send
1.18.1
then this is already wrong
You did --rev 1.18.1?
u got a fix?
R0.1-SNAPSHOT??
How would i register a CommandExecutor without a command?
Essentially this:
getCommand("name").setExecutor(new CommandExecutorImplementation);
but without the getCommand.
you cant
if you want to add commands without adding them to the plugin.yml you should take a look at PlayerCommandPreprocessEvent
you mean creating commands without plugin.yml?
no
Makes no sense. You cant have a raw CommandExecutor without a corresponding command.
Best you can do is just having your command be written in your JavaPlugin class. Then it will be the executor of all
your commands.
I just need one commandexecutor to be registered but i need it to fire whenever any command is ran.
the only way i can think of is using the preprocess event.
Use the event then
can someone help me with spigot plugins? I am trying to add featherboard but it is not showing up when I do /pl it doesnt even turn red plus it doesnt make a folder in the pl folder it stays as a jar
is this right cause it is still not working
they told me to come here for help idk why but ill go back there
you dont have the api
yeah not sure why the guy told u to come here
its not the api -.-
If you're using remapped the names are changed
PacketPlayOutPlayerInfo is NMS and since you wanted to use remapped version you now have the mojang names for that
u know the Mojang name ?xD
ClientboundPlayerInfoPacket
I sending Packets changed too?
public static void sendPacket(Packet<?> packet) {
for(Player all : Bukkit.getOnlinePlayers()){
((CraftPlayer)all).getHandle().playerConnection.sendPacket(packet);
}
}
.playerconnection dont work
soooo wierd xD
you can take a look at my tool to translate your stuff back to mojang names - once the site is full loaded you can use the searchbar at the top left
https://timcloud.ddns.net/mapping
public static void rmTab(CraftPlayer cp){
ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, cp.getHandle());
sendPacket(packet);
}
public static void sendPacket(Packet<?> packet) {
for(Player all : Bukkit.getOnlinePlayers()){
((CraftPlayer)all).getHandle().connection.send(packet);
}
}
public static void addTab(CraftPlayer cp){
ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, cp.getHandle());
sendPacket(packet);
}
}```
is this right?
Basically, forget all knowledge of existing mappings. They're probably not the same anymore
Though pretty much all of what you're doing here can be done with API
Player#showPlayer() and Player#hidePlayer()
never ever the api supports fake players O.o
Oh it's fake players
That snippet there alone just looks like it's hiding existing players
i think so .,.. because otherwise there is the api xD
is there a way to dynamically start up multiple servers from a single template on different ports?
My EntityDamageEvent spawns 10,000 threads in one attack.
i have no idea What is going on my code now
?paste
probably yes ... but thats advanced stuff
What could you possibly be doing? lol
yea i'm aware
i was wondering if there were any programs that could help me
or any open source projects
i dont know i just hit snowman and it just boom
maybe look at google ...
Relevant code would be helpful ;p
https://paste.md-5.net/gusataziro.cpp Does anyone know the reason why whenever i enable this plugin it makes the TPS go to 2...
- There's no way you unironically space your code like that
- Bukkit#getOfflinePlayer() is going to absolutely kill your server
i saw someone talking about docker
You can just use strings. I'm pretty sure that #getScore(OfflinePlayer) is deprecated in favour of #getScore(String) anyways
My EntityDamageEvent spawns 10,000 threads in one attack.
Here is the EntityDamageEvent and the entire class that creates the thread.
event - https://paste.md-5.net/duhuromava.cs
class - https://paste.md-5.net/uniyilixud.java
I have no idea why it's happening now lmfao
Your BroadcastRunnable, which is a task timer, is spawning other task timers in its run method
Line 37
dear god

i thought it just returns some numbers
how can i make player skulls stackable
i have a command that gives skulls in stacks, but i would like to be able to stack them if they have the same owner
so any ideas?
i wanted to try out the concept but i'm not even sure if spigot allows multiple instances of itself to be launched at the same time
Is there a way for a thread to get its own taskID?
with the same worlds its not possible since they are locked by the first instance ^^
if the items are fully equal its should be possible.... just because the owner is the same they are not equal ^^
i think u gotta make ur own extension of the thread class for that, could b wrong
You're cancelling with the task id but there is a better way to go about that. You have the choice of either accepting a BukkitTask instance in your constructor, or extending BukkitRunnable instead of Runnable
I'd honestly opt for the constructor route
the best idea that came to my mind is having a template, copying it using the File class, changing the port in properties and starting the bash file
public static class BroadcastRunnable implements Runnable {
private final BukkitTask task;
public BroadcastRunnable(BukkitTask task, LivingEntity entity) {
this.task = task;
// etc.
}
// etc.
}```
```java
Bukkit.getScheduler().runTaskTimer(plugin, task -> new BroadcastRunnable(task, entity), 0L, 20L);```
but it's probably a pretty bad idea
Then you can call this.task.cancel(); to stop it
could work
Alternatively if you extend BukkitRunnable instead of Runnable, it itself carries a cancel() method. Can just invoke this.cancel() or super.cancel(), whichever you prefer
Which isn't a bad solution tbh. Might be better to do that given that you're already passing in other information into your constructor anyways
But at this point you can almost avoid int ids entirely for schedulers. They're pretty old
isnt BukkitRunnable depricated for some reason ?
PacketPlayOutChat
is it now ClientboundChatPacket
I am searching for IChatBaseComponent as well
which is now net.minecraft.network.chat.Component ... ?
CraftPlayer p = (CraftPlayer)player;
IChatBaseComponent cbc = IChatBaseComponent.ChatSerializer.a("{"text": "" + message + ""}");
PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte)2);
p.getHandle().connection.send(ppoc);
}
}
for a action bat
bar*
and the problem is ???
well you litterly wrote that
PacketPlayOutChat is also Mojang - but a different name
BR isn't deprecated, but its scheduling methods are because you should be scheduling those with itself, not through the scheduler
and wat is with IChatBaseComponent
new YourBukkitRunnable().runTaskTimer(plugin, 0, 20);
// vs... deprecated
Bukkit.getScheduler().runTaskTimer(plugin, new YourBukkitRunnable(), 0, 20);```
ok interesting ...
@balmy osprey
Component component = Component.Serializer.fromJson("Hello World");
where Component is nm.network.chat
Component cbc = Component.Serializer.fromJson("{"text": "" + message + ""}");
Then What should i put in task at first?
new BukkitTask?
See that same message you quoted ;p
Anyone know how to build BungeeCord fork? I am using IntelliJ command package on BungeeCord-Parent and get only net.md_5.bungee package without libraries. Maybe it is a stupid question, but anyway i am kinda new in Maven
i didn't know -> works wow
Yeah the scheduler accepts a Consumer<BukkitTask>
public void onPlace(BlockPlaceEvent e){
Bukkit.getScheduler().scheduleSynkDelayedTask(this, () -> {/do something/}, 100L);
}
How should i get "plugin"? "this" doesn't work
PacketPlayOutTitle PacketPlayOutPlayerListHeaderFooter i also searched on the internet
well you can use the Constructor of the Class directly .... then it doesnt need to be static and its more smooth
hmm
cannot access net.minecraft.network.protocol.Packet
Forget this... The solution was very simple. Target folder is bootstrap/target
By package Projekt
did you rerun maven ?
yes
?paste can you send your pom ?
^^
But i found everything on coding
did you run buildtools remapped ?
i did java -jar BuildTools.jar --rev 1.18.1 --remapped
Success! Everything completed successfully. Copying final .jar files now.
Copying spigot-1.18.1-R0.1-SNAPSHOT-bootstrap.jar to /Users/sebastian.zaengler/./spigot-1.18.1.jar
- Saved as ./spigot-1.18.1.jar
compared to my pom it looks like the same ^^
is this the only thing you get ?
yes thats all
while running maven install ?
Yes and package
then probably @ivory sleet can help by pinging someone else who knows more about remapping system with maven and 1.18.1
Ok i solved the goddamn 10000 tasks, but seems any task is invoking now
I tested with message so bug must in Task
does some find what's wrong with it?
any Task seems working now
well I don't know what's causing the bug but there is some terrible codestyle here
hi i have a /stuck command on my server but i don't now how i can let the player have face doraction the same way now i am facing the same way every time
i would handle it a lot different...
- create 1 task at onEnalbe
- create a list that contains targets to observe(your snowmans)
- each 5 ticks a random snowman gets picked and checked (if dead -> remove later)
- if the snowman already got picked in the last 30s just wait / pick another one
still not good but a lot easier then canceling task and creating new ones all the time
and also not using a static method to initialize your class would be good
Having problems using the remapped jar from BuildTools to use NMS.
<groupId>spigot</groupId>
<artifactId>server</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>G:\Spigot\Spigot\Spigot-Server\target\spigot-1.18.1-R0.1-SNAPSHOT-remapped-mojang.jar</systemPath>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
I have these dependencies, but it's still not letting me access NMS.
Any ideas?
if someone think they can help if they see the code say it i can send the code
what nms do you want to use ?
what do you want to do ?
1.18.1
StructureGenerator.m
isnt that part of the API ? or are you talking about the Villages/Minesheafts/Dungeons Generator stuff ?
the command do so players can take /stuck and come up on the higest block and i see that every time i do it i am facing south in minecraft
you probably missed that remapped means a new "naming"-system ?
I'm creating bounding boxes for those structures, definitely not API
you want to make a CMD that stucks players so they can only look south ?
StructureBoundingBox ?
no if thay are yusing it now thay face south i want so they face the same way that they did if up,down and north
you will need to set the locations' yaw and pitch from the players location yaw and pitch
well he does not use remapped mojang version
but if you want to use remapped mojang version you need to rename almost every nms stuff
but I was getting this error:
The type com.mojang.serialization.Codec cannot be resolved. It is indirectly referenced from required .class files
When I tried it without using the remapped mojang
Any idea how to fix that without using remapped mojang then?
well, replace remapped-mojang in your maven ^^
replace it with?
try to remove the line completly
Sorry, that's the error I get without any remapped-mojang in my dependency
never used maven with not remapped mojang since its too easy with real method-names
so I tried switching to remapped-mojang to attempt to fix it
you have "remapped-mojang" right there ^^
This error was before remapped mojang
so I added it in, still had no luck, and came here
i dont know where this error comes from... does it refer to a specific class / line ?
Nope, that's all it gives me
It only appears when I have StructureGenerator.m
because something in there depends on Codec
StructureGenerator.m = OCEAN_MONUMENT ?
yeah
I believe you need to import datafixerupper
How do I do that?
Still have
The type com.mojang.serialization.Codec cannot be resolved. It is indirectly referenced from required .class files
I'm perfectly fine with porting this over to remapped-mojang if someone knows what all of these classes/methods would be called
what mappings does remapped-mojang use?
made an tool for exactly that - if you wait for the site to load you can use the search box top-left
mojmap?
maowmap
So according to this StructureGenerator -> StructureFeature ?
Unless I'm not understanding this
yes
Hallo i found this thread and i just need help with that. But did not answer there yet, can someone help me here
anyone know if it's possible to render certain textures on spesific blocks with a resource pack? so like i wanna have custom blocks with blockstates, but it's very limited - can i maybe have it so if a block is in one location it will render one texture from the resource pack, but if it's in a different location it will render something else?
i dont think so
i've been told origin realms made a plugin that makes it so noteblocks are usable even though they use noteblocks' blockstates for custom blocks
Is there a serializer for serializing text to json form like ComponentSerializer? The first one is the form the text should be in, the second is what ComponentSerializer outputs
[{"text":"greetings","color":"dark_purple","bold":true},{"text":"hello","color":"green","bold":true}]
{"extra":[{"color":"red","text":"Hello"}],"text":""}
Yeah go and ask them about it, they probably know more than us here
Just wanted to throw out there that this is absolutely amazing. I'm having 0 issues changing the names
You can check for blockstates in the model json. Use that to split the textures
i don't think OR share their methods, they study a lot about the game
@spiral light
Question though, it's fine if you don't know:
Since WorldGenMonumentPieces -> OceanMonumentPieces
any idea what a PillagerOutpost piece would be?
one of them probably
1.18 recreated a lot / renamed a lot or rebuilded the system a lot ... very hard to know what they did sometimes
WorldGenFeaturePillagerOutpostPieces?
can someone help me with this?
Pretty sure that's an old mapping, it wasn't showing up as an import
Are you looking for PillagerOutpostFeature?
Okay just checked the PillagerOutpost does not have it's own piece
I'm just going to keep it as an OceanMonumentPiece and see what happens since that's what the original guide was doing
Are you generating structures?
No, setting bouding boxes so vanilla mobs spawn naturally where I want them to
ah
but i want to ... so if you know how ... maybe just post it xD
mojang took a page out of Spring API it looks like
the industrial revolution and its consequences
Since this is my first time using the mappings, what jar are we supposed to distribute after compile?
-remapped.jar
or -remapped-obf.jar
yes
so distribute the -remapped.jar
When choosing to use the 'Mojang Mappings', it is absolutely imperative that you are aware of the conditions attached to them as well as the Mojang EULA. These are not restrictions you can simply ignore. In particular you may only 'use the mappings for development purposes'. This means that you must only use the remapped-mojang jar for development and must remap your plugin prior to distribution.
anyone?
When i publish a plugin, which i made in intelij with maven, do I have to list all libraries in a NOTICE.txt? Because in maven, there are many libraries that are downloaded
You can't
But you can use noteblocks depending on the state, since they have a lot for custom block textures
can u publish ur source code if its using remapped-mojang or
You can
I told you how to get custom state based textures?
-
Find the StructureFeature you want.
-
Reflect the pieceGenerator field.
-
Call createGenerator
-
Call generatePieces
For a full code reference look at StructureFeature#generate
well... i have that but now i am stuck with FeatureConfiguration which is a JigsawConfiguration which needs a StructureTemplatePool
and yeah ... just searching for that now
Do you want your own strucuture or spawn a vanilla one?
vanilla one... but i cant find where those stuff was init.
They're in the StrucutureFeature class
that's not the question...
The only reason I know all of this is because a few days ago I decided to dig through how structure generation works for one of my mods
The location is not part of the block state. So not that won't work
^^^
I have no idea what you mean by that
i want to not render a resource pack texture of a block with a blockstate at certain times and instead render the normal block
Why don't you just open the OriginRealms resourcepack and take a look?
so like if i have a noteblock that has a blockstate and in my resource pack i set a noteblock with that blockstate to a texture, i want to be able to not render the resource pack's texture and instead render the normal vanilla noteblock texture if a variable or something is set
I am pretty sure some noteblock states are impossible in vanilla, so you can use those
this is a plugin thing, you can't do that with just a resource pack, you need both
Also why don't you look at origin's source
Well duh
Find what data they're using and replicate it
their code is not public
No need for it to be
Decompile
wdym
i don't have their plugin
Or just look at the resourcepack
i can, but the resource pack is not what's doing that
And see what state they use
it's the plugin
Open the resoucepack. See what data it uses and mimic that data for when you want your blocks
how can i add text decorations like a underline text to a message?
that's not what i meant
this class only containing StructureFeatures and they contain the FeatureConfiguration -> just as CODEC and not rdy to use -.-
ChatColor.UNDERLINE
The resourcepack checks for a certain status of a noteblock so look what it is
In the resourcepack
i meant like i want to render a default texture instead of a resourcepack texture if a variable is set with a plugin
ty
i know how to make custom blocks using blockstates
You can't make a noteblock show a texture you want by setting a variable as you are saying
no
ok i want to use noteblocks' blockstates for my custom blocks, but i also don't want them to render their custom textures i set with the resource pack if a variable is set
BlockStates aren't magic. They're predefined you cannot add your own
omg
Don't omg
omg
I have no idea about whatyour are saying
i explained it like 4 times
^^
You're*
Very poorly
origin realms have noteblocks, even though they use their blockstates for textures
Yeah so kill05 said it probably has unused block states. Which you can use
they did that by not rending certain blocks' textures
Yeah now look in the resource pack to see what data they're using
fine
Just this sentence doesn't make sense i'm afraid to tell you
they literally did it
They can't use "their blockstates" since you can't create them
"instrument=banjo,note=1,powered=false":{"model":"custom/misc_blocks/crates/crate_2"}
ohh i know how they did it
they probably didn't use like one noteblock texture and then have the noteblocks always set to those blockstates, and instead store the instrument and whatnot in the block data
mhm
mhm
Working with Forge has really helped me understand these things
so there is no way to not render a resource pack's texture with a plugin?
alr, how do i do that? also how do i make it so their blockstates won't update?
Packets or heavy NMS
frick
Packets would probably be easiest
i don't know either
Yeah this is quite advanced you shouldn't do it yet
Keep learning basics and come back later
this is very important for my server though
If you wanna do it the crappy way just cancel right click events on the specific location
how do i do it in the not crappy way
And saying that doesn't make you learn packets suddently or nms
crappy ways are crappy
How olivo told ya
i want to learn though
you got a good one? i also need one that explains everything
In this episode, I show you how to listen for and create packets using ProtocolLib. I explain what packets are, how to extract and set data in packets, and more. #Spigot #SpigotTutorial
Packet Reference: https://wiki.vg/Protocol
ProtocolLib: https://www.spigotmc.org/resources/protocollib.1997/
Code: https://github.com/Spigot-Plugin-Development...
It's a decent start to Protocollib
alright, sounds good
Yeah but if you know what a packet is already and how are they used Just watch the part about the protocol api tutorial
i don't
Then watch it all
all i know is that they're like advanced event listeners or whatever
there's a good one for pure nms https://www.spigotmc.org/threads/nms-tutorials-1-introduction-to-nms.204127/
Packets are the most basic form of communication between a server and a client
And while you can listen for them they are not listeners
This is also very valid if you wanna use nms
Imo using nms is better and less painful
should i learn packets first?
But protocollib makes compatibility easier
Yeah you should learn what a packet is first
For this use case, NMS is going to be much more painful
With less painful i mean you don't have to guess the fields
Even if it takes reflection to use nms, i'd rather do that
But if it involves obfuscation ehhh
mojang mappings and abstraction is not that painful
Yea compared to reading protocol wiki
and packetwrapper also makes better use of protocollib
The wrappers are outdated and if they are wrong good luck finding out what's wrong
:sad:
Yeh
๐ญ
I had to play a lightning bolt with packets to make an animation and protocollib was just making it painful
Nms code legit took 3 minutes
Nms stands for net minecraft server
nms is mojangs code
Its the core code of mc servers
the actual server written by mojang
So yea it's mojang's code
so builtin?
Huh
like i don't have to use a depenency or whatever
I mean it's in the main server jar
just replace 'spigot-api' with 'spigot' in your pom.xml
doing what?
java -jar BuildTools.jar --rev MC_VERSION
i have the buildtools' spigot api
Try to import CraftPlayer and see if it finds the class
how do that
Just start typing craft and see if it lets you autocomplete
nope
Or press shift 2 times and search for craftplayer
do you use maven?
idk i use minecraft development thing
do you have pom.xml?
replace 'spigot-api' with 'spigot' in it
honestly i barely know anything about all this
bad, very bad
is that the illegal thing
no, its not illegal
it will take spigot from your local maven repo
@misty current help
if you at least once built that mc version via BuildTools.jar
...
i am confusion
I said that if someone were to upload mojang code in an online maven repo
It would be illegal
what does that mean
Don't mind about it
ok
what am i supposed to search
i already have it
Then do what areg told ya
i'm supposed to import the api.jar not the buildtools.jar right?
Sorry i meant the dependencies
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```
yuh
Change it with spigot
so just remove -api?
Ye
it's downloading or whatever
Resolving dependencies
ok it's done
Ok now you can use mojang's code
ok
Now go back to what u were doing and learn packets
i got craftplayer
Means it works
nice
im gonna go to bed but actually just be on my phone for like an hour
i am tired
thanks and have a good one!
ty
Hey so I'm trying to move away from NMS, I've relied upon it for writing NBT Tags upon a NMS Copy of an item
Is there a spigot implementation for writing NBT Data to items or similar, I want to avoid using Object lore as I want to avoid overhead of encoding/decoding invisible strings (they're run asynchronously) but lots of async tasks queued doesn't seem fun
?pdc
Some of my item choices move outside of the PDC's scope
(Sorry should of mentioned, I took a step back while I was waiting for the 1.18 Spigot to enter a release state)
Hey there i need some help, i want to create an item that when it is right clicked it would execute some functions i have
How would i do that?
@rustic mica I use the OnInventoryClick function, get the items meta (that I prewrote) and call the method. https://www.youtube.com/watch?v=5npPUMrYaYE&
I already know how to create the item and i have created it
I tried to do something with the PlayerInteractEvent but no matter what i do nothing gets executed
And i have registered the listener class
Did you add @EventHandler
so im guessing thare is no way to use @p with plugins
i have a man hunt plugin that you need to run as a player and say the player you want the comand to use it wuld be /manhunt hunter sjfdog
i want to use a comand block to automate this
so nearist player that pushes butten becomes hunter
if i put /manhunt hunter @p it thinks @p is a player
do /ban
what do you want it to do
i made a bnagui menu
wich you click ban
it bans the selected player
but its not banning the player
There is, one second
1.18.1-R0.1-SNAPSHOT