#help-development
1 messages Ā· Page 868 of 1
xd
š š
the answer that comes immediately to mind is no
AFAIK there's a GamePhase#tick method
You can use that to your advantage
For example
If another plugin adds the same command as my plugin, is there a way to let my plugin's be the one running? (Maybe using PlayerCommandSendEvent & PlayerCommandPreprocessEvent?)
Why is there no ItemMeta#deserialize, but there is a ItemMeta#serialize? I am stuck with a Map<String, Object> that I can't deserialize
I see people talking about a deserialize method from CraftMetaItem, but I can't find that class
isn't the serialize because of config stuff
Could be, yea
ye, the serialize comes from the ConfigurationSerializable interface it seems
In your wiki, theres also a page about GameTasks
yeah I do sumn like this
The GameTask interface has a start() and dispose() method
Basically you can make your own custom logic and attach it as a task
And when the phase ends, it disposes automatically
unless you manually cancel it
Is there a way to deserialize it?
Can some one send the the SQLite documentation for java?
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how to use simple and prepared statements, stored procedures and perform transactions
I see, also, should I make two seperate lists of tasks in the AbstractGamePhase class? One for when the phase ends and one for when it cancels? Im confused as how to differentiate the onEnd and onCancel. š„¶š„¶
they both dispose the same
Is there to trigger a player into elytra mode? the player has an elytra equipped dont worry.
yep, just figured that out
thank you
at what version was PrepareGrindstoneEvent added
how can you make a region unique with the same ID in 1 world
hashcode?
why do they have the same id?
I mean, how does protectionStones, for example, give an id to a region with the same template? It seems you canāt give the same id to a region
what an old plugin
I see thanks for all the help
what kind of region are you making?
are you referring to when a player places a stone?
yes
it uses the players name and just adds a number
it uses world guards region listing
at least that is what I recall in how it worked from way back when
not sure if it has since changed or not
like - player region: {PLAYER} {ID} ?
I don't recall the world guard api, but I am pretty sure you can use it to find regions owned by a player
since regions can have owners
not sure why you need to know how protection stones works though
most of its code is just using worldguard api
the only thing feature wise it adds to it, is giving the ability to allow players to create their own regions and the ability for that to be tied to the economy
I just noticed that the names of the regions of these forks are the same, although this is impossible
as well as limiting how many regions they could create
why would it be impossible?
hm
oh how you do this
this textures?
lol
worldguard ensures regions are unique with an id
And with a little bit of math things can be done
therefore it doesn't matter if two regions have the same name
their names are id
just make a uuid
have an incrementing counter or a name pool
For waystones at a server I work at we use a name pool
With stuff like "Shadowfall" or random names
once the pool is exhaused we just add numbers
"shadowfall 2"
they are global regions
most likely
global regions are used for templating
typically anyways
yay skipping slots works
?paste
thanks!
npnp
is there a way to make a dmg for player on playerinteractevent? or I will need to code smth like spawn arrow above his head or spawn sweet berries bush and then catch the event and change this damage to bigger one?
Can someone please help me here?
I want to save the item meta of any item into a config, and then load it when they open it back up. For some reason, when i close it the first time it saves the item meta perfectually to the config. but then if i open it again after i close it, the enchantments and meta clears, and only shows a default diamond chestplate
???
ij having a stroke again?
nah it exists
I do remember there was a bug at some point
Can't exactly remember what though
experienced smth similar
What's the problem?
this captures "lang:space.18lang:space.18" on group 1
trying to optimize minimessage tags rn
I'll need to change it to support other stuff
use pineapple chat
could someone possibly help with my issue?
You seem to be doing a lot weird things instead of just storing the item
put debug statements and dont use a player object as key in any hashtable
Yea, but for some reason i can store a itemstack in the config, but i can't load it
wtf is this
ok so decompiled the jar does not have the updated library for some fucking reason it was working before
You should be able to load it just fine
so do i just do ItemStack[] contents = (ItemStack[]) config.get(locationOfContents)
I'd get a list
how can i make the obsidian explode?
so config.getList() instead?
Yeah
Alright, so im guessing i for loop it and add the items
EEEEEEEEEEEEEEEW, not using recaf
jdgui my beloved
List<ItemStack> contents = (List<ItemStack>) config.getList(path+".items");
for(ItemStack cont : contents){
if(cont != null){
gui.addItem(cont);
};
}
slow with what
Hello i have a ceratain problem with my project (it's a FORGE API) .Namely i use an forge 1.12 api and all works good on singleplayer but when i try to use a multiplayer my mod looks like completely off 0 reactions.
@Mod(
modid = Abcd.MOD_ID,
name = Abcd.MOD_NAME,
version = Abcd.VERSION,
acceptableRemoteVersions = ""
)
public class Abcd {
public static final String MOD_ID = "abcd";
public static final String MOD_NAME = "Abcd";
public static final String VERSION = "2.0";
@Mod.Instance("abcd")
public static Abcd instance;
@Mod.Instance(MOD_ID)
public static Abcd INSTANCE;
/**
This is the second initialization event. Register custom recipes/@Mod.EventHandler
public void init(FMLInitializationEvent event) {
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
}
It's a part of my code the rest are just events that works on singleplayer but multiplayer doesnt
wrong server š
spigot not forge lol
yeah but there i didnt get even one help message for 3 days so im trying here ;/
rip
Yea here is the entire code https://paste.md-5.net/dajojipumu.cs
with the error
machines:
'-13671181':
owner: FinGym2468
whitelisted: ''
location:
==: org.bukkit.Location
world: world
x: -135.0
y: 74.0
z: 181.0
pitch: 0.0
yaw: 0.0
items:
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- ==: org.bukkit.inventory.ItemStack
v: 2730
type: GRASS_BLOCK
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
- null
o sorry
i forgot to paste it lol
yea i'm fetchingit
the path is the same when loading and saving?
Print the exact path and make sure it's rounding the way you want
alternatively just floor or ciel
alright, thanks for the help ill try that out rn
Anyone worked with retrofit? I'm trying to get my android app to fetch data from my api. If I run my code synchronously (as shown below), it'll work fine, but for some reason android disallows synchronous network calls (according to logcat)? So it just crashes
dataStorage.api.getSubsets().execute().body()?.forEach {
subsets.add(it)
}
So I decided to do it with coroutines and make a suspend function instead, but this just does not work
println("Waiting for subsets") // This is called
dataStorage.api.getSubsets().await().forEach {
println("Adding subset ${it.name} ${it.imageUrl}") // This is NEVER called
subsets.add(it)
}
And I'm left waiting forever. Anybody knows what this could be caused by?
Is that Groovy
Is there an action or something else to see if a player is looking at an entity within a certain range?
Kotlin
You can raytrace entities for a player
So it also has those weird forEach methods š
Haha yeah ig
Use rayTrace and take the player Direction Vector and multiply it by your range
? no need to multiply
Oh well then it can handle that
Ahh yeah I remember having to multiply for my own raycasting algorithm
Thank you both š¤
š¤
first i gotta find out how raytrace works but I think i will figure it out
Just call 1 function, it'll return a RayTraceResult
I sent this to the r/androidddev discord server
Maybe someone knows there :p
Can you show how you implemented that await fun
How I can play hurt effect for player? Like the screen shake and a read/blood screen effect?
I tried player.playEffect(EntityEffect.HURT); but it doesn't work;/
It's from retrofit
Not my function
You could damage them for 0
how? I actually make them a damage by:
double playerHealth = player.getHealth();
player.setHealth(playerHealth - 10);
but it doesn't make a effect;/
player.damage(0)
dataStorage.api.getSubsets().await()
apiis my interfaceBackendAPI, it's instantiated by retrofitgetSubsets()is this function:
@GET("api/v1/subsets")
fun getSubsets(): Call<List<Subset>>
await()is asuspend fun <T : Any> Call<T>.await(): Tin Retrofit
Oh I trought it's your extension, idk then
thank you<3 I do not know that is a thing
ForbiddenFruit:
package com.github.spigotbasics.core.module
class ForbiddenFruitException(clazzName: String) :
Exception("Module tried to eat forbidden fruit $clazzName") {
}
ModuleJarClassLoader
package com.github.spigotbasics.core.module.loader
import com.github.spigotbasics.core.module.ForbiddenFruitException
import org.bukkit.scheduler.BukkitScheduler
import java.io.File
import java.net.URLClassLoader
class ModuleJarClassLoader(val file: File, parentLoader: ClassLoader) :
URLClassLoader(arrayOf(file.toURI().toURL()), parentLoader) {
companion object {
val FORBIDDEN_CLASSES = listOf(BukkitScheduler::class.java).map { it.name }
}
override fun loadClass(name: String): Class<*> {
return this.loadClass(name, false)
}
override fun loadClass(name: String, resolve: Boolean): Class<*> {
if (FORBIDDEN_CLASSES.contains(name)) {
throw ForbiddenFruitException(name)
}
return super.loadClass(name, resolve)
}
}
Isn't this beautiful?
No, I understand no word
modules must not access BukkitScheduler or else they'll get a ForbiddenFruitException
Do you have something against the scheduler or what
modules shall only access our own Scheduler, otherwise we wouldn't be able to cancel tasks of modules being disabled
they must only use BasicsScheduler
In kotlin, are they methods or functions
functions
But why, aren't functions those that are outside of classes and methods those inside or something
function is simply the term in kotlin. functions can be declared at top levle (outside of classes) or inside of classes.
in java they're called methods and are always bound to a class
is it fine to use this
I mean, ideally you use the replacement
whats the replacement
alriught thx
https://paste.md-5.net/inewobinux.css
Am I dumb for not knowing why this doesn't do anything?
Location is correct. I just don't see any redstone block breaking at the location
URLClassLoader::loadClass(String) actually already calls loadClass(string, false)
Has anyone here looked at the auth me plugin source?
ItemStack potSpeed = new ItemStack(Material.POTION, 1);
ItemMeta potSpeedMeta = potSpeed.getItemMeta();
PotionMeta hpotmeta = (PotionMeta) potSpeedMeta;
Objects.requireNonNull(hpotmeta).setLore(List.of("§7Alle Spieler bekommen Speed 2"));
hpotmeta.setDisplayName("§bSpeed 2");
PotionEffect speed2 = new PotionEffect(PotionEffectType.SPEED, 15, 1);
hpotmeta.addCustomEffect(speed2, false);
potSpeed.setItemMeta(hpotmeta);
``` how would I change the color of the potion
wouldn't it call the parent's method if I hadn't overriden it?
it would call your overridden loadClass(String, Boolean) method
alrighty then I can get rid of it
PotionMeta has a setColor() method
Requires a Bukkit Color, so you can do Color.fromRGB(red, green, blue) (each a value from 0 - 255), or you can use a hex value like Color.fromRGB(0xRRGGBB)
Bukkit has an own color class??
Yeah
Doesn't awt or whatever it was called have one too
jup
Yeah awt is usually the default java one used
awt is a graphics library which isn't present in all JDKs (namely headless JDKs)
Okay so I now got a custom class loader working that I can use to prevent certain classes from being accesses, e.g. BukkitScheduler. However now I'd like to make it possible to access the Bukkit PluginManager, but only intercept certain methods being called from that, e.g. registerEvents - what's the easiest way to do this? Proxy classes?
kotlin has delegates
Ah
i am however not sure if you can change the plugin manager via reflection
then you could so smth like
class ProxiedPluginManager(private val pm: PluginManager) : PluginManager by pm {
override fun registerEvents(...) { /* own logic */ }
}```
yes but how that make me possible to intercept someone from just calling Bukkit.getPluginManager() ?
but can I just make my custom class loader return that class in loadClass ?
you mean detecting whenever org/bukkit/PluginManager gets loaded and returning ProxiedPluginManager::class instead?
dunno what you've been doing with classloaders
the plugin consists of modules. modules shall be able to be enabled/disabled at anytime, hence we need to keep track or listeners and tasks registered by those modules, so we can cancel/unregister them when a module gets disabled. This is currently working fine for tasks - I simply disallow access to the BukkitScheduler. The PluginManager however shall be allowed, I only want to disallow modules calling registerEvents
ah the classloader acts as a bridge to the platform code
uhh
cant you use reflection to set the plugin manager in CraftServer? dunno if that works on final fields
What is the different
Because reflection says no
Static is generally bad
huh why
You either need old java janky reflection or unsafe
idk ask Java
I don't want to forbid plugins from using the pluginmanager
do you need to change modifiers with &= ~Modifiers.FINAL?
No
Can you spoof the pluginmanager or something
setAccessible handles both final and private
ah
well just delegate to the original one, just have some overrides
cant think of a better way atm
how can i check if a block is placed by players or generated naturally
Good luck.
is there a way or would i have to manually collect all the data
Yes gather data
If u have coreprotect or smth similar u can prolly pull from there
wouldn't it be possible to save some performance by making API to disable some features of minecraft and then save performance by for example disabling ticking for it?
I don't think a plugin can do this
I mean, if we implement it in Spigot
Sure but i doubt that'd be accepted if something ticks that probably shouldn't or doesn't need to you can just disable the ticking in those instances
That is much more likely to be accepted
I mean have u heard of insert fork smth white u write on and smth purple?
what?
I didn't get that sentence lmao
Paper and purpur already has toggles for a lot of stuff and it def helps some to turn off some features. So yeah spigot could have improved performance by turning off stuff
oh yeah jan while you're here
Butcher villagers
I tried your event debugger and it spammed exceptions
Oh nice, havenāt updated or touched that for a long time
like, just make a simple API call Server#disableThisShit and then make the server NOT tick that shit anymore?
Feel free to email me the exceptions or smth
it also doesn't clean up so it was still spamming exceptions after being disabled
does that save performance at all? lmao
sounds like 0 to me
gotta do some shit that is related to ticking in order to improve performance a lot
or sth like that
Well, it was made sort of to drop in, debug and shut down the server. Didnāt care about much else lel
advancements and villagers are useless for minigame servers
Villagers thinking is expensive
but so is spigot
I mean
well, if they don't exist how do they think?
If you don't have any villagers they won't tick
yeah exactly
Donāt be logical
npc shops?
well don't they usually have completely custom nms villagers anyways?
Use npcs for that
smh
Or just call setNoAi/setAware
I mean I guess they will still tick they just won't do much
is this a good approach?
no
and would this go in CB?
Idk if MD would accept that
just make a plugin for it
that pastes dummy entity managers n stuff
hacks the shit out of nms
what is a good approach then?
I mean a spigot config option would make more sense than api to do it.
lmao
I mean there is plenty protocol implementations ready for that
tell me some more heavy shit that we can screw up?
World gen
I mean yeah but still maintain stuff
same thing, world gen does not trigger if you don't generate more chunks
disable world saving but still maintain spigot
world's don't load if they are disabled?
Poorly optimized plugins
Entities is pretty generic, what exactly
if(plugin.getName().startsWith("Essentials"))
plugin.disable()
Well pretty much all entities when there are many of them
Players too
disable everything but players
If you can optimize something with 0 effect on behaviour feel free
every spawnEntity method just returns a dummy entity
If it changes behaviour at all, it'll need to be disabled by default
You should pr a tnt dupe fix
java.lang.NoSuchMethodError: 'net.kyori.adventure.text.format.TextDecorationAndState net.kyori.adventure.text.format.TextDecoration.withState(boolean)'
I'm getting this error when I use MiniMessage.miniMessage().deserialize("")
How do I fix this?
Ahaha
compiling with paper and using spigot?
?
Although they won't fix it until the provide an alternative for movable tnt
Shade a new adventure and relocate it i suppose

im using 1.17.1
I was actually thinking of PRing movable tile entities to spigot
then yeah shade adventure
Via a new event
. @mighty crane
so what is the point of this to change items background?
and how do I do that?
pretty much
@echo basalt Heās using paper, was turned away when he said he wasnāt using 1.20.4 and came here š¤Ŗ
kek
Do you use gradle or maven?
maven
ppl at work want this
oh cool
paper server mean, bc im using lagacy
lock is another
Does mfnalex have a shading doc or smth
that's just model data
I see
@tender shard got a shading thing on ur blog?
what version was PrepareGrindstoneEvent added
Probably some time after the grindstone was added
there no way to check that some how
for maven?
People just getting started with maven always ask me the same 3 questions, so hereās a a short FAQ! How to change the output directory? Read this. How to shade dependencies and what it means Sometimes you are using certain libraries (for example, my CustomBlockData class, or similar stuff) that is not already present at...
Yeah @mighty crane wants it
font color/image
thx
if you also want to relocate shaded dependencies, add this into your maven-shade-plugin <plugin>:
<configuration>
<relocations>
<relocation>
<pattern>com.jeff_media.customblockdata</pattern> <!-- package name of what you want to relocate -->
<shadedPattern>your.own.package.name.customblockdata</shadedPattern> <!-- target name -->
</relocation>
</relocations>
</configuration>
oh ok
how to get the ammount of items that a block would drop with fortune
declaration: package: org.bukkit.block, interface: Block
Do note that you shouldn't use this if you have an actual block being broken
nah I want too do cutclean so ores automaticly get smelten
When a player is breaking a block?
title
it's a mix of 6 characters + color + spacing
and acts as a really low quality screen
there's also some optimizations being done
like space merging and color merging
basically I merge duplicate spacing so the client has less to render
and I also merge color tags to keep the component simpler
Make it api so I can rickroll random players in my server
I mean technically this is just a static method
that returns a component
so it's doable
you could also precompile the entire rickroll animation
Ig it'd be funny to constantly rickroll ppl opening checks without disrupting inv flow
The ReadTimeoutException : null error is from spigot?
but at the same time you can get a much higher quality image by just skipping this and making a solid image
more context
When you enter my server, some users see ReadTimeoutException : null
Anyone knows why this happens? I just started working with SQLite and OMRLite. Trying to figure out why it spits out stuff about an exception even tho i allreay have an exception handled in the code.
public PlayerData getPlayerTokens(Player player) throws SQLException {
return playerDataDao.queryForId(player.getUniqueId().toString());
}```
It suggests handling the exeption because you've told it getPlayerTokens might throw SQLException
Its an error i should ignore?
No
Ok then how would i go about handling it?
Catch the exeption and handle it to fit your needs
Ok
also do make sure to cache data and not call database request on the main thread
Idk what that means. Im not familiar with thoes terms
public PlayerData getPlayerTokens(Player player) throws SQLException {
try {
return playerDataDao.queryForId(player.getUniqueId().toString());
} catch {
player.sendMessage("No information about this player's tokens was found!");
return null;
}
}```
Like this?
oh wait catch needs a parameter
Is it the SQLException?
public PlayerData getPlayerTokens(Player player) throws SQLException {
try {
return playerDataDao.queryForId(player.getUniqueId().toString());
} catch(SQLException exception) {
player.sendMessage("No information about this player's tokens was found!");
return null;
}
}```
Like this, but then i guess the "throws SQLExceptions" is removable
Why, Does it break? also is the "throws SQLExceptions" removable?
Caused by: java.lang.NoSuchMethodError: com.mongodb.client.MongoCollection.insertOne(Ljava/lang/Object;)Lcom/mongodb/client/result/InsertOneResult;
at dk.shadow.bande.bande.BandeHandler.saveAllBandes(BandeHandler.java:285) ~[?:?]
at dk.shadow.bande.commands.ingamecommands.bandeadmin.subs.SaveSub.lambda$onCommand$0(SaveSub.java:21) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) ~[?:1.8.0_392]
at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) ~[?:1.8.0_392]
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_392]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_392]
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[?:1.8.0_392]
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) ~[?:1.8.0_392]
public void savePlayer(UUID uuid) {
PlayerData playerData = playerDataHashMap.get(uuid);
if (playerData == null) {
Bande.getLog().sendMessage("[ERROR] Player with UUID " + uuid + " not found in playerDataHashMap");
return;
}
try {
Document setData = new Document("bande_name", playerData.getBandeID())
.append("player_name", playerData.getPlayer_Name());
if (playerDocumentExists(uuid)) {
Document update = new Document("$set", setData);
mongoCollection.updateOne(Filters.eq("uuid", uuid.toString()), update);
} else {
mongoCollection.insertOne(new Document("uuid", uuid.toString())
.append("bande_name", playerData.getBandeID())
.append("player_name", playerData.getPlayer_Name()));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Hey guys, I want to save inventory all items to SQL database, and the encode/decode are the best way to do it?
Code that doesn't exist cannot run, so you need to include the MongoDB dependency. If you're on a modern version (1.17.1+) and it's hosted on maven central you can use the libraries feature in the plugin.yml. If not shade it
You can store them as a Blob or in Base64
What is Blob? I knew the Base64 but I never heard Blob
blob is just binary data
So, a byte array?
Hello, how to spawn "fake" entity through packets in 1.20.4 and send it to player ?
Ah Thank you bro š
Can i remove it?
Yes, as you catch it
What's the optimal way to change a player's nametag (I'm referring to the player name specifically, not just team prefixes through scoreboards) in 1.20?
Not much has changed in 1.20.4 so what's your problem?
Hey guys, I'm making Shop Plugin on bungeecord server
And I have a question How can I store shop data? (Currently, I saved it on database 'cause I think it's the best way to do it)
Is there anyway to store data?
If you want another way to store data you can probably use Redis
climbs wall damn I feel so stupid suddenly
Oh thank you Lots of people use it instead of SQL database?
Lmfao
very neat, very cool
It's an in memory key value database. Primarily used for caching information
public boolean setupEconomy() {
System.out.println("0");
if (!instance.getServer().getPluginManager().isPluginEnabled("Vault")) {
return false;
}
System.out.println("1");
RegisteredServiceProvider<Economy> rsp = instance.getServer().getServicesManager()
.getRegistration(Economy.class);
System.out.println("2");
if (rsp == null) { // console output is 0, 1, 2 //TODO: get because is null
return false;
}
System.out.println("3");
Core.v_economy = rsp.getProvider();
System.out.println("4");
return Core.v_economy != null;
}
beacuse rsp == null?
So you want to use it together with something else (since you probably want things to persist across restarts of redis)
Ahh thank u for answer š
call me crazy but I think the navigation class should act as a global navigation solution for all entities
I know, I know, this is heresy
but hear me out, maybe slimes should be able to pathfind
anyone got an easy soultion to checking if a block is placed by a player?
same with rabbits and bats
Lol
BlockPlaceEvent, add pdc??
why can you not
it would require enormous amounts of data wouldnt it
for like a huge ass smp server
It's not that bad lol
Depends on how it works
redis is a persistent storage solution as well, you need to enable that separately
but uhhh.... https://youtu.be/WQ61RL1GpEE?si=90TXqOUoAzPzs1Zr it is not great lol
Pdc just sounds like the best way to do something like that lol
you think it maybe be easier to an SQL database
or
better
not easier
what about CoreProtect
ah I thought it was memory only
Never used it myself š¤·āāļø
CoreProtect has an SQLite file
Which can take up quite a bit of storage ofc
so im better of storing it myself?
You probably want to store it yourself yeah
What's the use case
well every sinlge block that is brocken by a player needs to be checkde
and why?
im making a hypixel skyblock like game that gives players skill xp when they break certain blocks
mining xp for stone
farming xp for farming stuff
etc etc
i dont players to be able to place their own block and break them again
yk
I would use SQLite or PDC
the whole plugin already uses mysql and i dont wanna change it to sqlite which i dont even know anyways so im gonna go with pdc then
You can use MySQL too if you'd want
i just want whats fastest
Maybe use that to prevent exessive chunk file sizes
mhm
how can I disable natural regen (with food) thats what I got:
@EventHandler
public void onHardCore(EntityRegainHealthEvent event) {
if (event.getRegainReason() == EntityRegainHealthEvent.RegainReason.EATING && main.hardcore) {
event.setCancelled(true);
}
}```
PDC would probably be faster
im not yet sure what scale this whole thing will reach
Do make sure to optimize the data you're storing
You can compress it further
1 character takes 8 bits you could in theory store 8 blocks
A 1 for player block and a 0 for non player placed block
my idea was to just not store non player placed blocks
at all
if its in there its placed by a player
if its not in there
its natural
The thing is you need to store where the player placed block is
yeah
my idea was to simply store coordinates
and if the cdoordinates are in there
its a player placed block
if they are not
That would take a LOT more than what I mentioned above
but how exactly would the server know what the cords are
just store every single block in order?
how would you store 8 blocks in one byte?
1 byte peer block
so youād need a single gigant at number to store the entire world?
You'd store it in the chunk pdc
but yeah it would essentially be a massive binary number
i guess that could work
probably better than storing it per block
someones definitely asked this question before though
mhm
Do someone have an example for sending the spawn entity packet of ItemDisplay and TextDisplay in 1.20.4 ?
im trying to load in player stats when they log in, but the issue is that some of those stat updates also cause packet updates to the player or interact with bukkit in some other way that's not allowed asynchronously. right now i'm doing it sync, but that's causing a bit of a lag spike. whats a better way to go about it, to spread out the various updates required to update their stats over a longer period of time or something else?
i would assume doing it async and then calling a task to re-sync those stat updates would also cause a lag spike due to the amount of tasks scheduled
Loading your data should be done async, always.
What do you mean by "re-sync those stat updates"? I have never had any player mapped data that needs sync calls when loading.
stuff like discovered recipe updates need to be done sync
there are also some attribute updates
Those can surely be applied sync in microseconds
actually yeah im just being stupid to update those stats like that right away
nevermind
Take a look at how Vanilla does it
That's how you work with NMS
Just load your data into a ConcurrentMap<UUID, SomeStats> loadData(UUID playerId) on AsyncPlayerPreLoginEvent.
and then inizialize them inizializeStats(UUID playerId) on PlayerJoinEvent.
thank you !!
What is a ConcurrentMap? I constantly see it
I'd use a guava async cache and store it for 20 seconds (keepalive timeout)
We don't want to have a memo leak if someone starts the login process and doesn't manage to go through
ConcurrentHashMap is a Map implementation which allows concurrent access.
Damn, thread safe map?
Finally, I always needed that
Yes thats the more sophisticated approach to prevent data leaks from a client dropping its connection after the async pre login
There is very little performance drawback for this as well. (As long as you dont hammer it with a ton of threads on all keys constantly)
also if interested Caffeine has a better implementation and API for this IMHO
https://github.com/ben-manes/caffeine
Caffeine was spawned from guava iirc. Might be from the same guy.
iirc its preferred by google because it was written by the same people
with a somewhat better implementation
The improvements draw on our experience designing Guava's cache and ConcurrentLinkedHashMap.
the guava javadoc suggest to use caffeine too
final CraftWorld world = (CraftWorld) location.getWorld();
final Level handle = world.getHandle();
final net.minecraft.world.entity.Display.TextDisplay textDisplay = new net.minecraft.world.entity.Display.TextDisplay(EntityType.TEXT_DISPLAY, handle);
textDisplay.setBillboardConstraints(net.minecraft.world.entity.Display.BillboardConstraints.FIXED);
textDisplay.setInvulnerable(true);
textDisplay.setPos(textLocation.getX(), textLocation.getY(), textLocation.getZ());
textDisplay.setYRot(LocationUtil.getYaw(orientation.textFace()));
textDisplay.setXRot(0);
final List<SynchedEntityData.DataValue<?>> textData = new ArrayList<>();
textData.add(SynchedEntityData.DataValue.create(new EntityDataAccessor<>(12, EntityDataSerializers.VECTOR3), new Vector3f(0.6f, 0.6f, 0.6f)));
textData.add(SynchedEntityData.DataValue.create(new EntityDataAccessor<>(23, EntityDataSerializers.COMPONENT), CraftChatMessage.fromString("Hello")[0]));
for (final Player player : Bukkit.getOnlinePlayers()) {
final CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().connection.send(new ClientboundAddEntityPacket(textDisplay, 0));
craftPlayer.getHandle().connection.send(new ClientboundSetEntityDataPacket(0, textData));
}
Hello, I tried to send a packet to spawn a text display, the entity is spawning, but all its data (text, scale) aren't applied.
Is there a reason that teleporting the player sometimes can cause them to tp places they shouldnt be?
Sometimes it can be them in a cave, using teleport and it teleports them to above the cave
Or the nether, and gets tped to the nether roof
public static void teleportToSurvival(Player player) {
UUID id = player.getUniqueId();
String[] loc = ((String)PlayerData.getUserData(id, "Last.Location")).split(":");
String world = (String)PlayerData.getUserData(id, "Last.World");
Location l = new Location(Bukkit.getWorld(world), Integer.parseInt(loc[0]), Integer.parseInt(loc[1]), Integer.parseInt(loc[2]));
player.teleport(l, PlayerTeleportEvent.TeleportCause.COMMAND);
}
This is specifically the code thats causing this issue.
Hm, is it just me or is this smelling like a bit too much staticity
Either thats where the coordinates point to
Or am I high rn
Or some failsafe is teleporting them to the top block
From what Im aware they shouldnt be a failsafe for teleports here
Ill check the cordinates but im 99% sure these players arent on the netheroof
Its when they rejoin the survival world that they get put on it
Uh, accessing data by Strings. š¦
Type safety cries when looking at this.
hey
Bros should use byte[] for that
Sponge API
Nono
It's an own thing
How do I reset/refresh player profiles?
is it very different to Spigot?
And sponge has nothing to do with spigot/paper
Yes
It's an entirly differnt api, so yeah
It's a completely seperate thing
It also has a version that runs forge
sorry gang text wall incoming :(
@carmine mica It's been a week since I posted a response on stash, so I'll ping you here instead since I'm interested in your thoughts on this.
First I agree we should probably get rid of Inventory#getMenuType obv we were trying to get away from that it'd be pure idiocy to just go back to it.
Second your response all made me further question how realistic it is to keep allowing these so called "virtual inventories". I myself am hard against things like CraftMultiCraftRestulContainer existing in implementation, however, if we want users inventories to "work" as expected these crappy implementations need to be done. It might honestly be worth it to just remove CraftContainer and pass through SimpleContainer (aka InventorySubContainer in spigot maps) implementations to everything so they can "store" items and not much else without the drawbacks of CraftContainer existing.
Third, I'm wondering whether you'd think it'd even be advantageous to modify the Bukkit#createInventory API at this point. I wonder if it'd be better to just let it die and force newer plugins into using MenuType#create which is and always will be the better way to create Menus. If we go with this approach the API will be easier to maintain and use as well as expand in the future as we'd have removed the need for any form of major patching unless something big changes.
thanks
Ye, I've heard it's the best thing to run plugins and mods, because hybrids are just š
I clearly need to watch a 10 hour tutorial on java if a small segment of my code gets a LOT of complaints lmao
Any good tutorials out there anybody would recommend I watch?
I get I could search one up but considering that you guys had to learn from somewhere you probably know better sources.
oldie but a goodie
All you have to learn is oop
OOP is blegh just learn syntax and that stuff slowly falls into place over time
Also, the memory
OOP only developers in shambles when I start passing in functions as method parameters
https://en.wikipedia.org/wiki/List_of_Java_keywords Gunna read into this then as well
If I need to learn javas variables
variables is episode #5 of the new boston java tutorial
Practice is the best way to learn
Java variables is just pointers to object in the heap
yeah when you're starting out though you shouldn't worry about implementation details
Javas memory managment is goofy
you should worry if your code works or not lmao
So why is using static a bad practice by the way?
Encapsulation
I see that complaint a lot and nobodys ever explained it to me
it's not it's a bad practice if you need it. You should generally be using constructors
but again there are always exceptions such as, Singletons (love these guys), constants, etc...
So its not a bad thing to use, but overusing it a bad practice
You should know when to use it
Generally static should pretty much be used if you have no state (internal data to modify)
Like utility methods
Staticity is bad most of the time
You're taking in parameters and spitting out a result
There's no internal state to that method l that changes that outcome
/**
* Sends a chat message displaying what the source was from.
*
* @param player The player to send it to.
* @param from What was this being called from?
* @param text The text for the chat message.
*/
public static void specificChatMessage(Player player, String from, TextComponent text) {
TextComponent message = new TextComponent(from + ChatColor.RESET + ChatColor.DARK_GRAY + ChatColor.BOLD + "> ");
message.addExtra(text);
message.setColor(ChatColor.WHITE.asBungee());
player.spigot().sendMessage(message);
}
So for example this should be fine to keep as static?
Being able to create an api Inventory/nms Container is useful for reasons for sharing a container in a view. I think what I would do is have some way of creating Inventory instances just purely based on slot count, and the a MenuType#create method that took those inventories and verified the size requirements matched.
Hmmm yeah my thought on that too, might be a bit weird to implement though I'll look into seeing if I can come up with anything reasonable. Main issue with this is for containers that have functions such as the loom require some hook in so you end up with the weird craft variants
I mean sure what would you gain by locking this method into a class instance
TIL ChatColor has an asBungee
Ofc š¤”
Also you shouldn't be using ChatColor directly inside a component
Nothing I can really see
oh
how should I do that then?
You can use fromLegacyText if you must
Otherwise use a seperate text component for each color and then combine them
via ComponentBuilder or append or whatnot
PineappleChat >>>
ur a pineapple
Thx
did you enjoy my painful mob heads class
yes
could always be an enum
Okay material enum
Enums are shit apparently
An enum would be bigger anyway, I would lose the few loops I do have
enums are always better guys
Is there a way to reset/refresh game profiles for skin resets?
Packets
Yeah but which ones
why always when i try create region i have this error - https://paste.md-5.net/onuviriyav.bash
who tryna smash
Presumably it doesn't like the special characters
Or maybe the spaces
Sup
lol rus this "special characters" ?
Well it's not ascii
I checked no it is not
replaced with English letters the error still appears
well, try without spaces
"_" can be ?
yes this space
dem
i was think region name was can have space
private static final Pattern VALID_ID_PATTERN = Pattern.compile("^[A-Za-z0-9_,'\\-\\+/]{1,}$");
That's the regex they use to check
thenks
it's actually weird of them to restrict the naming style of region names
this not passoword lol
$%%&%&##* u want region name like this?
Well, so what? This is just the name of the region; those who create them themselves are responsible for this. After all, they don't come up with a password.
Probably makes it easier to store in databases
database have this pattern too?
No but it means the database doesn't need to be utf8
How do I cancel a bukkit runnable/scheduler runTaskTimer inside an entirely different ifstatement?
if () {
BukkitTask taskid = new BukkitRunnable() {
@Override
public void run() {
System.out.println("I want to cancel this");
}
}.runTaskTimer```
```java
else if () {
/*I want to cancel it here with "taskid.cancel();" but I can't get it to work because it's out of scope and IntelliJ context actions don't work*/
}
}```
Is it just me or does this sound like you need to learn java
Hm
Thank you this worked š
idk how i couldn't figure this out myself unless it just doesn't work with bukkitscheduler
Hmm, actually, I have a slight feeling of xyproblem, because why would you can the task that you create and run in one if in an else if
When using a TextDisplay what happens if you use more lines than fit in the TextDisplay?
Because I only want it to run when the if statement is satisfied, or are you implying that I can make BukkitRunnables/BukkitSchedulers outside of all methods & if statements and then call them later?
No
there is no limit
I'm asking you why you would cancel a task that will not even exist if the else if fires
Is it in a loop or something
sure, sure, but they do have a size in the y direction
Yeah
i need to stop the loop in a 2nd ifstatement
Do you know of a method to know if the text is going to not be contained by the TextDisplay anymore?
They don't have a size
No, I'm not talking about the timer. What exactly are those if statements and why would you cancel a task that doesn't even exist
The width and height aren't actual bounds
wait but you can tranform it with a scale
They just control clipping
and like it auto adds a new line if the text is too long
A newline will be created if the text length is longer than the wrap length.
yeah that's what I mean
TextDisplay#setLineWidth()
Do you know how much Y Space each line takes up?
Should be the same as an armorstand's text.
By default anyways.
TextDisplays can be scaled to be larger.
Yeah by default it's the same as an entity name
I made an arrow that starts spinning around the player for infinity when I rightclick (which is the code in the bukkitrunnable within an ifstatement) and I needed it to stop when I leftclick which is a new ifstatement. But everything is working now cause I made an instance variable
hmm and a block is 16 pixels
idk if the task "doesn't exist" but the arrow is most certainly still spinning if i don't cancel it
Hm, well, I'd guess your code could cause issues in your case, but I don't know exactly what your code is so can't know
It's usual for people to write fundamentally wrong code, ask for help in smaller parts and then complain about their code not working
Thank you I will keep it in mind
if (prestige == 0) {
return prestigeWrapper.getBracketColor() + "[" +
levelWrapper.getLevelColor() + level +
prestigeWrapper.getBracketColor() + "]" +
ChatColor.GRAY + name + ": " + message;
} else {
return prestigeWrapper.getBracketColor() + "[" +
ChatColor.YELLOW + prestigeWrapper.getRomanNumeralDisplay() +
prestigeWrapper.getBracketColor() + "-" +
levelWrapper.getLevelColor() + level +
prestigeWrapper.getBracketColor() + "]" +
ChatColor.GRAY + name + ": " + message;
}
How do I make this look more readable, I'm using Java 8
StringBuilder mayhaps
StringBuilder def is a must here
Default height is ~5 pixels
Okie dokie
oh ight, thanks
Fun fact: an inventory slot is 16x16 pixels
The inventory slot border is ~2 pixels wide and ~1 pixel tall iirc
the whole goal is to use it with custom uis
DeluxeMenus2.0
Show code
except it needs a resource pack
and makes quite long strings
I need to benchmark it to see if it's even viable
RPs aren't an issue anymore
Because we can have multiple server packs woo
It adds like 108 characters to the inventory title
Doesn't seem tooo bad
What's frame.mainPanel?
Probably missing some field on it since I think that's where it errors out.
what tf is that?
I use the translatable keys for spacing
which is cool
lets me do lang:space.123
Ah fancy
and allows me to merge spacing
I just made a bitmask style system for it
I just pass a Map<Integer, Color>
So it's not spigot related?
So if you wanted a 14 space it would combine an 8, 4, and 2
exploin
I made a colored background thing
Not ideal though cuz more characters
What's the IJ form builder look like?
?whereami
I prefer Netbeans when working with Swing
I had issues with IJ's forms so I used netbeans to build out the BuildTools GUI.
hmm. rgb?
yes
Rgb and manual alignment
it's like 100 lines of code
half of them dedicated to optimizing colors and spacing
What's that game called where you color stuff based on numbers for each row/column
Reminds me of that :p
Nonogram
we could make a color by number
But yes color by number is another name for it
I just couldn't use the GUI to make it do what I needed it to. It tried to force certain layouts when I needed the freedom to place the elements where I wanted.
IJ wouldn't let me do that so I just switched.
but yeah it's quite easy to make
each row just has a character that represents a scaled 1x1 image with a different negative ascent
Whats the backbone? Anything fancy or new?
not rly
basically for each row I get the color
If it doesn't exist I just send an INVENTORY_SLOT_SPACE and move on
Ah ok. So you detect the title width (Assuming you enforce a font) and then color in the background
This goes before the title but ye
it negates its own width so I can apply titles on top
Ah this way around makes more sense. So font doesnt matter.
Alright so the usual š
there's some manual alignment and stuff
a lot of my tries looked like this
You can even scale them negatively. Im guessing thats what he is doing for the spacing
lol
spacing is just a fucked up font with the 1.19 <space> thing
It's nice
We love the negative space font
I can lang:space.123 and it goes 123 chars ahead
lang:space.-123 and it goes 123 behind
Not from what I remember. Even when testing with IJ, everything worked the same as in netbeans. Although, we ended up ditching IJ for the form builder in Netbeans since it was more flexible and used that for a while. The project got a little more complex to where we ended up dropping the formbuilder altogether and switched to raw swing code.
Anyways once I'm done rendering my title I merge spaces
which basically turns lang:space.1lang:space.1 into lang:space.2
And some color math so I only open color tags once when facing back-to-back colors (color:#aabbccUTF</color>lang:space.1color:#aabbccUTF</color>)
EnterUIDFrame#mainPanel. When does this field get initialized?
Is the project hosted somewhere? I want to see if it compiles properly on my machine.
That's fine
quick question I was just wondering, how do bukkit plugins work as java programs if we don't have the main method?
public static void main(String[] args) {
}
``` or am I just lacking additional java knowledge lol
Spigot has the main method
Plugins won't run on their own
Spigot constructs an instance of your plugin and then calls onLoad / onEnable
Bukkit gets main class in plugin.yml file
oh well, makes sense
but everything is like super automated for me that I don't even think about these stuff
Is there an exemple about spawning entity with packets in 1.20 ? (and apply it some modifier)
the pluginmanager checks all .jar files inside plugins/, opens each plugin.yml, reads the main attribute, Class.forNames that class, looks for a no-args constructor, invokes it, and now it has an instance of the plugin. then it throws it into a list of enabled plugins and invokes the plugin's init method, then it calls their onEnable()
damn that's cool
it's basically just a more complicated version of my module loader https://github.com/SpigotBasics/basics/blob/main/core/src/main/kotlin/com/github/spigotbasics/core/module/loader/ModuleLoader.kt
have you figured out how to do the bukkit scheduler proxying?
your own one?
and here was I thinking I were decent at coding spigot plugins xD
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
List<String> returnList = new ArrayList<>();
if(args.length == 4){
returnList.add("SECONDS");
returnList.add("MINUTES");
returnList.add("HOURS");
returnList.add("DAYS");
returnList.add("WEEKS");
returnList.add("MONTHS");
returnList.add("YEARS");
}
return returnList;
}```
What's most efficient way, to delete items that does not fit.
take a look at StringUtils.copyPartialMatches
StringUtil.copyParti- dangit
if you want to do it yourself to you can also make a Trie (Syntax Tree) data structure
that is generally the intuition
thats basically returnList.filter(arg -> args.startsWith(lastArg))
weird t hat bukkit doesn't have any filtering once you start typing by default
I could've sworn that had existed
fair
pls how to spawn a display entity through packet
Is it worth to even try to use nbt classes from nms instead of using nms api, because I dont even know half of the obfuscated code unless there is some documentation on it
I am on 1.8
Some functions have names but some dont, this is the problem and this mappings arent even by mojang
(Bc they dont exist btw)
What about:
Using 1.8 is like voluntary participating in waterboarding.
I am forced to do it because the minigame is old school pvo
Pvp
For other plugins I use the latest version (and there I can just use PersistentDataContainer)
why would blockbreakevent always return a player
what if it broke from something ele then a player
Then it wonāt fire a block break event
does .size() on hashmaps start counting on 0 or 1?
0 = empty, 1 = 1
okay, thanks
so i'm making a prison server and currently im using FAWE api for the enchants but it keeps producing ghost blocks
is there any work around to this?
hella annoying
What version
I think that size/length in java will always start at 1. Only indexing in Arrays starts at 0
1.20.4
Hmm
Idk how stable fawe is for 1.20.4
I think itās kinda just a limitation on how it works though
That sometimes you get weird stuff happening
hello, im currently trying to use heads from a website but im not sure how to use them, as skullMeta only has setOwningPlayer(OfflinePlayer player);
but the website provides stuff like this for developers, im not quite sure what this is and what to do with this.
eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjgyYWQxYjljYjRkZDIxMjU5YzBkNzVhYTMxNWZmMzg5YzNjZWY3NTJiZTM5NDkzMzgxNjRiYWM4NGE5NmUifX19
Ur using some old mc version?
Then use PlayerProfile
how do i get it?
wait jan are these heads even secure, like if the acc changes its head they will change too, right?
declaration: package: org.bukkit, class: Bukkit
Not sure, probably?
Though it will have a link to the previous head texture so canāt know if that ever gets updated
Depends where you got it from
hmm okay
i've always had this issue but wondering if i could get rid of the ghost block
Well itās called async for a reason
ye ik
Anything from https://minecraft-heads.com/custom-heads wonāt change
Specifically the custom-heads section though, not the entire site
https://minecraft-heads.com/custom-heads/search search link is probably more useful
Should I use ItemDespawnEvent, EntityDeathEvent, EntityRemoveFromWorldEvent or anything else to stop an arrow from despawning?
anyone know how to force a client to update the head textures?
whenever i add a skull item it js renders fucking steve
using an owner name btw not a game profile
on 1.8 so yeah thahts probably it
Item or Block?
item
in an inventory
i sent with packets
i had to bc the bukkit inventory literally didnt update
1.8ļøā£
want a small tip?
like a really small one
like very very small
returnList.addAll(List.of("SECONDS", "MINUTES", "HOURS", "DAYS", "WEEKS", "MONTHS", "YEARS"));
easy
and less code
honestly you could do this instead:
return args.length == 4 ? ArrayList<>(List.of("SECONDS", "MINUTES", ... )) : new ArrayList<>();
wdym?
oh
you could do that, but then it won't be mutable pretty sure, unless he's modifying the list both should be fine
then here you can do just List.of
Use Arrays.asList()
conclube detected
List.of() copies the vararg array
where as asList() just wraps around it
And since the list isnāt exposed to anything, its just niece to save some memory and computation
Yes but it still scales worse
You gotta pay attention to those details, esp if u use it and care about the impl and uāre building a project for the world to consume
oh btw you back from your trip?
Yes
nice nice
Heās always tripping
Coll bonk
:3
Such ominous movements there
we should make our own spigot in rust
or cpp
would look cool in university application form
Only if you use the vararg version š
If you're passing 10 or less values, it does not copy the varargs
yep
Wack
isn't it funning managing memory or is it just me
like trying to actually optimize a program
in cpp or rust
cpp ofc gives more control
I mean, even in Java itās scarcely the case where you want to just throw away memory, but yeah I get ur point
you're good at rust right?
I guess if you code after some weird religious cult like elegant objects principle
Im decent
Iāve written some cool stuff in it
how would I design the packet system + tcp connection?
Ugh, well what exactly are your goals?
mc server what else
Design wise, and what do you care about in the product?
in java i would inheritance the fuck out of it
but in rust theres no inheritance stuf
I mean there is sorta
idk it working? what are you asking?
im just tryna get a simple server working
you can join and do stuff
no world gen cause too complicated pretty sure
Well you asked me how to design it, and I canāt answer that straightforward without knowing what exactly youāre aiming at here
obviously youād open up a server socket
Default the port to 25565
yeah
but like
and then on connection i would send to another thread
how would that thread manage the packet data etc/
one sec let me show you my current project
it has no server connection stuff right now only config
Show it to me, Iāll take a look and reply tmrw, heading to sleep now
dont question goofy code, i aint good ati t
what is the best way to handle this?, i don't see any fishing state referring to this, (the unhook thing)