#help-development
1 messages · Page 1858 of 1
your context is just <filter>
what part of the pom is it in
what is the full filter
one sec
post the pom
lemme try
This is inside the shade plugin:
I need an explanation about this entire part, what does it mean?
I read maven docs. I did. just didn't understand it at all.
it gives me errors..
Is there an easy way to use extra libraries in a plugin? Do I have to use Maven to add them into jar from dependsies? Or how?
it is preventing those classes from being shaded in
and what does the *:* mean?
yes, or use libraries in plugin.yml (1.17+ only)
wait. the string variable has to be like Material.GRASS_BLOCK or just GRASS_BLOCK?
ok, thank you
so select all the artifacts in XSeries and from there exclude the following classes?
in other words ^^
Just "GRASS_BLOCK"
not just xmaterial, all dependencies
yep tried that but not working
Try the other one and see?
did that too haha
Material.matchMaterial should be working
yeah i think that i made an error maybe somewhere else
Can I sak a question about Java here? (not a stupid question, but more related to just java)
here i made a for loop that loops into all the sections in the config.yml. then it puts the name and the material string variables into a function that creates a block
i dont know if i explained it correctly lol
is it not getting the right material?
i dont think so
this is the config file
oh lemme try
yep thats why then
path + ".material"
so i want to make spawner work on any light level heres what i got so far the only probelm is the w.getWorld has and unknow symbol ```@EventHandler
public void onSpawnEvent(CreatureSpawnEvent e) { // When a creature (Mob) spawns, this even will run.
if (e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER) { // Checks if the mob spawned because of a spawner.
Location loc = (Location) e.getEntity().getLocation(); // Gets the location of the spawned mob.
World w = (World) e.getEntity().getWorld(); // Finds the World name that the mob spawned at.
String mobType = (String) e.getEntityType().toString(); // Gets the name of the mob spawned as a string.
e.setCancelled(true); // Cancels the event so the mob doesn't spawn.
// This will only show the mob for a split second so it shouldn't affect lag, though it may
// be a visual bug that might get reported lol.
w.getWorld().spawnEntity(loc, EntityType.valueOf(mobType));
} else { // Otherwise, does this
return; // Does nothing. Returns to normal.
}
}```
Yeah that works too
(This problem appears most of all in Windows) I tryed starting some java processes (other minecraft servers) and when I shut down the main one, other close as well (also they start in background). How do I start them independent or maybe even start a normal cmd shell window for it?
idk what to do now
How are you starting them?
w already is the world.
still not working
Also if it isn't related to development you might want to ask in #help-server
Can you show the code again
also this EntityType.valueOf(mobType) is kinda redundant. just take the EntityType of the event instead making it to a string
I tryed many ways. with Runtime class, with ProcessBuilder and other ways
i tried removing .get world then it has no errors but nothing changes
Oh thats why
you still have to get the string from the config
should be getConfig.getString(path + ".material")
ohhhh lmao
for each one one thread
that would keep them alive even if the main one dies
bruh still not working ._.
Even if main java app dies?
Can you show the addItem method
as long as they are not daemon, yes.
i tried removing .get world then it has no errors but nothing changes
spawners only work in dark
yeah currently you are just canceling the spawnevent if the mob comes out of a spawner
Remove the Material.
yeah yeah i did remove that
ah wait, i oversaw the spawn method
i think that the error its on the return item
i put it cause my ide suggested it
What's the yellow line under Material.matchMaterial say
hmm
do you think that this could be helpful?
not really
mhm
it doesnt even cancel
that i can see
not sure if there is a "force to spawn in light". you probably have to do that yourself. maybe there is a game config or smth.
Try having your materials in your config surrounded by ""s
so like material: "GRASS_BLOCK"
Print what material is
help
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I find the following error
like with p.sendMessage(material)?
yeah or a sysout
oki
yeah currently you cancel the spawn and.. spawn them again
[ERROR] Could not load 'plugins/0.1.4_CA.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:164) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:739) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Thread.java:823) [?:1.8.0_272]
Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
in 'reader', line 8, column 6:
pb:
^
My plugin.yml
thats the goal
main: ledmans.miplugin.MiPlugin
version: '0.1.3.4.55'
name: Paintball
softdepend: [ Vault ]
authors: [ ledmans ]
commands:
pb:
they already gave you the answer
kinda
You probably tabbed pb: instead of using spaces
i want to summon entity where spawner is
no its not. the goal is to also let them spawn if there is any light.
it seems to not be that easy.
you prolly have to cache the spawner and spawn the entities yourself
scheduled
You are lucky that a spawner is actually a TileEntity.
So you can implement your own TileEntity, overwrite the tick() method and let it do whatever you want.
For example build blocks or spawn entities
?paste
for me sorry
oh i'm back lol, that's what comes out
Me and my dog rn
HAHA
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
pretty clear
Well there's your issue then. Can you send where you're calling createItem?
ok
i'm not calling it, now i'm just sending a message to a player for each material in the config
as you said to do
wait what did you print
hub1:
x: 11.713679753493269
y: 71.7776368487581
z: -126.28430046724496
material: GRASS_BLOCK
hub2:
x: 11.706774598316242
y: 71.7776368487581
z: -123.04959035484632
material: ACACIA_BOAT
this.
thats what i want to get
That should not be empty
haha
OH
? lmao
You're getting hub1.material
"warps." + path + ".material" is what you want
^
or save the result of getConfigurationSection to a new variable and get that
I'm a little slow but I got there 
You should get the values relative to the retrieved configuration section
still not working
i think that my idea of making it its totally wrong
i want to list all the warps on a gui with blocks, i get the block in the "material" on the config
i think that there is an easier way maybe, anyone got any ideas?
`
Thanks
I want to ask if there is a way to make an inline return of a string replaced with hashmap key-value?
My brains are being burning btw
Something like this:
FileConfiguration configuration = ...;
ConfigurationSection warpsSection = configuration.getConfigurationSection("warps");
for (String warpName : warpsSection.getKeys(false)) {
ConfigurationSection currentWarpSection = warpsSection.getConfigurationSection(warpName);
double x = currentWarpSection.getDouble("x");
double y = currentWarpSection.getDouble("y");
double z = currentWarpSection.getDouble("z");
Material material = Material.matchMaterial(currentWarpSection.getString("material"));
}
this gets all the infos for each warp right? (coordinates and material type)
In other words i want to convert the code below to an inline code
Map<String, String> placeholders = new HashMap<>();
public String replace(String text) {
for (Map.Entry<String, String> entry : this.placeholders.entryKey()) {
return text.replace(entry.getKey(), entry.getValue());
}
return null;
}
btw Location is ConfigurationSerializable so you should do this probably:
for (String warpName : warpsSection.getKeys(false)) {
ConfigurationSection currentWarpSection = warpsSection.getConfigurationSection(warpName);
Location warpLocation = currentWarpSection.getLocation("location");
Material material = Material.matchMaterial(currentWarpSection.getString("material"));
}
And also save the warps using ConfigurationSection#set(String, Location)
This looks like a job for regex
I get the following error I am not using any tab
https://paste.md-5.net/gofogidive.sql
MyPlugin.yml
main: ledmans.miplugin.MiPlugin
version: '0.1.3.4.55'
name: Paintball
authors: [ ledmans ]
commands:
pb:
omg that is workingggg, thank you again bud ^^
match("%(.*?)%")
gets every word between two '%' signs. Then simply iterate through the groups
spigot never lies.
ew short regex
and if you're creating placeholders using special characters you're weird
I don't see any "tabs" in my plugin.yml
%([A-Za-z_]+)%
Doesn’t placeholder API use special characters
Yeah well papi doesn’t use regex as it’s kinda slow
Does it use magic
Hey people
I dont want to do that
Because i will add to that map things like %player%, %rank%, and then i want to make a method that will replace all the placeholders, but i want to do it inline
just replace the placeholders yourself
you will have more expense filtering them out, check what they are and then replace them
Then use a lamda
now. i swear its the last time i ask today lmao. do you know how to do that when i click that item, i teleport to those coords?
I cannot find one btw
i just cant figure that out. maybe i should stop making this kind of plugins lol
.entrySet.forEach
PlayerInventoryEvent, if clicked item is yours, get who clicked and teleport them
bad attitude, never give up
ik how to make that but
It return a void
lemme show my code
?paste
^
I tried that many times but it doesnt return a string, it return a void
Because how i will send the message back to the player?
?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.
this is what i got with 7smile7
I need to return a string with the variable repalced so them i can send it to player
this is the config file
What do you want to do?
and now you want to react if someone clicks that item?
so, in that gui there are 3 items now right?
string = string.replace(key, value)?
Where string is a variable outside the forEach
There are several ways to do this but here is a fix brute force:
public String applyPlaceholders(String input) {
AtomicReference<String> atomicInput = new AtomicReference<>(input);
placeholders.forEach((key, value) -> atomicInput.set(atomicInput.get().replaceAll(key, value)));
return atomicInput.get();
}
which will be overriden multiple times
thought he want to do that for every var?
its trippy to explain that lol. like i need to create a click event for each item, that has their own coordinate
But its a fu**d way to return a replaced string from hashmap values using inline code?
inside the forEach it will be overriden and just the last one will be "returned"
No
I have done one but know i cant find it 😡
and i cant think of a way to do that. its so trippy
me xD
store the item somewhere or store it inside the item.
?pdc
oh imma read that
.map(entryToReplace -> s -> s.replace(entryToReplace.getKey(), entryToReplace.getValue())) ?
Here is your "inline":
private final Map<String, String> placeholders = new HashMap<>();
public String applyPlaceholders(String input) {
return Stream.of(new AtomicReference<>(input)).peek(ref -> placeholders.forEach((key, value) -> ref.set(ref.get().replaceAll(key, value)))).findFirst().orElseThrow().get();
}
I still dont know what you are trying to achieve...
Why is there an atomic reference wtf
I have two classes, One called LogsHandler, and one called INFO, I need to be able to get the name and target of the info, and put the string to be displayed in the LogsHandler class
Yes btw
Because otherwise i get scope issues.
This is the 3 line version:
public String applyPlaceholders(String input) {
AtomicReference<String> atomicInput = new AtomicReference<>(input);
placeholders.forEach((key, value) -> atomicInput.set(atomicInput.get().replaceAll(key, value)));
return atomicInput.get();
}
Ah right doesn’t it have to be final to be used inside a lambda
I have two classes, One called LogsHandler, and one called INFO, I need to be able to get the name and target of the info, and put the string to be displayed in the LogsHandler class
Transfering strings inbetween classes
But why are the placeholders a Map<String, String>
Shouldnt it be something like Map<String, Supplier<String>> or Map<String, BiFunction<Player, String, String>> ??
effectively final yes
cant you just force the input to be final then?
its a string anyways
Then how ya gonna replace it
and then ill just do
input = input.replaceAll()
on a final variable
You don’t need anatomic ref, reduce should do it
reduce?
Oh jeah
Is it time to learn something new
reduce works too
Can someone please help me
^^
I have two classes, One called LogsHandler, and one called INFO, I need to be able to get the name and target from info class, and put the string to be displayed in the LogsHandler class
OMGGG
A more concrete example would help, what code do you have so far?
So i have a command, /info
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
You tried
I have already gotten the target (args[0]) but I need to put that name, and the command sender and put it in a different class
how would i get that
this wont work
public String replace(String text) {
for (Map.Entry<String, String> entry : this.replaces.entrySet()) {
text = text.replace(entry.getKey(), entry.getValue());
}
return text;
}
what happened to standard for loops nowadays
^
can't we just leave .forEach with javascript
he insists on inlining
I mean I kinda like forEach for small stuff
public String replace(String text) {
for (Map.Entry<String, String> entry : this.replaces.entrySet()) { text = text.replace(entry.getKey(), entry.getValue()); } return text;
}
But I usually stick to loops for anything bigger
what is entry?
forEach is really nice when you can just use a method refrence
you never actually return text at the end, remove your return and then on the next line write return text;
true true
but then its not a oneliner anymore 
The same thing its not working
Its saying that i cannot return a void
You did not quite understand what all the stream operations actually do. Just stick to the normal for loop. This is quite complicated.
I cant my eyes burns when i see that horrible loop too long
horrible loop that long? it's 4 lines my dude
All of minecraft is basically 1 big loop :p
I will decompile some plugins to check if it have what i want
...
right
ok
public String replace(String text) {
this.replaces.entrySet().forEach(entry -> text = text.replace(entry.getKey(), entry.getValue()));
return text;
}
Oh but i want to skip that return
you can't
That code won’t work
yeah just realised
You need something like reduce
Ohh ok
streams are slow
Im trying to use reduce but this is even more comlicated than using an atomic reference...
i'm optimizing this plugin that's entire reason why it's performance is so poor is because it uses streams everywhere
I think streams are faster these days
That why
Probably still slower than loops though
I mean they are not THAT bad. If you use java 11+ then many Streams are just on par with for loops
idk but .findFirst() is taking like 10% of server perf
replacing it with a normal for loop increased performance a lot
idk why
I dm a Java senior developer and told me to use return stream.map(bla bla)
fire that developer
Lol
i refuse to believe a senior dev would encourage trying to shorten a function body to one line at the expense of the codebase and performance
public String applyPlaceholders(String input) {
return placeholders.entrySet().stream().reduce(input, (in, entry) -> in.replaceAll(entry.getKey(), entry.getValue()), (key, value) -> value);
}
Im not sure if i use the BinaryOperator "combiner" at the end properly
And readability
probably not
Why replaceAll
Thanks
I wil ltry it
ok well congratulations your code is now less readable, less performant, and actually larger in terms of jvm bytecode
idk... it supports regex i guess
could be bad tho
i personally would never do that
But if you don’t use regex it’s not good to use it
what if it's for a chat plugin
and then a player writes some invalid regex
server crash
(i've done that before)
ya
I will continúes searching for a inline string renplace
Because its imposible that there isnt a way for doing that
Another daught what is best Socket or Websocket for making clienta-server communication?
Just use messaging channels?
welll ... just java.net.Socket ?
How do you communicate with a client without a player
Sometime ago I find a truck for without players need with Messaging channel but i m an idiot I cannot figure how i had lost that
Use a message queue, don’t roll your own socket system
I just use plugin messaging to talk to a forge client
Yeah but i will use for cache sync btween servers
So is there a free host for redis?
local ?
Inefficient in many ways
It iterates over the whole map
You could use a prefix tree, or if all your placeholders start and end with %, just find and replace those while appending to a StringBuilder
I suppose this would only matter if you have a lot of placeholders
teleportation packet error
Good Morning Guys, What is PDC?
?pdc
cafebabe knows everything
that's just the docs
Probably with a map, since they require all placeholders to be surrounded by %
Sounds slow to check every single registered placeholder for a string though
Good way or API for fully setting a player invisible (with armor)
How to make command auto fill
pretty sure they extract every string surrounded with % and then check that against a map for a replacement. Something like that.
iirc they only check the token before the underscore as the rest is up to the expansion derivative to parse
Implement TabCompleter
i would use regex, get all stuff between "%" and then iterate through the groups and replace them with whatever the map returns
can i convert a bukkit itemstack to an nms itemstack
CraftItemStack.asNMSCopy
thx
so i have my local server running
but when i try to join localhost in the direct connect panel of mc
it doesn't let me join ):
"Connection refused: no further information"
same thing happens when i try localhost:25565, 0, 127.0.0.1, 127.0.0.1:25565
nothing is logged in the server console
is the mc server listening on localhost?
localhost is just the named piped usually for 127.0.0.1
however computers typically have another ip other then the loop back as well
so maybe try the ip assigned by the router?
also is the server and client on the same system?
how would i check this :p
what did you set for the ip address in the configs for the server?
generally for home hosting, you don't need to set an ip specifically and should instead set it to 0.0.0.0 so that it can listen on all ip's it has
ill try that now
thank you :)
just changed the ip to 0.0.0.0 and restarted the server
now the world files are corrupted?
pages upon pages of variations of [21:11:42] [IO-Worker-26/WARN]: Region file ./world/region/r.-1.-1.mca has an invalid sector at index: 73; sector 13893932 is out of bounds
how did you stop the server?
did you run /stop
if you hit the X button that isn't an appropriate way to exit the server. But if that isn't the case I couldn't really tell you why other then maybe a bad plugin?
what order is EnitityEquipment#getArmorContents arranged in?
yeah
no plugins are loaded :p
thank you for trying to help though, i do appreciate it
you can however get each armor independently however @woeful crescent
wait is there an order or no
trying to understand this, how would i set the value like 0 or 1
like set invisible to false, or true in the metadata packet
if invisible is false it would be 0, if you want it set the bitmask is set
public WrappedEntity hideFrom(@NotNull Player player)
{
final SynchedEntityData data = this.nmsEntity.getEntityData();
data.set(new EntityDataAccessor<>(0, EntityDataSerializers.BYTE), (byte) 0x20);
final ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(this.nmsEntity.getId(), data, true);
NMSUtil.sendPacket(player, packet);
return this;
}```
i have this to make it invisible
the 0 i assume is the index
0x20 is the bitmask
how would i toggle though like between the values to set visible and invisibel
bitmask doesn't mean that 0x20 is the entire byte either, just that it refers to one thing of the byte as a whole
there is 8bits to a byte
0x20 could mean or refer to the second bit of the byte
not sure if it does or not, just an example of what bitmask means
hmmm okay i'm a little confused here xd
the wiki discusses the masking somewhere
00000100 is what bit 6 set to 1 looks like. Well maybe not exactly since LEB128. But for practical teaching purchases we can pretend that it does.
im officially lost 😔
i understand bits but i dont understand how mc does this stuff xd
ok, well a byte is 8 bits
however MC uses all of the bits and not just the byte as a whole
hence bitmasking
that is why that list above you are looking at, can have multiple bits set in a single type
ahh i see i believe i understand it now :d
so you need to figure out, where 0x20 means in the byte
MC uses LEB128 or better known as Little Endian Binary 128
wiki.vg has pages on this
but if you are using protocollib you most likely won't need to worry about this anyways since it takes care of most of this stuff for you
ahhhh okay
do you actually have any idea why my mobeffects packet wasnt working 😔
sec
most likely because of this
data.set(new EntityDataAccessor<>(0, EntityDataSerializers.BYTE), (byte) 0x20);
final ClientboundUpdateMobEffectPacket packet = new ClientboundUpdateMobEffectPacket(this.nmsEntity.getId(), new MobEffectInstance(MobEffects.INVISIBILITY, Integer.MAX_VALUE, Integer.MAX_VALUE, false, true));```
i didnt have that before
i tried to set entity invisible with an effects packet before but didn't work so i resorted to metadata
well maybe because of the max values for integer? lmao
moving on......
xd
i didnt know that would affect it
since regular spigot allows it
well max value for an int is different on every system and generally that large of a number isn't expected to be in the packet 😛
Just set the level to 0
Integer.MAX_VALUE is just shorthand in code to mean the largest possible number an int can be on the system
what level? 😮
mmmm i see xD
oh amplifier
how do i make a player invisible indefinitely (like the potion effect, not hidePlayer())
and what would you think i should set the duration for to make it indefinite
Max value should be fine
oh are you guys talking about this already, lol
well mob effect, but it is relatively the same for a player
ok
yeah but with nms, the regular way is player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_INT, 255, false, false)) is what i do
you can always have a loop to reset timers too on effects
just because you set an effect doesn't mean you can't have something come back to update said effect 😛
public WrappedEntity hideFrom(@NotNull Player player)
{
final ClientboundUpdateMobEffectPacket packet = new ClientboundUpdateMobEffectPacket(this.nmsEntity.getId(), new MobEffectInstance(MobEffects.INVISIBILITY, Integer.MAX_VALUE, 0, false, true));
NMSUtil.sendPacket(player, packet);
return this;
}``` doesn't do anything to the entity 😔
there might be other packets you might have to update as well not entirely sure
part of the reason I don't mess with NMS packets XD
Apparently this is how I did it
private PacketContainer constructPacket(int id, boolean disable) {
PacketContainer entityMeta = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
entityMeta.getIntegers().write(0, id);
WrappedDataWatcher dataWatcher = new WrappedDataWatcher(entityMeta.getWatchableCollectionModifier().read(0));
WrappedDataWatcher.WrappedDataWatcherObject isInvisibleIndex = new WrappedDataWatcher.WrappedDataWatcherObject(
0, WrappedDataWatcher.Registry.get(Byte.class));
WrappedDataWatcher.WrappedDataWatcherObject effectIdIndex = new WrappedDataWatcher.WrappedDataWatcherObject(9,
WrappedDataWatcher.Registry.get(Integer.class));
dataWatcher.setObject(isInvisibleIndex, disable ? (byte) 0 : (byte) 0x20);
dataWatcher.setObject(effectIdIndex, disable ? 0 : EFFECT_COLOR);
entityMeta.getWatchableCollectionModifier().write(0, dataWatcher.getWatchableObjects());
return entityMeta;
}
i dont think i can get the invisibility index like that thru regular nms
public WrappedEntity hideFrom(@NotNull Player player)
{
final SynchedEntityData data = this.nmsEntity.getEntityData();
data.set(new EntityDataAccessor<>(0, EntityDataSerializers.BYTE), (byte) 0x20);
final ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(this.nmsEntity.getId(), data, true);
NMSUtil.sendPacket(player, packet);
return this;
}``` is how i did it with the datawatcher
Guys a quick question can u have 3 persistent data doubles in a block?
I want to learn that and i was just wondering if it can be useful for a plugin
Not in a block
Without a lib like this https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Thank ya
How may I better format messages? I got a role that is given and at the end of the game, it lists the players with that role, but it looks like this https://gyazo.com/d53e3fdef6338b70dcdae7c6f30b4220 and I'm unsure on how to make it format better. What I mean is for example if there is one player, it goes in the middle and if there is more than 3 or something, it goes to the next line. Just something that looks better if that even makes any sense
you can't format it "better"
chat is different for everyone
it may look good for you, but horrible for everyone else
for centering
Force a resourcepack with a monospaced font upon them. Ez formatting.
🥲

If I do the same thing in three places ChunkLoadEvent / WorldLoadEvent / onEnable , wouldn't the task run three times?
Can I set invisiblity duration to Integer.MAX_VALUE
How would I go about forcing a map to reload? So that it displays what blocks are there now instead of the original time it was loaded?
what's ambient
makes particles less obstructive
I can set the ItemStack on PacketPlayOutEntityEquipment to null right
to unequip?
this.c = var3 == null ? null : var3.cloneItemStack();
Looks like the packet accounts for null, gonna do that
how do i unregister events
maybe?
i meant unregister the listener
yea
also can i subscribe to just one event
or wait no
lol
Of course you can
you can do that o.O
yep
Yep, there are several methods for it too
How do I take things logged to console, and send them some place else? (discord webhook etc)
like errors logged by plugins, but "redirect" them
By writing code to post log messages elsewhere
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.
nvm solved
can I get list of ConfigurationSection from config yml?
getKeys(false) will help you on your way
uh I mean like this
I keep getting a Jar does not contain plugin.yml when putting my plugin into a server, but the plugin.yml is in my project but it doesn't show up in the jar
Is it in the root folder (no package)
yeah
If maven/gradle probably needs to be in resources folder
okay
I have a playerdata.yml and kitdata.yml also should they be in the resources folder as well?
Yes
ya look like a valid convert, thanks
how to toggle pvp ?
about a week ago i gave some info about this if you search through the channel history
is 1.8.9 code usable in 1.17+? my guess would be not fully, if at all, but figured id ask
Depends. If no NMS, then possibly
thx
ill send u it when i can find it
how do u import spigot jars with maven?
thank u
How to deal with the problem that &r doesn't clear &l &m or other formats with fromLegacyText?
no
a lot of it changes and breaks
Not really
a lot of stuff changes under the hood so you just need to see what breaks i guess
but from my experience i just started again
I'm using BungeeCord
Almost certain it does
If it doesn't, write a test and open a bug report
Thought it was my code :o Thanks.
When using runTaskTimer, Does TaskID not change even if BukkitRunnable is executed again through runTaskTimer?
I mean, if I run BukkitRunnable using runTaskTimer() and the TaskID is #3 at the first time,
I wonder if it will stay #3 while runTaskTimer is running.
how do I close a player's inventory
p.kick
kick?
nope
Player#closeInventory
smh it's in HumanEntity instead of Inventory
but i guess it works
does each line of code run each tick?
like 1 tick = 1 line run?
no
uhh... /give triggers PlayerDropItemEvent. is this intended?
._. the get() of ConfigurationSection return List<Map<?,?> instead of List<ConfigurationSection>; it passed compile time check but throw runtime exception
so how can I work on list of ConfigurationSection
If you just added the sections they are Maps, if you loaded the config they are MemorySections
I am reading a yml file and I want to get List of ConfigurationSection defined in this way
try List<MemorySection>
just .get
.get return an object
or getList
and it seems internally it will return List<Map<?,?>>
you can use get and provide the object type
That sounds like a bug
You have to save and reload for them to be converted to MemorySections
._. well, is it possible to convert Map to ConfigurationSection?
maybe a workaround but idk
This only happens if you add Maps to the config. Creating ConfigurationSections works fine, but add a Map object and its not converted to a MemorySection until you reload the config.
I'd class it as an annoying bug, but not the end of the world.
Depends which world
is there any way to find out if player is using the correct tool to break the block? isPreferredTool does work but it only returns false when after breaking the block, it will not drop anything
In MySQL does creating a variable in a table with the max VARCHAR allocate more memory automatically? Or will it auto adjust the memory allocation for the size of the string?
wdym?
Like creating a VARCHAR(65000)
Simple to google https://stackoverflow.com/questions/7124029/mysql-varchar-size
Tysm! Happy new year!
is there something like player#isbreakingblock
i dont think BlockDamageEvent#isCancelled() works..
i had cancelled breaking the block but the code still runs
isCancelled() does not cancel an event
yes,
if (!disabled.contains("playerUsedWrongTool")) {
Material[] logs = {Material.OAK_LOG, Material.DARK_OAK_LOG, Material.ACACIA_LOG, Material.BIRCH_LOG, Material.JUNGLE_LOG, Material.SPRUCE_LOG};
if (Arrays.asList(logs).contains(e.getBlock().getType())) return;
scheduler.scheduleSyncDelayedTask(plugin, () -> {
if (!e.isCancelled() && !e.getBlock().isPreferredTool(e.getItemInHand())) {
Killer.kill(player, "used the wrong tool.");
}
}, 20L);
}
PS: BlockBreak animations are client side in 1.18
- Dont call contains on a List
- Dont create a new array/list every event that just wastes memory
um, you are testing the cancelled state of an Event 20 ticks after its finished!?
im testing if the player is still breaking the block or not
no you are not
what alternative do I use on 1?
An Event is a fire and done process. Once your code exists teh event is finished
then how do I check if the player is still breaking the block
There is no method to test to see if a player continues breakign a block
you can detect the damage, and the break is all
check if they are the same block?
dunno
dont mind about that
sorry ping
yeah no, doesnt work
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onDamage(BlockDamageEvent event) {
Block block = event.getBlock();
Material blockMaterial = block.getType();
ItemStack tool = event.getItemInHand();
if (!Tag.LOGS.isTagged(blockMaterial)) {
return;
}
if (!block.isPreferredTool(tool)) {
// Handle wrong tool usage for logs here
}
}
!Tag.LOGS.isTagged(blockMaterial) tag?
private static final Set<Material> CHECKED_MATERIALS = EnumSet.of(
Material.OAK_LOG,
Material.BIRCH_LOG,
Material.SPRUCE_LOG
);
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onDamage(BlockDamageEvent event) {
Block block = event.getBlock();
Material blockMaterial = block.getType();
ItemStack tool = event.getItemInHand();
if (!CHECKED_MATERIALS.contains(blockMaterial)) {
return;
}
if (block.isPreferredTool(tool)) {
// Handle wrong tool usage for block contained by CHECKED_MATERIALS here
}
}
dont spoonfeed
🥄
Dont tell me what to do 😄
🙁
well, i dont know tags exists until now...
Usually you want to use a Set instead of a List when calling contains
Tags are an exception for this specific case
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
hey so i am trying to use the worldguard API, and I am getting this error when I compile. any thoughts as to why?
cannot access com.sk89q.worldguard.protection.flags.Flags
how do you build the project?
intellij maven build - clean then compile
(will delete that afterward so it doesn't flood)
looks good
yeah this works on a different plugin that is 1.16.5, I don't know why this doesn't work for a 1.8.8 spigot plugin
aaaand im out
dam lmao
cause they dont work with 1.8?
yes but i thought worldguard worked with 1.8?
that isn't your entire pom
version 7.0.6 is for 1.17 and 1.18 only
i didn't want to send all so that i wouldn't flood
?paste
for 1.8 - 1.11 you would need to use version 6.2
But i advise against using 1.8 at all
¡
Okay so I changed the <version> tag to 6.2, do I need to change anything else?
probably. This version is very very old and might have completely different approaches which you will probably not find any documentation for anywhere
Okay, so i'm stuck again with my plugin haha. Its just so trippy. How do you put 3 values (x,y,z) in a block that i can later get easily?
storing data in non Tile Blocks is only possible through some trickery
Bruh
So how can i make it?
Do you have any ideas for the click event?
Idk if you remember yesterday
What are you trying to do?
Oh okay u dont lol lemme explain
So i have a config with some warps, each with a name, x,y,z and a material
I made a for loop to get al the warps and for each one make an item that i put into a gui
Idk if i explained that correctly
makes sense
Now i need a click event for those blocks, so that when i click i teleport to the coords
You didnt mention any blocks so i have no idea what "those blocks" is refering to
So you want to have certain Blocks that teleport to certain warps when right clicked?
No wait lemme start my pc a sec
they are making a GUI
Ah i see. Was a bit confused with the whole clicking on blocks thing
seems they want the items in said GUI to probably teleport them to different servers XD
or warp them somewhere in the same map/server
there is an Inventory Click event
yeah ik that
hub1:
x: 74.65848167798883
y: 105.89627683692098
z: -262.68832976440643
material: GRASS_BLOCK
hub2:
x: 58.36908896976975
y: 105.89627683692098
z: -219.65651838033324
material: BIRCH_LOG
this is my config right?
for (String warpName : warpsSection.getKeys(false)) {
ConfigurationSection currentWarpSection = warpsSection.getConfigurationSection(warpName);
double x = currentWarpSection.getDouble("x");
double y = currentWarpSection.getDouble("y");
double z = currentWarpSection.getDouble("z");
Material material = Material.matchMaterial(currentWarpSection.getString("material"));
warps_menu.addItem(createItem(warpName, material));
}```
and its not making the item?
and here i'm looping throught all those "warps", getting all the infos that then i put in a function to create a block. Finally i put all the blocks in the gui. As 7smile7 said
no it is working nicely
but. now i need a click event for each block, but how would i get the infos
get the slot they clicked?
like i need to store the coords into the block idk
Use a Map<Integer, Warp> for slot -> warp mapping.
Or if you dont have a Warp class then a simple Map<Integer, String> map should suffice
that couldnt help
?pdc
isnt pdc there?
i tried that, but i cant store 3 doubles in a block
Eh... writing a UI using pdcs... idk about that
lol
oh GUIS?
yup
ok then use nbt
or store in the hashmap
oh, wait
you should have the custom gui as a reference somewhere?
cuz i'm actually pretty new at dev and i dont understand this
All the cool kids rename the inventories and just check the name on every click 😄
lemme search on google for maps lol
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.
there
always easy to do that until someone has a client that can send named inventories 😛
oh kk thanks
oh thats actually easier than i thought
so i need to make a map in the for loop, put the 3 values and then get them? in other words
when you load all the warps you should fill your map with the values. Its probably a good idea to also define the slot number in your config file
oh okay imma try that
And you should have a single instance of your inventory as its not dynamic meaning there is no harm in everyone having the same inventory open
is there event when turtle hatched from turtle egg?
maybe, i say maybe i got that lmao
EntitySpawnEvent would be my first guess
oh, i was fixated to hatching, that will do the trick, thanks 🙂
hey yo! I tried doing this: ```java
ConfigurationSection warpsSection = getConfig().getConfigurationSection("warps");
for (String warpName : warpsSection.getKeys(false)) {
ConfigurationSection currentWarpSection = warpsSection.getConfigurationSection(warpName);
double x = currentWarpSection.getDouble("x");
double y = currentWarpSection.getDouble("y");
double z = currentWarpSection.getDouble("z");
TWCore.coords.put("x", x);
TWCore.coords.put("y", y);
TWCore.coords.put("z", z);
Material material = Material.matchMaterial(currentWarpSection.getString("material"));
warps_menu.addItem(createItem(warpName, material));
}```
this is the event: ```java
@EventHandler
public void onWarpClick(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
if(e.getView().getTitle().equalsIgnoreCase(WARPS_MENU)){
if(e.getCurrentItem() != null){
Double x = (Double) TWCore.coords.get("x");
Double y = (Double) TWCore.coords.get("y");
Double z = (Double) TWCore.coords.get("z");
Location loc = new Location(p.getWorld(), x, y, z);
p.teleport(loc);
}
}
}```
but, it gets just the coords of the last warp set
so even if i click on another warp, it will tp me to the last set
.
write a java after " 3 times ` " for better readability
oh thanks for the tip ^^
👍
for(ItemStack itemStack : ((GuiChest) gui).inventorySlots.inventoryItemStacks) {
for(Slot slot : ((GuiChest) gui).inventorySlots.inventorySlots){
if(slot.getHasStack()){
if(slot.getStack().getIsItemStackEqual(itemStack)){
itemSlot.put(itemStack, slot);
}
}
}
renderItem(itemStack,0,0);
}```
this isnt spigot but i have a question
if i have a loop
that has another loop inside
it does indeed still loop
it goes in succession if that makes sense
Single thread runs in sequence. Outside loop can;t run until inner finishes
so when the inner loops 1 time, all the outer ones will loop 1 time
I'm new to this plugin thing and i ran into a problem because i don't know how to know the gamemode the player is on, can anyone help me?
?jd-s and search gamemode
get the player object and check. Unless you gave them perms to use the game mode command to change their gamemode, typically this will just be survival
a Clue, its under HumanEntity
ok thx 😁
any way to make blocks colorable with a resource pack and a plugin? maybe like using the grass thing that colors it depending on the biome?
Yes you can color certain blocks based on their biome. But i think they need an alpha mask. So leaves and grass are the only types i can think of
there are preconditions iirc
what's that
actually, nvm, i don't even have my custom blocks part done yet so it wouldn't really matter
do you know what's the protocollib packet for when a blockstate updates?
or like in the render distance or whatever
you actually solved probably a problem i had
Hm? What problem.
Lets look at mojangs grass_block.json
{ "parent": "block/block",
"textures": {
"particle": "block/dirt",
"bottom": "block/dirt",
"top": "block/grass_block_top",
"side": "block/grass_block_side",
"overlay": "block/grass_block_side_overlay"
},
"elements": [
{ "from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 },
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "east" }
}
},
{ "from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
}
}
]
}
Pretty sure the coloring is handled with the "tintindex" property
yeah i know
my quesiton was on how to make it colorable with every color, and also how to know what color i should use
what biome i should use*
no idea. Just dig through the json files and see how its done in vanilla 😄
alr, can you help me with the packet thing doe?
coloring the texture of a grass block with a specific color and get the same result like the mc-client
Which operating system is the best for hosting minecraft servers?
Ubuntu 20.04.3 (HWE) LTS minimal
Ubuntu 20.04.3 LTS minimal
Ubuntu 21.10 base
windows 10 bro, i gotchu
Each material has a base color which is multiplied by 135, 180, 220 or 255, and then divided by 255
keep that in mind too, so there isn't infinite colors to choose from
related to me or smth else ?
its not an alpha mask
Ubuntu LTS minimal best. Don't use a lot of snaps tho
Hi im new, im having a problem with getting the custom name of a chest. When i create it and set the custom name to DeathChest it sets properly (i corroborate that using playerSendMessage(chest.getCustomName()) ).
But when i go and try to break it (i make another playersendmessage) that says me the custom name of the chest its null, i can send the code if its necessary
when you break it ... when do you try to send the msg ?
before it was breaked ... as item ... before it broke
and i think that the only way to set a unic data of the chest is setting a custom name
PersistentDataContainer ^^
how can i do that?
?pdc
not exactly completely related to spigot, but I cannot find a good guide on making a nuvotifier listener plugin (preferably, for bungee)
their support seems to have closed down to people asking for setup help
is there a way to get the servers.properties config file without resorting to finding it in a directory?
what do you want to find from the server.prop ?
I don't want to find, I want to write
what do you want to write ?
if you change smth in server.prop it only affects the server after a full restart
I cant set a customTag to a chest neither to a block
I'm already handling everything required to parse it up to the point where I just want to write the value
just wondering if there's a method to get that config directly or if I have to go do more directory crimes
since a chest is a tile entity you can...
DedicatedServerProperties var1 = var0.getProperties();
found this one
var0 is ServerInterface O.o
uh
so its in nms
its not that deep in nms ... just CraftServer::getServer::setResourcePack(resourcepack, hash)
any depth would rule it out for me, I don't use any nms
what i tried to say its that when i put chest.SetCustomTag that method doesnt exist
1.18.1
how?
thank you, i will try it
Does anybody know what the license of spigot is? I asked this question e few days ago, but couldn't find anything
anyone know how to make a bungeecord nuvotifier listener?
cuz for spigot, I'm pretty sure I can just use the votifier api
but I'm a bit unsure for bungeecord
probably on the webpage ?
what would be the best way to wait till a chunk is loaded before teleporting a player?
Where? I can't find it
mit?
?stashh
?stash
did someone ever tested what BlockFaces exist ??? i feel like it should have also the 3x3 cube filled in the middle
this are the options that i have when i try to set a PersistentDataContainer:
setMetaData
SetCustomName
setData
setType
setBlockData
setLock
setLootTable
setSeed
Which should i use?
I know
thats not the pdc
Where can i find this?
dunno
in the stash bukkit is GPL and craftbukkit is LGPL
but i dont see anything in spigot
is this something to wait till a chunk is loaded before teleporting a player?
CompletableFuture.completedFuture(location.getChunk().load()).whenComplete((b,t) -> target.teleport(location));
Chunk loading is sync on spigot
your probably not forum-proven or smth
verified*
hello I do rtp command and how to do player tp on ground, I'm tp on the sky
(i'm french sorry for misspelling)
I do Block.getHighestBlockYAt() ?
It says world
What is the license for spigot? @sullen marlin Sry for pinging
i want to create custom enchantment using spigot, can they be obtained using the normal enchanting table?
Depends how you do it
no
I don't think so
not automaticly
is there any way to make that possible?
EnchantItemEvent
EnchantItemEvent and add some of yours too
How does it make you able to add custom enchants?
thx
You add your custom enchants to the getEnchantmentsToAdd map
what is that?
What is what
the getEnchantmentsToAdd thingy
Have you clicked the link?
But that would like add your enchant to some existing one, right?
or instead of
Do you not see the method labeled “getEnchantsToAdd”
yeah
@spiral light thanks for your help, i watched a video about PersistentDataContainer and i undertood it
i'm just trying to load a chunk and wait until its loaded before teleporting a player
But i cant understand what that does because idk english very well lol
You don’t need to wait, your code will be blocked until it’s loaded
It returns you a map, which you can modify
Because it’s sync
sorry for the stupid question but...what is a map
?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.
It's a Java data structure
Key - Value based
it teleports a player which kinda falls in the void
Key is enchantment level and valuse is the enchantment
well player.teleport will automaticly load the chunk ^^
actually its vice versa
How to pre-generate chunk?
do you understand what i mean with the player floating in the air and falling in the void until the chunk appears?
i'm looking to avoid that
so i think i need a delay or something
its mostly a problem because of your connection / slow server
possible
is there a way to stop animals following wheat
in an event
without nms
i dont want ppl making mob farms 😂
kill mobs that have players in range with wheat in hand
🥺
if you block following by wheat - what about leashes ?
I believe you can block it via the EntityTargetLivingEntityEvent
i have nothing
when I write World. I have : Environement, Spigot and class
not getHighestBlockYAt()
It’s not a static method
so how I write the method ?
what world do you want to find the highest Y for?
overworld
You know there might be more overworlds than one?
yes
okkk
hi
is it possible to get a empty bucket's ItemStack data when i fill the bucket?
elaborate please
any idea why BlockExplodeEvent its not working?
i only code 1 if in the event.
if(event.getBlock().getType() == Material.CHEST){
event.setCancelled(true);
}
and i put tnt next to the chest and it explodes
how I get the coo of the player ?
getLocation
Why would the block be a chest
its an example
what?
event.getBlock gets the block at the source of the explosion
Do you want to make chests not explode
aaaah okey
exactly
Remove all chests from event.blockList
