#help-development
1 messages · Page 1788 of 1
ohh i thought it was someone's discord name
wait so they took spigot , changed it a bit, called it theirs ?
They can't call it fully theirs
since some of the optimizations can impact the gameplay
No spigot updates = paper death
ohh i see
lol
wait they can just take over it then
👀
yes, since its open source
Well they would continue spigot but that's more work to do
yeah true
Bukkit and spigot
It's all in MD hands
He has to update bukkit so spigot can be updated
damn
Fork chain is crazy in minecraft: CraftBukkit -> Spigot -> PaperMC -> Tuinity -> Purpur <-> Airplane?
Purpur = purpur and airplane
Airplane has its own purpur branch
No fucking sense but it exists
well purpur includes airplane patches
there's some contraversy behind that
but afaik it was solved
Airplane includes purpur patches in a branch
It's paper part
damn
honestly Both Purpur and Airplane should be merged into PaperMC
purpur follows a way different goal than paper
i hate seeing bunch of forks popping up which do include patches from other forks
Purpur has gameplay changes mostly
what does it change ? i mean like what ?
It replaces tons of plugins
It's all configurable
Why doesnt this work in the set display name?
"&4Condenser Wand\n" + "&a&lRight click &l&4on a chest to condense items inside!\n" + "&a&lRight click &l&4in air to condense your inventory!"
Afk system, mob riding, compass
:o
display names do not have multiple lines
Flying squids
for example by using Purpur you can make pickaxes break mob spawners with silk touch without any plugins
lol actually cool
ohh i see
that's nice ig
damn
Airplane community is a bit toxic. I've came into their discord only to get told to get fucked
LMAO
well at least that was my experience
joins the discord
You also need to pay for their profiler
what's that
I mean it is a nice business model
analysis tool which makes tracking down lag problems easier to do
yea spark is great
i see that could be interesting for a bigger server ig
which probs can create theirs ?
lol
spark does not have live updates
Well
true
Who needs that pff
has its advantages
i think making plugins is also a good business model
No
if you wanna make money from** minecraft**
You can't live from it
also that depends on where u live uwu
nvm i dont think u can
but like having multiple plugins that sell monthly and you only have to update (idk if that's an easy thing) sounds good ?
Maybe
no its really not
ok then am wrong
plugin should only be for enjoyment
But we use GPL license
never for money
you wont earn a lot
and also you'd probably have more stable income working for a server anyways
yeah am still just talking about it i wont do it cuz i dont really care to get money from selling plugins
money should only be motivation for plugins
i only get motivated when i dont get error like this xD
Follow GPL or Richard stallman will come to your house
public class ClimaticExpansions extends PlaceholderExpansion {
@Override
public @NotNull String getIdentifier() {
return "Climatic";
}
@Override
public @NotNull String getAuthor() {
return "Fragment./Adri752";
}
@Override
public @NotNull String getVersion() {
return "1.0";
}
@Override
public boolean canRegister() {
return true;
}
@Override
public boolean persist() {
return true;
}
@Override
public String onPlaceholderRequest(Player player, @NotNull String params) {
if(player == null) {
return "";
}
if (params.equals("heat")) {
return PlayerHeight.getHeat();
}
return null;
}
}```
Hey! could anyone tell me if am missing something in this papi code?
If you are really experienced then you can get positions where you get paid 15$/hr for 40hr/week.
If you really really want to then you can make a living out of it. Add giving java courses and some freelancing to it and you
might even be able to make a half decent living. But at that point you are better off as a software dev
making twice that amount...
lowercase on identifier
Yeah but I was talking about spigot plugin selling
Working on a server is totay different thing
fuck me
my cat fur is stuck inside my mouse sensor
and i cant scroll properly anymore
and i don't have proper screwdriver
Oof rip
Just confirming why do the "pre" updates not contain bukkit, and other src for the API? Like the jar is basically only craftbukkit but installs the libraries elsewhere.
because a) that wouldn't be an issue if you used maven, gradle, or any other sensible build system; b) that wouldn't be an issue if you used the API not NMS; c) Because Mojang did it and it's not a terrible idea
I'm trying to use the API xD
then depend on spigot-api not spigot
Spigot-api can be found in Spigot/Spigot-API/target; your local maven repo; or our nexus instance
I don't use dependency managers.
silly, but I Just listed 3 locations with the jar for you
And I'm looking them up lol. A link would be easier but meh.
?maven
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
So that being said... Does that mean the jars won't contain bukkit instance even in the stable release?
I don't like "Building" my plugin every line of code I want to test.
if (player.getLocation().getY() <= 50){
player.sendMessage(warningMessageUp);
scheduler.runTaskTimer(plugin, () -> {
setCold(1);
}, 0, 20 * 10);
}```
i have this code
but when i get to Y 50 i don't recieve any message
(I have specified the warning message), could anyone help me?
what about when you get to y 49
is not an event
what is it then
you dont even call the method
well what is calling coldAndHeatSetter
that seems inefficient
everytime you move, not even on the x, y or z axis but on pitch and yaw it creates a new task.
Ugggg the spigot-api jar don't contain all the classes I use either.
you can use -shaded to have the api dependencies included
I'm using the shaded jar
what is missing
ok, so should i make an arraylist so when a player gets to Y 50 he gets the event only once but when he leave the Y 50 it stop?
WorldServer, JSONObject, IBlockData, NBTTagCompound, GameProfile, CraftMagicNumbers, BlockPostition, CraftBukkit Apache libs
There is probs more but this is what I'm missing in one of my latest version plugins.
that's not api
that's nms
you just told me youre trying to use the api
' because a) that wouldn't be an issue if you used maven, gradle, or any other sensible build system; b) that wouldn't be an issue if you used the API not NMS; c) Because Mojang did it and it's not a terrible idea
'
I thought with mojang mappings internals are now api 🙂
' I'm trying to use the API xD
'
runs
NBTTags are api.
wat
..........................
they are not
The others not so much.
Ok this has to be said then lmfao.
You complain about us not using the API but you just said a huge part of the itemstacks aren't in the api....
which part
NBTTags
nbt to do what?
The nbt tags are represented through sensible api contracts
Store data on the item.
Example I store ints in NBTTags for how much health/hunger an item has so when placed I Don't have to have that data stored in a config.
declaration: package: org.bukkit.persistence, interface: PersistentDataHolder
?pdc
Thats makes it easier in future versions.
therefore modifying default tags using this PersistentDataHolder is impossible.
That part is kinda annoying though.
I'm still not understanding why the spigot jar just doesn't contain all this like it has for the passed... 8 years?
' because a) that wouldn't be an issue if you used maven, gradle, or any other sensible build system; b) that wouldn't be an issue if you used the API not NMS; c) Because Mojang did it and it's not a terrible idea
how do i handle backend web authentication
because a) that wouldn't be an issue if you used maven, gradle, or any other sensible build system
Would still have these issues lol Like I said already using the shaded jar.
that wouldn't be an issue if you used the API not NMS;
I use NMS for supporting older versions.
Because Mojang did it and it's not a terrible idea
It is though.
a) you wouldn't; b) well this doesn't affect older versions; c) that's like your opinion man
What do you mean I wouldn't I just proved to you I am LMFAO
but you're not using maven, gradle, or any other sensible build system
stop using the manual way
you're using eclipse projects
go through every class and run javac
Yeap 😄
Oh would you look at that. Still missing classes. Who would have thought that using maven wouldn't fix a damn thing.
did you just depend on the actual jar file on the system
like, an actual system path
hardcoded
deadass if he did that 💀
seems like it 😂
that again is the api
you are trying to depend on the implementation are you not
in which case you'd depend on spigot instead of spigot-api
and every other library as well
which is automatically installed by build tools into your local maven repo
this is the downside of not using a dependency manager
I've tried both. And they are both not containing the classes I use from 1.17
doubt it
did you run buildtools with remapped?
i had this issue before
its cause there was a jarinjar loader thing
the spigot server version installed in your local .m2 contains the expected layout
and you have to use -remapped to get the stuff in the right place
nope One sec
yeah try that
cause if u run without remapped for me at least
its the jarinjar strategy
but when you run with remapped
it exposes the inner jar stuff
do you even have to tho ? I just ran a clean install and the not remapped jar looks usable as well
does your not remapped jar look like the image
it does not
then thats why
Yeah, thats without --remapped
made it so that if you cant create tag twice and cant delete non existing one :D
progress
It's rather strange. I don't understand why for some people it works and others it doesnt
for emily it worked
but if u go onto spigot forums
someone also experienced the same issue
and had to run remapped in order to get the proper structure
I'm not sure why
🥲
Yeah
Ah sweet, yea then you wouldn't even need remapped if you don't want to jump into special source
makes sense
got the same jar
java -jar BuildTools-#138.jar --remapped --rev %Input%
hmm
i mean when i ran it i put remapped as the last arg but that shouldnt matter right
again, the jar copied by buildtools will be the bootstrap jar
the raw jars are in the Spigot/Spigot-Server/target folder
And also check your .m2 folder too
and the spigot jar
and see if its like that
the bootstrap jar is really meant for server owners
Yeap its in the .m2/repo
Even using that jar I'm still not able to use Bukkit imports.
because that jar only contains craftbukkit
you need to depend on spigot-api and spigot separately
as well as all their libraries if applicable
again, this is why Maven/Gradle exist
You know I wanna try making an anticheat but I have never played with packets before so this would be interesting
otherwise extract the entire META-INF folder of the bootstrap and depend on every jar there
Thats a fucking bitch to do. Even with maven and gradle. I can't just depend on 1 jar anymore.
No I would still have to add all the depends that aren't in the spigot api. JSON etc...
🤦 read your last few messages
'otherwise'
I think I know more about maven than the guy that uses eclipse projects
just sayin
I use maven for shading. Thats it. Don't need to waste time building my plugins
Which one do you guys recommend using protocollib or packetevents by retrooper
Also added spigot and spigot api to maven depend.... Still have missing imports.
So far 1.18 is a joke and just makes it even harder to support future versions.
protocollib is more expansive
packetevents afaik uses tinyprotocol
which was developed by the comphenix (the same protocollib dev)
who would've guessed
so they are both good?
You know what's makes spigot easy to support? When the author doesn't screw up the api every major update ;)
PacketEvents seems to be more focused on more NMS injection while protocollib relies more on the reflections for backwards compatibility
hm
ProtocolLib is more abstracted while PacketEvents are more on the raw side of packet handling
🤦 I can't even use Bukkit.broadcastMessage()
At this point are you not even reading my messages?
what do you expect from prerelease builds
if you depend on the build server implementation you basically have no classes whatsoever.
you are depending on a bootstrap jar
that later on extracts all libraries and resources inside
is anyone willing to make me a few small plugins? i cant find any with 1.8 support.
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
the API contracts haven't changed, you are just depending on a boostrap jar
its possible to build paper/spigot without spigot api bundled in?!
Nope already discussed this. I have tried that jar, the snapshot jar, the shaded jar, the remapped jar, the maven repo jar, the spigot api jar and the spigot jar.
then you failed somewhere down the line ¯_(ツ)_/¯
I am testing an example setup right now and it works great
of course lol
IDE doesnt output you more errors if its done correctly
yeah please dont suggest another ide, its not helpful & the issue isnt the choice of ide
You clearly have never setup a Forge project 
switch to nano
I didn't because I use fabric
Smart
gn everyone
So for us server owners, what's the deal with this new bundler/bootstrap thing? How does it work and what is its purpose?
if you are a server owner it doesnt really matter
It shouldn’t really matter (hopefully)
but the main reason is because of JDK encapsulation with URLClassloader class
in english
which caused JAR loading to be harder. And a new strategy called jarinjar loading (with a bootstrap class) is the fix to load libraries at runtime
JDK encapsulation with URLClassloader
I don't even know what that means.
Is this necessary because of Java 17?
Seems more complicated to me.
yeah but it means that the library jars are actually used as-is rather than modified
but also as with everything its a trade-off
if we retained the old style spigot jar people would yell and say that was the wrong move too
Mojang
OK. Just trying to understand the change.
it basically makes the server jar a launcher like the client has
are you a developer? lol
I have seven plugins on SpigotMC, one of which is used by 300 servers with 1000 players.
But I don't use NMS.
I have one plugin on SpigotMC used by PulseBeat 
👑
Ooh, he asked a question and I answered.
Sorry for asking that XD. It's never bad to understand smthing
Btw Pulse
Whats pulse
Have you started unit testing?
Yes
m e
The guy that just said Yes
Yes
:o
hope you’re not testing every function
Even tho people like bob asserts it’s the right way
U own big server ?
!p
no
Cuz you actually wanna test behavior and not specific classes
Yeah
!paste
?paste
Don't test for error conditions you don't know how to handle. 🤓
assert meta != null
can u guys take a look at the 39th period
i want to control the situation that the player closed the inventory screen
Testing classes would be unit testing. Testing behavior would be functional testing.
They each have their uses (as does regression testing).
imagine testing things
Yeah, was probably just talking about tdd in general, I mean sure unit tests can be good to verify your code does not do the wrong thing. But surrounding every function of every class is a bit excessive, since impl details change and then you’ll end up with a lot of broken tests. 
world gen - are 'mountain' biomes in 1.18 renamed to peaks?
windswept
this one I assume?
is that from the wiki?
ye
ty
spigot supports those renames at runtime
packetevents
hmm, I am getting a strange error with buildtools?
fatal: invalid branch name: init.defaultBranch =
applyPatches.sh: line 16: cd: /c/Users/admin/Downloads/118Server/Spigot/Spigot-API: No such file or directory
Resetting Spigot-API to Bukkit...
fatal: ambiguous argument 'origin/spigot': unknown revision or path not in the working tree.
...
Resetting Spigot-API to Bukkit...
fatal: ambiguous argument 'origin/spigot': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Applying patches to Spigot-API...
fatal: could not open '../Bukkit-Patches/*.patch' for reading: No such file or directory
Something did not apply cleanly to Spigot-API.
Please review above details and finish the apply then
save the changes with rebuildPatches.sh```
i might be doing something stupid. I am using git bash inside the same folder as the buildtools latest jar
i did
ran this cmd: java -jar BuildTools.jar --rev 1.18-pre5
maybe I'll try another machine
what is fatal: invalid branch name: init.defaultBranch =
not sure
seems like you mightve broken your .gitconfig?
(Also you should probably be building pre-8 now)
dam we on 8 now?
oh we on RC1.. i just read the new post like 1-2 days ago I thought
Just checked, not yet
ok i missed 3 pre-releases in 3 days
wait I even clicked the spigot post after it got updated to pre-8 when spigot mapping stuff got mentioned in #general
He got the cloning machine working
human.clone()
yep, that's what it was.
I fixed it by running the command git config --global init.defaultBranch main
I should say I found a few people earlier this year who had the same problem, but never found a solution.
Maybe this should be added to the issue solutions list?
how do i get rid of the top box hanging over
make them the same width? lol
yeah i had to use pt
this is impossible to tell you without seeing the website
cross platform solution
how come?
because protocollib has a lot of resource usage
Quick question is better to make the plugin from latest version and support everything below it or start from below and support upwards?
I think if you put api-version: 1.17 in plugin.yml, servers older than 1.17 won't be able to use it.
I've been stuck for like 2 hours trying to get something to work now.
Basically I want the tab suggestion for /msg to show all players on a BungeeCord proxy, not just the ones on 1 particular Spigot server. I have been trying to do this using a BungeeCord plugin by just simply creating a command and defining a custom TabExecutor response. The problem is that BungeeCord does not seem to override the tab complete response, but it does override the command's functionality. Is there any workaround to get this to work as I intend?
Would appreciate any help!
How would I go about loading a pre-built building
Ie: I build a house and when I run a command the house is pasted in (like world edit but prebuilt buildings)
if (cmd.getName().equalsIgnoreCase("anvil")){
Inventory Inventory = Bukkit.createInventory(Player, InventoryType.ANVIL);
Player.openInventory(Inventory);
}
i'm trying to make a /anvil command. the ui shows up and stuff but you can't actually enchant anything. how would I make it to where you can enchant items?
worldedit api
Would it be smart to cache the players data then to call it through api everytime?
Depends
What does the API do to get them
If it's just getting it from collections then it's probably fine
Structure api
What about it
Oh for importing structures
I still have to have to a look at that API
their uuid and player
Oh lord
The anvil logic isn't in the GUI itself sadly
Also please please please name your variables in lower camel case, having a variable called Player with a capital P is very bad
Hey so whenever you hover over water with creative its seems to be detected what can I do to fix that? ```java
if (packet.isPosition()) {
final List<Block> blocks = ReflectionUtils.getBoundingBox(profile.getPlayer()).expand(1, 1, 1).getBlocks(
profile.getPlayer().getWorld()
);
final boolean check = blocks.stream().noneMatch(block -> block.getType() != Material.AIR && !block.getType().toString().contains("WATER"))
&& blocks.stream().anyMatch(block -> block.getType().toString().contains("WATER"));
if (check) {
if ((ticks += 2) > 10) {
final double prediction = data.getLastDeltaXZ() * 0.8F;
final double difference = Math.abs(data.getLastDeltaXZ() - prediction);
if (difference > 0.04 ) {
if (increaseBuffer() > 15) {
fail("diff=" + difference);
}
} else decreaseBufferBy(Double.MAX_VALUE);
}
} else {
ticks -= ticks > 0 ? 1 : 0;
}
}
if im using Material mat = Material.valueOf(args[0].toUpperCase()); how can i check if the material is actually a material and not something like "jad8jasjd"
iirc valueOf throws an exception
better to use something like .matchMaterial and just check if returns null
if (Material.matchMaterial(args[0].toUpperCase()) == null) { isnt detecting if the material doesnt exist
it should though I dont think the uppercase is necessary
still isnt
so you're saying jad8jasjd returns a valid material?
Have you thought to see what it is..
cause its just a lookup in a map which is cached from Material.values() so it definitely wont return a valid material
after if (Material.matchMaterial(args[0] == null) { i have it send a message to the console and it doesnt
Yeah you are missing a )
if (Material.matchMaterial(args[0]) == null) { still isnt working for me :/ args[0] = "diIJjxwijd37d"
is there an event for when a shovel is used to change grass to a dirt path
what else?
Use the interact event
ty ill check it out
im rly confused...
for (Material m : mats) {
if (m == mat) {
p.getInventory().addItem(new ItemStack(mat, i));
}
}``` why am i not getting the item? args[0] = "dirt" but when i do something like args[0] = "djajdjsad" i get an internal error but if i do a real material name nothing happens
Material#matchMaterial
ive tried that as well but had an issue ^
Material doesn't produce an array, why are you looping thru it?
why are you event trying to loop mats?
i have an array with every material
is mats a list of permitted materials?
im looping a list of every material and args[0] to see if they are = since Material.match isnt working
it still isnt detecting if the material isnt real
mats.addAll(Arrays.asList(Material.values()));
if (mats.contains(mat)) {
p.getInventory().addItem(new ItemStack(mat, i));
}
else {
p.sendMessage("material does not exist");
}```
You are making a List of ALL materials
Even better, use a set
bump
yes?
im detecting if the material exists wdym?
Material mat = Material.matchMaterial(args[0]);
if (mat != null) {```
^ I have no idea how you were not getting null using that
Unless you are using some kind of cursed hybrid server
welp it works now idk why it wasnt before but thanks
Next time: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
All java primitives are by value so they will always 'clone'
boolean b = a; // clone a
Most events are before
So right now I want to create a clan plugin that is working on multiple server instances, and now I know how to use the basic jedis, the question is when should I load and save the clan data?
any time it changes
In my mind, I load all clans data and cache it on startup, check If the clan data is already on Redis or not, If it's not on Redis I load it from the MySQL.
Use redis for messaging, not storing
Messaging like what?
like bungeecord plugin messaging..?
Because thats still somehow slow? You also have to serialize and deserialize everything all the time
And redis suck as storage
But it's quite simple I would say
public void loadClanStats(){
try(Jedis... ){
int balance = Integer.parseInt(jedis.hget("key", "field"));
}
}
public void saveClanStats(){
try(Jedis... ){
jedis.hset("key", "field", "value");
}
}
Sure
So how you would suggest If I want to sync the data every server at all times.
When any update happens, you send a message to all other servers so they update data aswell?
How do you notify the other server?
Can you make an event in redis? just like EventHandler in Bukkit, where If I send a message, the other server can receive the message?
I don't know how the other server can receive the message everytime I send a message.
Yes
Read redis docs
Is it the pub/sub?
subscriber and publisher, yes
oh okay, that's very useful
is Maven or Gradle better?
maven
Okay so, is this correct?
Subscribe to specific channel, and then the publisher will send a message for example the clan uuid and set a data using Jedis#hset, and then the subscriber will listen to the message and get the data using Jedis#hget.
Apparently gradle is faster when it comes to a multi module project
But maven is probably much more stable as it has been around for a longer time of period
thus I’d say a lot of plugin devs are also used with it so therefore more supported in the spigot community 
I believe there’s a gradle plugin which solves it for gradle users also?
Haven’t seen anything other than some GitHub repos
Nothing talking about one directly
tbh its simple enough some sort of exec(..) in gradle could probably do it
gradle
faster and much less verbose
There's a tool for gradle but i think its not allowed to mention it here
Yo aglerr ever checked out redisson
redisson
https://github.com/redisson/redisson here in case you haven’t
Way more sophisticated than Jedis
And yes it has a pub sub
what's the different with jedis?
Ridiculously more features I’d say and better engineered.
okay, i'll check that out
but is this the correct way?
Yeah, well its my personal goto when it comes to redis with java
I don’t know I actually haven’t used Jedis since a very long time
Let me take a peek
Oh yeah
JedisPool::getResource
then use Jedis::subscribe
yeah, i think i'm gonna stick with jedis for now
i never actually used redis, so i'll get more comfortable first
I’m still surprised a lot of spigot devs use mainly redis as a message queue and message broker
and with data synced every server, i just need to load/save on startup and disable right?
Ah
I just feel like when it comes to message queues, there are simply way superior alternatives
spigot 1.18 when coming
How’s your current design?
I’ll review it based on your description

?1.18
There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
Okay, when server startup it will load all data from mysql, and cache it on the memory, and then update the local cache from the message that is sent thru redis pub/sub, and on server stop save the clan to mysql.
But I found a problem, when the data has not been saved on the mysql yet, the servers will have different data.
no
Or just a normal hashmap or smtng?
yeah hashmap
Hmm sounds somewhat dangerous
the hashmap, or the design?
Design
I mean loading the clan data seems fine (in the start)
But you might just want to rely on the redis cache
As redis has its own "hashmap"
store everything on the redis?
So no local hashmap
manya says it will be slower
No not everything
A little but redis is fast
Ridiculously compared to mysql or smtng
what should i store?
Because the problem is
You can end up with something I refer to as the synchronization problem
Let’s say you do in fact use redis pub/sub in combination with a local map instance in every server
yeah there will be a synchronization problem, i can see it
Server 1 clanA balance = 1
Server2 clanA balance = 3
Server1 clanA balance increased by 1, so 2
Server2 clanA balance will be 2
Now at timestamp 20:00
Server A mutates the clan name and sends the update (with pub sub).
At timestamp 20:01
Server B mutates the clan name and sends the update.
However for some reason server B was able to send its update such that it completely reached server C, A, Proxy and D at timestamp 20:02.
But server A got its update reached out at timestamp 20:03 to C, B, D and Proxy.
Now those servers will float around with invalid data
one way is to ofc include a timestamp in every message you send with pub sub
And handle conflicts as such
hmm, so how would i do it?
Another way is to completely rely on ONE cache like redis’s cache
Third way is to use a lock service, like hazelcast
Well you decide
never heard of hazelcast, i think i'm gonna stick with redis
Yeah, try the first way
if (e.getBlockPlaced().getType().equals(Material.WHITE_TERRACOTTA)) {
player.getInventory().addItem(new ItemStack(Material.WHITE_TERRACOTTA, 1));
BukkitScheduler blockTimer = Bukkit.getServer().getScheduler();
int o = blockTimer.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Block block = e.getBlockPlaced();
e.getBlock().setType(Material.YELLOW_TERRACOTTA);
if (block.equals(Material.YELLOW_TERRACOTTA)) {
block.setType(Material.ORANGE_TERRACOTTA);
} else if (block.equals(Material.ORANGE_TERRACOTTA)) {
block.setType(Material.RED_TERRACOTTA);
} else if (block.equals(Material.RED_TERRACOTTA)) {
e.setCancelled(true);
}
}
}, 10,5);```
uh whats wrong with this code
It only works fine for transfering WHITE_TERRACOTTA to YELLOW_TERRACOTTA.
use == to compare enums.
also you're comparing Block with Material
it will never be true
hmm ok
So you would want to get the type Block#getType
i'll let you observe the code first
Sure thing
i have invited you btw
Link me, I’ll accept it through the link 😅
not working either
show your code
the updated code
change the top if condition too with ==
so you want to change the block type every 0.25 second?
exactly
im using a scheduleSyncRepeatingTask
Don't cancel the event in the repeating task like that
Also make sure to stop the repeating task or your server will die
all of those e.setcancelled are ```java
e.getBlock().setType(Material.AIR);
404 =-(
it is not public, you want to see it too? i can add you no problem
what should i do for that however...?
Data Synchronization across servers with Redis
BukkitScheduler blockTimer = Bukkit.getServer().getScheduler();
int o = blockTimer.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Block block = e.getBlockPlaced();
e.getBlock().setType(Material.YELLOW_TERRACOTTA);
if (block.getType() == Material.YELLOW_TERRACOTTA) {
block.setType(Material.ORANGE_TERRACOTTA);
} if (block.getType() == Material.ORANGE_TERRACOTTA) {
block.setType(Material.RED_TERRACOTTA);
} if (block.getType() == Material.RED_TERRACOTTA) {
e.getBlock().setType(Material.AIR);
}
}
}, 10, 5);```
I tried this but this will remove the block instantly
Of course, the process is fast, it will change every 0.25 second.
changed it to 5 seconds it isnt even transfering it self
The block Type is set to yellow terracotta and then you check, if it is yellow terracotta. Of couse it is alway what you just set it to. All the if code will be executed and it is so fast, you won't see it. You only see the last type : air
yeah..
You should set the type to yellow before the repeating task and then use if-else or switch in the task
What is the problem here?
What exactly are you trying to achieve 🙂
it transfers WHITE_TERRACOTTA to air instantly
Wait, but WHITE_TERRACOTTA isn't even in there?
if a player places a WHITE_TERRACOTTA
so the block should change it color every 0.25 seconds until it reaches to RED_TERRACOTTA and then it should be air
because i didnt showed the complete code
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
Player player = e.getPlayer();
if (e.getBlockPlaced().getType() == Material.WHITE_TERRACOTTA) {
player.getInventory().addItem(new ItemStack(Material.WHITE_TERRACOTTA, 1));
BukkitScheduler blockTimer = Bukkit.getServer().getScheduler();
Block block = e.getBlockPlaced();
int o = blockTimer.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
block.setType(Material.YELLOW_TERRACOTTA);
if (block.getType() == Material.YELLOW_TERRACOTTA) {
block.setType(Material.ORANGE_TERRACOTTA);
} else if (block.getType() == Material.ORANGE_TERRACOTTA) {
block.setType(Material.RED_TERRACOTTA);
} else if (block.getType() == Material.RED_TERRACOTTA) {
block.setType(Material.AIR);
}
}
}, 10L,50);
}
}
That makes a lot of sense lol
Let me walk you through what's happening atm
First the player places WHITE_TERRACOTTA right
yeah
Then we go inside the run method of the scheduler
It first changes it to YELLOW after 10 ticks
That makes sense, since the if statement comes right after changing it to YELLOW
well you set the block type to orange terracotta and then instantly check wether it is orange
so it will always immediately go into that if statement
do it the other way around
check for red first, then orange, then yellow
that should work
I think i can use map to save that block so i can create another if out of the scheduler and check if that block is orange and then another scheduler
@Override
public void run() {
switch (block.getType()) {
case Material.WHITE_TERRACOTTA:
block.setType(Material.YELLOW_TERRACOTTA);
break;
case Material.YELLOW_TERRACOTTA:
block.setType(Material.ORANGE_TERRACOTTA);
break;
case Material.ORANGE_TERRACOTTA:
block.setType(Material.RED_TERRACOTTA);
break;
case Material.RED_TERRACOTTA:
block.setType(Material.AIR);
cancel(); // We cancel this scheduler, since we're now done
break;
}
}. 10L, 50L);
This is basically what you want to do
that is also a good solution
woa right i forgot switch lol thanks
no worries 🙂
might also wanna add a default to cancel the task
very good point
in case the block gets broken in between or something
always smart to do, to prevent weird memory leaks
this.cancel?
thats not working too
Make it a BukkitTask
Give me a sec, I'll write it out in IntelliJ to make sure it works
it is a bukkit task
int taskID = Bukkit.getScheduler....
and then cancel with the taskID
or does that also not work
Are you trying to cancel inside or outside or both?
inside the switch case which is inside the Bukkit task
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
switch (block.getType()) {
case Material.WHITE_TERRACOTTA:
block.setType(Material.YELLOW_TERRACOTTA);
break;
case Material.YELLOW_TERRACOTTA:
block.setType(Material.ORANGE_TERRACOTTA);
break;
case Material.ORANGE_TERRACOTTA:
block.setType(Material.RED_TERRACOTTA);
break;
case Material.RED_TERRACOTTA:
block.setType(Material.AIR);
cancel(); // We cancel this scheduler, since we're now done
break;
}
}
};
runnable.runTaskTimer(this, 10L, 50L);
what
Should use a BukkitRunnable
just store it as a BukkitTask then
iinside
You can just use a BukkitRunnable Gameisntover, the code I sent works
oops i used BukkitScheduler
Yeah, that doesn't allow cancelling right from the run method
BukkitTask task = new BukkitRunnable() {
@Override public void run() {
this.cancel();
}
}.runTaskTimer(this,10L,50L);
or
Bukkit.getScheduler().runTaskTimer(this, task -> {
task.cancel();
},10L,50L);
?scheduling I wrote this not too long time ago in case of any future references
Asking this question again as it got burried:
How would I go about showing all players on a BungeeCord network in the player tab-complete in things like /msg <player>. I've tried overriding the command using a Bungee plugin, but Bungee plugins only seem to override command functionality for natively existing commands.
One solution I came up with is just sending fake PlayerInfo packets to every single server on the network to simulate them being online in that particular Spigot server, but this seems suboptimal.
you could use plugin message channels maybe?
or if you got something better, a redis cache, or even some message broker could do
I use Redis as my plugin message channel basically, so I could use that, but also seems inefficient to request the full player list from the Proxy on every single tab complete action
yeah this
?1.17
Install 1.17 with BuildTools: https://www.spigotmc.org/wiki/buildtools/
I could use the message channel to broadcast to all servers when a player joins the network and then let those individual servers spawn a PlayerInfo packet, but I feel like I'm overthinking this
no no no
you'd cache it
so only on a server instance startup would you request all existing players on the network
and then on every player join / leave of the network I send a notification to remove (or add) one player from that cache to all singular servers?
yes
idk why you'd use redis as a mq, but Ig it works (would recommend rabbitmq or kafka if you got access to those)
I am using Proton: https://proton-1.gitbook.io/proton/
Which basically either uses Redis or Rabbitmq
just cross-server messaging without the hassle of BungeeCord's native system where you need at least 1 player on a server etc.
On Single Server Shutdown -> Send bulk update
On Single Server Bootstrap -> Query update
On Player Join -> Send update
yeah
well using player connections was a clever yet limiting implementation detail
(and on Player Quit -> Send update) but gotcha
yuh that too lol
then idk if you have 1 proxy or multiple proxies and one super proxy
Just using 1 proxy right now to keep stuff relatively simple
hmm alright, arguably you let the proxy be the only one which sends the leave/join updates
Yeah that was what I thought you meant haha
oh yeah, just to clarify 😅
I see, this makes a lot of sense (as I also cache other stuff this way), but I thought there might have been a way to override it using a Bungee command
I'll just go with this for now, thanks a lot 🙂
yeah good luck
tyvm
hmm actually yeah there probably is
is it me or does protocollib actually make things slower to dev? I find it much faster to use NMS for packets
Tried using the BungeeCord API and two separate command frameworks for Bungee, good chance it's not gonna work :p
I think it just mostly depends on what you're used to. The freedom of using NMS will always be more than with ProtocolLib, so in that sense some things might be easier, but the trade-off of not having to deal with abstraction / reflection and just being able to rely on a library is great
yeah but even looking at minecraft's protocol wiki
i never manage to set the right values to the right fields
Jurre, you might need to send the tab complete event through packets or smtng
?1.18
There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
wait
?1.16
guess you figured that out alr tho
I tried modifying the suggestions list using the TabCompleteEvent on Bungee, but that one only listens to tab completes in Command Blocks like tf 😂
Yup, just pick what you need (don't just add in everything), and then use that
make sure to check if stuff is up to date tho, I believe some code is a bit old already
yeah exactly haha, check for that as well
ok so let's say i want to play a lightning bolt
is the wrapper weather something
WrapperPlayServerSpawnEntityWeather.java
Yeah
oh wait that's so useful
i can also see how do they work behind the scene
and what would i have to set if i didn't do it with wrappers
thanks a lot
Exactly, I use it all the time just to check if I set all the correct fields
np
random number i guess
also another thing, is there anything there for entity metadata?
i need to do some armorstand packet playing
only class i've found is WrapperPlayServerEntityMetadata but it just takes a metadata object as a parameter
so i'd have to make it myself
PrepareAnvilEvent setResult bug? item in slot 1 is replaced directly
Hi guys. In order to make an explosive arrow what should I do? Should I use the interface AbstractArrow?
is it possible to teleport a player to a location when they are near a certain coords?
yes
how would i do it using eclipse 1.8
ty
How can you turn ItemMeta into a String and back into an ItemMeta object? Does anyone have an example or explenation?
hey if you guys have 5 minutes to check my thread i will really appreciate it, since i need it done and working for 1.18 it's a bit time sensitive :c
I would like it so I can store data regarding Items and generate new ItemStacks onEnable. If there is another way to do that, I'd love to hear!
you should probably just post the thread here ❤️
1.8 spigot isnt supported
I couldnt find a way anyways
how can i spawn an armorstand with metadata using protocollib?
bump
don't be a version nazi this isn't the forge discord :/
he just said that spigot 1.8 is not supported which is true
no need to support a version many years old now
anyone?
i mean, we can still help with 1.8, but if something comes up, which needs a hacky solution but is already granted in higher versions, we should just say "update"
How can I get the game profile for a player? it tells me that the "GameProfile" class does not exist
craftbukkit
But i use spigot
and mojang lib
bukkit is built in spigot
How can i access it?
build tool dependency 🤔
if you use paper there's an easier way but i don't know how to
EntityPlayer player = ((CraftBukkit) player).getHandle();
GameProfile gp = player.getProfile();
This is weird since i used the Jetbrains minecraft plugin to generate the project
/shrug yeah but when it comes to randomly saying it for the sake of saying it
So to get those libs i need to use the buildtools?
depends what dep you're using, spigot or spigot-api
you need to use your build tool to add it as a dependency
<repositories>
<repository>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
</repositories>
<!------>
<dependencies>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>version</version>
<scope>provided</scope>
</dependency>
</dependencies>
can never remember how you call on buildtools from the bot ;-;
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Yeah, i got this
this is just spigot
❤️
how can I put in as a parameter an Entity? I can't just construct one without spawning it
yeah thats spigotapi
you can but eh, wdym what you tryna do
protocol lib or packets?
oh rip, I raw it idk
i could use nms but it defeats the point of protocollib
So what i have to do is run the buildtools and then it craftbukkit and the mojang lib to my project?
And then it should work
craftbukkit already has the mojang auth lib
little bump cause i found new things
Btw your xml didnt work
you only need to run btools if you want spigot, mojang and nms in one
Could not find artifact com.mojang:authlib
you prob. didnt change the version
i set it to 1.17
yeah no
?
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.2.38</version>
<scope>compile</scope>
</dependency>
is what craftbukkit use
So should i make it compile or provided?
provided
Got it
but if you want to use craftbukkit anyways, you can just shade craftbukkit in
craftbukkit already have it
And what about the CraftPlayer class?
thats craftbukkit
Could you send me the xml?
for craftbukkit you need to run the buildtools and put it inside your local repo
Ah so it build generate the craftbukkit jar and i will have to add it as a library?
yup
np, make sure to use spigot then instead so you also have the craftbukkit patches from spigot
I'm using Spigot
you are using the spigot-api
just the -api
Alright, thank you mate
👍
is it a good idea to do armor stand animations with armorstand packets to show them to a single player or should I hide the entity from everyone else than the player?
armor stands tend to... lag
you should use packets as much as you can working with them
cant say the same,never used it always doing my packets thru nms
it would probably be viable in my case, i don't need cross version compatibility
i still have to decide which one to use
i don't have much experience with neither of them
What’s painful about protocollib
1.8 😔
the fact that understanding how do some fields work takes years
not rly
how am i supposed to set the metadata of an entity
first by looking at examples
last i used protocollib i simply went on vg and checked what the packet had
and also if i want to have my armorstand offset how do i do it? the packet takes integers as parameters
for location
there should be one asking for doubles
Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type double exists in class PacketPlayOutSpawnEntity.
tried that
oh probably the packet changed in 1.13 or smthing
still strange, how is the client meant to see an offset armorstand if the packet takes int fields🤔
how do people have plugins which work in all the versions in the world? any tutorials on that?
to make your plugin work, u need to use only those APIs that work on the lowest version u want to support, and use reflection or sub-modules for NMS stuff
so if I want to support all versions from 1.13 to 1.17 I just need to develop it in the api that works for 1.13 and it works in all versions above?
if your are not using NMS it should work fine
seeing as I dont even know what NMS stands for that should be fine. thanks 😄
NMS stands for net.minecraft.server
packets?
yes
alright thanks 😄
but if you're using protocollib it should work fine without any abstractions or reflection
appreciate that!
i love how 90% of people relate NMS to packets :p
is there a way to avoid reflection completely?
Yes you could extract the bukkit version
yes, modules and shading
and use a switch statement
Oh i thought u were talking about something else nvm
lol
bump
First use block.getType().name() when working with Material names
Second, it detects water because you are over water. What do you expect it to detect?
well yeah
Anyone here know how to access com.mojang.serialization in the 1.18 pre-release? Can't find a jar containing it after running buildtools.
interesting
This test java final boolean check = blocks.stream().noneMatch(block -> block.getType() != Material.AIR && !block.getType().toString().contains("WATER")) && blocks.stream().anyMatch(block -> block.getType().toString().contains("WATER"));
Seems to be checking for not AIR and Not water, but also IS water?
so if the current block is NOT water and is NOT Air, but there is water in the list
Your test is extremely confusing. I don;t see how it could return true
For it to be true, there has to be No AIR, No WATER and WATER.
can you make an entity spawned with packets not despawn when it goes out of render or do I have to resend the packet?
like i store the location of all packet entities for a player and when the player walks into the chunk plays the packet again
If you spanned using packets it only exists in yoru code and on the client
if teh client delets it you have to respawn it
yea i was asking if you can force the client to not despawn it
no idea, but I doubt it
yeah same
what about this approach?
I believe the client deletes everything thats out of range
i can listen for chunk load events, check if there should be a packet entity in that chunk and spawn it
See how something like holographic displays does it
I would guess they are constantly tracking distance
any time a player moved between chunks recheck
kk thanks
I don't know why but i love going in NMS classes and finding this sorta stuff lol
this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw");
((CraftPlayer)this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)");
is it more efficient?
recomended to use as its accurate
it gives me this error but my chest size is set to 27
show code
Hello! I'm trying to set some NBT tags for my items, but it doesn't set
My methods:
public ItemStack setNBT(ItemStack itemStack, String key, String value) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound itemCompound = (nmsItem.hasTag()) ? nmsItem.getTag() : new NBTTagCompound();
itemCompound.setString(key, value);
nmsItem.setTag(itemCompound);
return CraftItemStack.asBukkitCopy(nmsItem);
}
public String getNBT(ItemStack itemStack, String key) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound itemCompound = (nmsItem.hasTag()) ? nmsItem.getTag() : new NBTTagCompound();
itemCompound.getString(key);
return itemCompound.getString(key);
}
public boolean hasNBT(ItemStack itemStack, String key) {
return !getNBT(itemStack, key).equals("");
}
If you aren't on a horribly outdated version you should use the pdc
I'm on 1.17.1
wdym by pdc
?pdc
Allows you to store custom data on an itemstack
I am guessing that is what you are aiming to do ?
well, actually yes, but can't I do it using nms?
Well ehm. Technically yes but why would you ever prefer using NMS if there is API
cause I will probably support legacy versions
bruh md_5 why did you remove apache commons lmao
just drop support for everything below 1.16
ok, but why my code doesn't work?
that’s how jesus works
if you wanna do stuff with nbt i would highly suggest using nbtapi, it's very easy to use, works from 1.8 to 1.17 and the developer always replies quickly
plus you can shade it
?
I want to change the text above a players head, tried multiple different apis, even tried scoreboards, nothing worked. Armor stands have a delay when the player moves and it looks really weird, is there a better way I could be doing this?
🤷 use a debugger or debug messages