#help-development
1 messages · Page 1830 of 1
If I have a block and a block facing, how do I get 3x3 adjacent blocks based on that facing? (That means west and east - north and south give the same set of blocks)
Is the command in the plugin.yml?
Ah it’s not
oh
There is a description but no command
I feel like I should share this as it has been a road of learning and it may help some people in the future. So item durability is handled by the base Material. If you didn't use a base material that can take damage like armor, or a tool when creating your custom item, you won't be able to damage it. This is a problem for me as I know some users are not going to want to use the resource pack, and seeing a pair of shears named "Ender Chest" just isn't right. So what I ended up doing was implementing a custom durability stat on the item with an integer value in the persistence data container. Then in the events I am interested in, I just update the lore of the item with its durability. This way the player can see durability of non-tool items when they hover over it. A little annoying it isn't displayed at a glance, but a good enough solution for me =]
I suppose if I wanted to be REALLY hardcore I could have like 20 different custom textures each with the health bar a little lower, and essentially use custom model data for each individual health tick....
that seems silly tho....
Hey I have a question for premium plugins.
How do you put an external link to download the .jar
can anyone help?? i can't figure out how to use citizens api
Is there a way to spawn a barrier particle using 1.18.1 api?
Should do a thread about it on the spigot website
perhaps I shall once I get the kinks worked out a bit more =]
Particle.BLOCK_MARKER with a T data of Material.BARRIER.createBlockData()
player.spawnParticle(Particle.BLOCK_MARKER, location, 1, Material.BARRIER.createBlockData())
Hi guys quick question. How do I stop the spigot server from crashing when I'm debugging (Reason: Server not responding)
for that set the timeout to a high number in spigot.yml
Ty
Thank you 😄
public void chat(AsyncPlayerChatEvent e) {
String UUID = e.getPlayer().getUniqueId().toString();
if(UUID.equals(spaceID)) {
Bukkit.getServer().getConsoleSender().sendMessage("§a[prefixes] [DEBUGGING] space talked lol");
e.setCancelled(true);
e.getPlayer().getServer().broadcastMessage("§o"+space+"§f: "+e.getMessage());
}
else if(UUID.equals(eliID)) {
e.setCancelled(true);
e.getPlayer().getServer().broadcastMessage("§o"+eli+"§f: "+e.getMessage());
}
else if(UUID.equals(cassID)) {
e.setCancelled(true);
e.getPlayer().getServer().broadcastMessage("§o"+cass+"§f: "+e.getMessage());
}
else if(UUID.equals(bsID)) {
e.setCancelled(true);
e.getPlayer().getServer().broadcastMessage("§o"+bs+"§f: "+e.getMessage());
}
else if(UUID.equals(flagID)) {
e.setCancelled(true);
e.getPlayer().getServer().broadcastMessage("§o"+flag+"§f: "+e.getMessage());
}
else {
e.setCancelled(true);
e.getPlayer().getServer().broadcastMessage("§o§7"+e.getPlayer().getName()+": "+e.getMessage());
}
}```
this doesnt work, no errors in console, chat is still default
how not work?
the check, the cancel the broadcast?
helo, i wanna respawn a player istantly, but i'm using the mojang-remapped NMS, so i don't have the .spigot.respawn();
How can i solve?
ping me if someone can solve, thx
?
none of it works
you can see the patch in spigot and replicate.
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse/CraftBukkit-Patches/0026-Implement-respawn-API.patch#4,17,21
but you put the @EventHandler?
Is it able to cancel the dismount for players so they keep being the passenger of an entity?
in teory yes, you can try https://hub.spigotmc.org/javadocs/spigot/org/spigotmc/event/entity/EntityDismountEvent.html
declaration: package: org.spigotmc.event.entity, class: EntityDismountEvent
so i can solve pasting this in my code?
yea if you are using NMS then can try replicate the same method in you plugin
but your are using the mojang maps not?
then not sure how not have the respawn method (i dont use the mapping for know)
yessir
but another thing... you can try make this check in respawn event
What do you mean you're using remapped NMS so you don't have spigot().respawn()?
NMS has nothing to do with whether or not you have access to API. If you're depending on Spigot, you will have those methods lol
this.. when i read i was thinking you try use CB directly >.<
Yeah... you're in API. You have those methods.
Unless you were doing spigot.respawn(), which won't work. spigot() is a method, not a field
nop
and directly p.respawn() ?
player.spigot().respawn() exists for me with 1.18.1 Mojang Maps
not even that
i'm in 1.171., is maybe for that?
It's existed since like 1.8
.... i'm using mojang-remapped
Pretty sure it existed for me when I was still using 1.17.1 too
i need citizens but the github wont work
you only generate the mapping in buildtools?
yes i built in buildtools
How are you getting that Player object
do i need the api heybro?
through the event
for using in your plugin?
yes the github one
What's the event for firework blowing up?
Thanks ^^
Hey guys, so this ones probably a no but I gotta ask. Is there a way to make my custom item repairable at the anvil, and to determine what kind of material is required? Or is it completely based on the Material of the base item
do i need the api
Yeah, I just tried using 1.17.1 remapped and Player#spigot exists for me. What error is it giving you?
Canceling the event works perfectly! Thank you so much
You'd have to do the logic yourself by reading the anvil inventory probably
simply it doesen't exists
I was just looking into that =] I still can't seem to find an event that fires when a player actually clicks to accept the repair. PlayerMendEvent I thought I was close, but that was for the mending enchant
Make sure you're on the latest version & restart your IDE
Usually it makes the text red if it doesn't exist unless your theme changed that
nop, its not the ide / theme:
Probably just InventoryClickEvent
Or InventoryInteractEvent, one of the two
Ohhhhh wait I think I might get it. So I need to listen for PrepareAnvilEvent. Then detect when my custom item is put in there along with the item that I want to repair with, then I need to use the Inventory attached to that event to explicitly set the output slot to the repaired item? But PrepareAnvilEvent says it fires when items are put into slots, will it fire when the output is taken back?
Oh snap another separate just inventory interact to check for them grabbing it, that may work
maybe cab try reload the POM in the IDE?
Really is strange not get the method
Hello, i am trying to make my first plugin, but i cant get it to work. Spigot log says, i have to extend java plugin. But in code i have public class Main extends JavaPlugin
show error...
[16:59:59] [Server thread/ERROR]: Could not load 'plugins\logit.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: main class `jejt.survival.LOG_test.Main' does not extend JavaPlugin
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:415) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:231) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassCastException: class jejt.survival.LOG_test.Main
at java.lang.Class.asSubclass(Class.java:3924) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:74) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 8 more
wait, does every class have to extend java plugin?
my main class looks like this:
package jejt.survival.LOG_test;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
this.getCommand("logit").setExecutor(new CommandKit());
}
@Override
public void onDisable() {
}
}
ok, i try, thank you
whats the yml reader class for spigot
i believe you are looking for YamlConfiguration
so, i changed the name and the error slightly changed
[19:25:30] [Server thread/WARN]: Legacy plugin logit v1.0 does not specify an api-version.
[19:25:30] [Server thread/ERROR]: Could not load 'plugins\logit.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: main class `jejt.survival.logit.Main' does not extend JavaPlugin
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:415) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:231) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassCastException: class jejt.survival.logit.Main
at java.lang.Class.asSubclass(Class.java:3924) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:74) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 8 more
aifht show plugin.yml
main: jejt.survival.logit.Main
name: logit
version: 1.0
author: me
description:
commands:
logit:
description: something
usage: /logit
permission: logit.logit
Hey, how can I play right click animation? Like when you right click grass block with shovel then it plays an animation, how can I play that animation again by sending packets?
convert? you don't
@urban lantern could you send me your jar in dm, it might not be compiled right
do you mean casting it?
/execute store success score output saveall run save-all
How can i get the value of player "saveall" in objective "output" with the api?
event.getPlayer()?
is there a tutorial for this
ive made some plugins, but they were completely autonomous. I need config for this one
i think there are plenty to find?
Cast it to player
Player player = (Player) event.getEntity() if that is what you mean
nvm i think i got it
What's the best way to identify an Inventory?
wdym ?
Well I got multiple inventories which got similar content but different titles. I gotta code an item click for each of that inventory which got the same function. I need an id or something like that.
I assume they are doing something where they need to check for a specific inventory but in an efficient way, not the usual name checking way
Use the view returned from openInventory
A hashmap <UUID, Inventory>
mb my english bad this morning, maybe I misunderstood
hey guys, im trying to use Inventory.remove(ItemStack item), but it doesn't seem to be affecting the inventory. Do I need to do an inventory = *previous*? I'm having trouble finding the implementation of remove. Both Inventory and PlayerInventory are interfaces which extend Iterable.
What does the View contains besides the title?
It’s a unique identifier
you don't need inventory = previous
it's mutator method
Aight I will keep use that, thanks Col!
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Objective obj = board.getObjective("output");
assert obj != null;
int num;
Score save_all = obj.getScore("save-all");
int num = save_all.getScore();
?
Like that right
Hmmm, it doesn't seem to be working. Let me check my logic
Anyone?
void remove(@NotNull
ItemStack item)
Removes all stacks in the inventory matching the given stack.
This will only match a slot if both the type and the amount of the stack match
Parameters:
item - The ItemStack to match against
maybe amounts don't match?
Ohhh I think you may be right
you may use remove (Material)
i found one at spigotmc but its confusing
There are some on yt as well i think, they might be easier to understand
@vale ember it was a logic issue 😉 I was comparing player inv to ender chest inv from a previous method
oh yea. yt has everything
@young knoll Why does an inventory have many Viewers? On the inventoryclickevent I got the option to use event.getView() but on the Inventory i can only use .getViewers() 🤔
Yes because multiple players can view an inventory
example a chest
your friends can take the content of the chest while you have it open
same concept of the inventory here
Yeah but how do I get the inventoryholder of the viewers?
How to get craftbukkit and bukkit as maven dependencies for 1.18?
Do I have to iterate through the viewers and check the uuid @mighty sparrow
Run BuildTools on your machine. It installs those dependencies in your local maven repo.
Wait
For 1.18
Yea
Don't They are a part of Spigot
Spigot-api includes Bukkit, Spigot includes CraftBukkit
nms is neither Bukkit nor CraftBukkit
read the post about 1.18 nms and special source in #announcements
Read the nms section of this post:
https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/
for NMS you need to attach spigot.jar(server) as a dependency to your project
He doesnt need to do that. Its a hacky solution.
Using mvn install:install-file is possible but not advised.
i guess any use of NMS is hacky
Meh sure
hmm but why is that hacky, using NMS is like modding vanilia server, so we could assume that all minecraft mods for client are hacks
Just using NMS is not modding the server. It doesnt change any of the source code.
Its basically the same as using Spigot only that you dont have a fixed API layer between you and
the server.
Does some1 know a way to get an itemstack displayname without the chatcolors?
ChatColor.stripColors or smrh
You can strip the formatting of any String using ChatColor#strip() or something
stripColors
i have a yml that i created and set to compile with the jar. How do I generate that file if the yml isn't already there
Spigot has a utility method for that. JavaPlugin#saveResource(String)
oh, thx
declaration: package: org.bukkit.plugin, interface: Plugin
Its an instance method of JavaPlugin.
Where do you have access to an instance of your JavaPlugin class? -> in your onEnable() method
This means that you could call saveResource() in this context:
@Override
public void onEnable() {
boolean replaceExisting = false;
this.saveResource("cool-config.yml", replaceExisting);
}
The 'this' keyword is optional here. It just emphasises that you are referring to a method of the instance you are currently in.
@fleet imp ^
net.minecraft.world.entity.EntityInsentient doesn't exist, is there a replacement for this?
if i use an Player object for a player who is currently not on the server
does calling methods like .setHealth affects the player or not? because i donno where player data is saved
Depends on what mappings you are using
maybe some operations affect files while others need an active player
sound stupid but i'm just wondering
its also stupid tbh
It does not. You should never reference a Player object for offline players.
What would it normally be? I'm using remapped-mojang
so, will this get the yml in the data folder or saved in the jar
yes
Best practice:
Only use Player objects in volatile scopes. Never have Player fields unless the encapsulating Object also only exists in volatile scopes.
WeakReference
@lost matrix
what's volatile again?
a weak reference
It will save whatever was in your resources path to the current plugin folder (if it exists)
a value that will be changed by mulltiple thread
no
?
is running a Set#contains operation to check if a block is a certain material on every player interact event a good idea?
...how do i set a resources dir path
ah thats on class level
or is there something better for this
why not
What i meant is not the volatile keyword.
Volatile in the sense of fugitive
EnumSet is your friend
no idea what your saying lets translate it
Although material shouldnt be enum at all
It won't be soon™️
ah i understand
why?
Because it is big and ugly
Advise against using Set#contains on player interact, or were you talking to someone else?
@lost matrix I think it's Mob
and how it should be?
Yes. Its really fast and even if you would check 50 HashSets every time someone interacts with a Block you wouldnt notice it in the timings.
ADvise against an enumset for material
ahh
Because of the upcoming changes?
Yes
Plus minecraft becomes data driven, there's a possibility of custom materials in future
MD said it will probably be fine, but
He has also said "To reduce the risk of breakage, please consider avoiding the use of switch statements and EnumSet over enums which implement 'Keyed'."
Pretty sure spigot will be forced to handle Material as an enum for at least another decade as players hold on old versions because of
selectOneOf("performance", "combat-system")
fuck legacy support smh
🤔
how do i set the resource path
If you dont use maven then just throw your yml file into your java project (src folder)
Thats what i meant by "resources path". Its just a file that was thrown into your jar.
quick question: is 16 chars still the max length name for player names?
I mean the "official" limit to get an account, not whether I can avoid it serverside or sth
yes
From Mojangs side: Yes
public boolean isValidMinecraftName(String name) {
return name.matches("^\\w{3,16}$");
}
i have the yml in my resources dir while using maven. yes i included it in the iml
thx, will steal that
Then calling saveResource will just copy the yml file from your jar into your plugins main folder
The joke "md_5 will rewrite bytecode rather than breaking compatibility" becomes true
that brings me back to this, i want it to save it to the data folder if nothing is there, otherwise, get whats in the data folder
if you setMetadata on a shulkerbox and then break the shulker box, is the metadata accessible through the shulker box itemstack's BlockStateMeta, or is the meta from the shulkerbox block lost?
This only saves the resource to your folder if it doesnt exist already and loads it as a YamlConfiguration in either case.
File mainFolder = this.getDataFolder();
File customFile = new File(mainFolder, "custom.yml");
this.saveResource("custom.yml", false);
YamlConfiguration loaded = YamlConfiguration.loadConfiguration(customFile);
Are you on 1.8 or why would you even think to use Metadata?
im just in general curious about how metadata and persistent data containers both behave and im having trouble finding information about how they are implemented.
I have an ItemStack PLAYER_HEAD. How can I get the BlockData for that head?
Metadata -> unknown
PDC -> will be preserved and accessible
ok thanks
PDC is saved in the NBT String
When i create a thread in my plugin, how can i change the name? When i try it with .setName(), it doesn't change anything,
ah i see
I am pretty sure that when placing or breaking a shulkerbox block, it will NOT keep the PDC data that was on the item and vice cersa
You would have to manually transfer them on BlockBreakEvent and BlockPlaceEvent
How can I create a bossbar with auto-refresh value? I want to put placeholder on that
yes that's how I remember too
just create a scheduled task and change the text? lol
I'm guessing by setting the title every x second?
yes of course
ah okay
What do you mean by changing the name of a thread?
what is the best way to transfer? cancel the drop and spawn the itemstack manually?
BlockDropItemEvent and BlockPlaceEvent because in those you have access to both the ItemStack and the BlockState
wha.. You know it is not just plain strings, right?
use ItemSpawnEvent and use the consumer
It has efficient compression and such
Its something like Craft Scheduler Thread - 22
At defautl
is it better to use one scheduler for every player or scheduler every player?
My code
Save saveFiles = new Save();
saveFiles.setName("TheName");
saveFiles.start();
Sure i just always use Strings as my primitive and throw json in there...
Its a binary format you are right.
I'd use one scheduler for all players
okay thanks
ah, i'm the opposite; always using byte[] or nested persistent data containers 😄
You need to use the the TileState org.bukkit.block.Skull
Then you can transfer the owner form your org.bukkit.inventory.meta.SkullMeta onto your BlockState
I wasn't the one who asked the question 🙂
XD
but I don't have a TileState right? I only have an ItemStack
I do NOT want to place the head, I just need the blockdata that would be created when it would be placed
currently checking whether this works
return Material.PLAYER_HEAD.createBlockData(blockData -> {
((Skull)blockData).setOwningPlayer(getOfflinePlayer(string));
});
however that won't work for base64 textures :/
quick question
Ha! You dont have player profile api on spigot!
if use default:
BlockData groundData = Bukkit.createBlockData(Material.PLAYER_HEAD);
BlockData wallData = Bukkit.createBlockData(Material.PLAYER_WALL_HEAD);
do i need break before default: case to stop the execution
but I have in authlib, so?
You still cant set it for skulls
Skull is a TileState. You cant cast the BlockData to a TileState.
If you're on j16+ use enhanced switch
of course? Been doing that since 1.13 in angelchest
i used it but i need different execution mode
i need breaks
since i dont want pyramid of hell
im refactoring big chunk of code
thus why i need break
that way i can execute the same block of code for two different clauses without copy pasting
for each one of them
case case1, case2 -> {}?
both cases have different code in them too
Then i have a recommendation:
Dont use switch statements at all 😄
Or if-else blocks
This is why the material enum is cursed
im just askin one simple question
does default: flow in
without break
from other cases
case BLABLA:
default: {
System.out.println("Others and blabla executed it");
}
can i do something like this
will it flow in
Yes. Always break after a statement.
so default: is not an exception
i can expect the same results as using simple case x:
for this particular situation
does the itemspawnevent triggers when a player drops an item
i dont think it will trigger but just to be sure
heloo whats the probvlem here
I dont think so
use ternary operators
XDDD
anything
ah
thats a simple example
how do i create a world without making a folder for it
but can I achieve that without placing the skull? I don't find a way to get a Skull from an ItemStack
i dont think it is possible, at least with the api
well where else would you save it if not in a folder?
i want to make a virtual world
to interact with
the world shouldnt be saved at all
I made this funny line of code and it doesn't like the saveResource:
if(!(Bukkit.getServer().getPluginManager().getPlugin("MineCord").getDataFolder().exists())) {
plugin.getResource("config.yml").saveResource(Bukkit.getServer().getPluginManager().getPlugin("MineCord").getDataFolder());
}
but it would still create a folder, right?
erm what the heck are you trying to do
just not safe the changes
yes, but i don't think a folder causes problems, you can easily delete it afterwards
what is an api and how does it work the definition in java termonology is confusing
if data folder doesn't exist => create data folder and config file
yea it kinda does, so i would like to have an option that doesnt create a folder
there's no api in java terminology, overall api is application programming interface
a way to interact with a program via code
private static final Map<Character, Consumer<String>> someStuff = new HashMap<>() {{
put('x', SandboxCore::doX);
put('y', SandboxCore::doY);
}};
private static void doX(String value) {
System.out.println("Im doing X: " + value);
}
private static void doY(String value) {
System.out.println("Im doing Y: " + value);
}
private static void doSomethingElse(String value) {
System.out.println("Something else happened: " + value);
}
private static void apply(char c) {
someStuff.getOrDefault(c, SandboxCore::doSomethingElse).accept(String.valueOf(c));
}
public static void main(String[] args) {
char x = 'x';
char y = 'y';
char z = 'z';
apply(x);
apply(y);
apply(z);
}
Outputs
Im doing X: x
Im doing Y: y
Something else happened: z
HashMaps scale O(1) while switch case scales O(n)
I always prevent switch statements and chained if statements wherever possible.
I never checked to be honest... i just assumed it as primitves dont have hash values...
huh
umm FastUtil primitive maps exist for a reason
Yes looks like runtime complexity of switch-case is O(n)
Its a bit weird because they have a fixed size
but still
Maybe the objects have abysmal equals implementations XD
just do saveDefaultConfig()
F
weird = best
looks a bit like my bf
aaahahaha
how do I make it accessible then lol @lost matrix
for the texture on the model I know
but
on the grass block
avoid that
something something have a texture in your texture folder and refer to that texture in your model.json
to get an actionbar, should i use the api or sender.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(""));
sure why not. If it isnt deprecated then go for it
Cannot be accessed from outside package do i have to implement it then
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
cant get it to work
What spigot version?
1.17.1-R0.1-SNAPSHO
Show some code pls
sender.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent.fromLegacyText("hrll"));
thats a paper method iirc
It is
huh?
99% sure that spigot also has those methods to send action and titles to players?
No
no
Player.Spigot has
This is the spigot method
wrong TextComponent import
This is not valid java:
new TextComponent.fromLegacyText("hrll")
Remove the new
Cannot resolve method 'sendMessage(net.md_5.bungee.api.ChatMessageType, net.md_5.bungee.api.chat.BaseComponent[])
player.getLocation.getX/Y/Z
Thanks Coll
the textures are missing because they aren't pathed in the resource pack correctly
and the xray effect is due to cullfacing since you're using a solid block and not occupying space otherwise occupied with a full block
no this problem I know I just put none, im not at the modeling phase yet
bump
theres no way to fix this
?
How can i use ansi-colercodes in my program? When i simply hang it behind the string and executeit in Powershell, it doesn't change but basically prints the color-code out too!
not practically
my advice to you is to use the bottom slab variant
do something like this
but even then, understand that the model cannot be rotated
so it would always be facing the same way
but you could make it face random directions
you are doing your model in blockbench, right?
He is
there might be a way to fix the cullfacing, but it's not something I'm really familiar with
but I still would advise making it the half slab instead since the hitbox will be less bizarre for such a small object
Please someone help, I wanna change something about ore distribution, but I don't understand how to make my own worldgen which changes only that and keeps the rest of 1.18 generation as it is
Are there any tutorials or something else I can read about that?
https://bukkit.org/threads/tutorial-how-to-customize-the-behaviour-of-a-mob-or-entity.54547/ Is this still the best method for achieving something like this?
Each entity in the game has it's own class that defines how it behaves, for example the way skeletons work is controlled by EntitySkeleton. To modify...
Im sure there is some API methods now
erm what's the name for consumers without any arguments again?
like I wanna pass a void function with no parameters as parameter into another function
I need something like this:
public class MyClass {
private Consumer consumer;
public MyClass(Consumer consumer) {
this.consumer = consumer;
}
}
and then do something like this
MyClass thing = new MyClass(() -> {
// do stuff
});
am I stupid or is that just a runnable?
Just a runnable
On paper, there's mob goal api
Looks perfect. That will DEFINITELY compile and run fine without problems
The red means it's working
red = running
imagine being red/green colorblind
A question if you have a running a jar on the JVM and its obfudcated you can get it source code vía ASM (assamble) library right?
you will always only get the "obfuscated" byte code
umm
Ahh ok
there's some deobfuscated for some obfuscators
although they never truly restore the original code
Yes I know
But i dont know why no one recommend obfuscation when some jar have never been de obfudcated up to know
I use allatori on all my paid plugins^^
even on my library in free plugins to make it a bit smaller and faster, though with different settings of course
Thanks for recomendación
but allatori is 290$
At its paíd?
I thought I seen it public on github
Smh just dont obfuscate your plugins
you must not use it for commercal stuff though
Thst doesnt really help
it does help. never seen any leaks since I got allatori
of course people could deobfuscate it, but they simply don't take the time and leak another plugin instead lol
hi i'm currently working on my GUI, so i displayed all Materials with it. However some Material are not displayed because of lack of ItemMeta or something. How what condition use to get only Material that can be display in Inventory?
Same. If people want to crack your plugin, they will
check isItem
yes, but until now people just didn't after I started using allatori
Anything with isItem == false should not be in an inventory
i forgot an english word. the pronunciation is something like "cooldown". help!
What
Im really stress btw. I have been looking for a java socket framework. And people only recommend Netty and Apache Mina. When they are too big for building simply things
meh does not work :,
ugh how can you code with such a background lol
what's the item that's not showing?
Looks like air
i guess air
yeah true
You can exclude that too with isAir
maybe
pagination is done corretly
anyone got a quick regex for me to check whether a string is 32 numbers? ^^
your page calc is not correct?
Simply dont let put air item on your inv
.+{} or something
\d{32}
(.+){32}
thanks!
define pushing
How can I disable players colliding with each other, I tried to do this when they joined:
e.getPlayer().setCollidable(false);
But it didnt work
player.spigot().setCollidesWithEntities(false)
What that
I think
Collides?
What is inventory extraContents ?
left hand
deprecated
Alright thx
whats deprecated?
the method you sent
lemme check
If you are using eclipse and tells you deprecsted its because its a yeat
declaration: package: org.bukkit.entity, interface: LivingEntity
I have never liked using eclipse
yeah it's moved to LivingEntity
i just tested that allatori demo and idek what my own plugin does now
you want your custom spigot fork?
does it work though?
I can help you with allatori if you like
im on 1.18 btw
idk havent tested it i dont have a server setup rn
important: you must not rename your main class
but its some weird stuff it did
also not all methods you are overriding
Like it has to be called Main?
Yes because i will tríed to implemente a server-client and viceversa, messaging system without players
?main
no, you just must not rename it
u can rename it?
here's an example allatori config: https://paste.jeff-media.com/?e20564f898931b16#7xXbbTsj71fcUqc3McBKpCMkf3aLH8GbkLkJrMmsxDz3
Post and share your source code or server logs here.
When would i have renamed it i guess is what im saying
when using allatori of course lol
event.getHook().setHookedEntity(null); isn't working for me, and there is no errors. .-.
mfnalex can I then dm u?
https://paste.md-5.net/omagataxab.js This what it did to my onEnable almost looks like it wouldnt work
sure
I wanna talk to you about obfuscator if you have no problems
It just put a random 'this;' in
sure, feel free to dm
what does that even do lmao
black magic
and it used to just be getCommand now its "\027\030\022\r\030\026\037".getCommand
whatever that is
string obfuscation
don't worry about what it does
it's very complicated
^^
it can even rename your variables to use keywords
actually hold up
woah
tell me how this getCommand("faction").setExecutor(new FCommand(this)); becomes this "\027\030\022\r\030\026\037".getCommand(NotInFaction.ALLATORIxDEMO((String)this)).setExecutor(new FCommand(this)); saveDefaultConfig();
NotInFaction is an expection i made that appears no where in that class lol
it moves certain stuff to other classes
oh ok
the ALLATORIxDEMO method is probably the string decryptoin method
How to set armor contents ?
when my inventory instance is of inventorytype player
declaration: package: org.bukkit.inventory, interface: PlayerInventory
thats so weird cause this is the entire expection class is just comments https://paste.md-5.net/ebasaqawug.java
Thanks @tender shard
To make a core would you need to make a separate plugin for bungee so it can work with another plugin from another server?
Thank you it works
it's byte code. your decompiler wasnt able to decompile it so it just shows the byte code
sorry wrong reply
@olive lance
^
np
ohh ok
I suggest ReCaf, it's one of the best decompiler GUIs imho
bet
I don't think you're allowed to share CMI's byte code 😛
sure, depends on your settings
here's settings to just make it smaller and faster:
Leaking bytecode is still leaking
Those would be helpful
Post and share your source code or server logs here.
Cause im open source just wanna make it fast as possible
yea
Anyone here good with streams?
I'm looking to check if a list of an abstract class contains at least 1 of a certain subclass, using a stream
It still did that string encryption thing tho with the exception class
it removed almost 100kb from my library lol
yea my plugin is only 55kb right now so i wasnt expecting much
then you didnt use my config I sent? it has string-encryption set to disable
Somebody know if we have class A with 300 line of code, and class B 150 code lines that inherits class C with 150 code lines.
After compilation to .class files both classes A and B will have 300 lines of code inside?
Yeah it definitely used it and had the string encryption set to disable. maybe thats not considered that? idk why it wouldnt tho
hold up lemme try 1 thing
restart my decompiler
I cast Inventory to PlayerInventory ? @tender shard
Ok it did work
If you know it's a playerinventory, yes
alright
How do yall name your projects if its two words do you do TestWater or Test Water
ugh
never spaces
btw how would you name this method:
public static UUID getUuidFromString(final @NonNull String string) {
if(string.length()==36) return UUID.fromString(string);
if(string.length()==32) return fromStringWithoutDashes(string);
throw new IllegalArgumentException("Not a valid UUID.");
}
getUuidFromString
or
getUUIDFromString
?
UUID
yeah I know it's just for my OCD
aight I'll go for UUID
sometimes intellij is a bit stupid
it doesnt even suggest to create that method lol
the only reason why you would do UUID is because its a acronym
String#replace and String#replaceAll really have misleading names
they should be called "replace" and "replaceRegex" or sth
kinda. replaceAll will accept a non regex
well, other IDEs are even more stupid 
ugh
yes
visual studio is the worst
vsc isn't even a ide
and eclipse's maven integration sucks
but it's fine for py + js
I know a few people using VSC for java and
I really wonder
why do they make their own life so hard
i use it sometimes when my Intellij idea bugs
getting IntelliJ Ultimate was the best decision I ever made
uh, i won't pay that much
I got a for free
bruh
somehow even law students get coding software for free at my university
lmao meanwhile I can make as many email aliases as I want and get free stuff again and again XD
what's the command line again to shade with maven?
mvn package should run the shading plugin
You only need an OS project and you can get it for free
if you have declared it in your pom
what is an OS project?
oh open source
really?
open source
how?
whats wrong with the community edition
well I got it anyway, just curious
or netbeans :>
nothing
but why not use Ultimate if you get it for free 🙂
it has some MySQL features added, I dont know what else
yep
Md uses netbeans
a profiler I belive
Im pretty sure he uses notepad
yeah
probably
or emacs
that would be legendary
sometimes I force myself to use vim but emacs? that's a whole nother level
yeah I can finally pay my rent too lmao
three AngelChest's per day and I got enough money for that day lol
: o Well, my most famous proyect (with md_5 project) it's my bungee fork

which one?
no please god
I'm still using waterfall but seems like I gotta switch to Velocity soon
I won't say it here due i will get banned?
I thing that there's some type of rule of that

I read the rules 20 times, I don't think there's a rule about that 😛
When creating multiple config/data files, should i create a class for every one of them? or should I create instances of a class and reload/edit them by name
(im followed a codedred tutorial and was wondering how to continue further)
never heard of that, I'll look it up 😄
I just create one YamlConfiguration per config file
I won't spam here
I think it's because paper said they'll drop bungee / waterfall
they said probly not 100%
slowly remembers Heartbleed...
are you creating static varibles? I have a DataManager class that has reload/save/default methods, but the file names are hardcoded.... should i just make them take a parameter instead?
fun fact: the Heartbleed bug was introduced into OpenSSL by a student from my town's university lmao
And if even that happens there a lot of people that will still mantaining waterfall
XD
sometimes I do that, yes. Most of the time, no. I just have something like this in my main class:
@Getter private final YamlCOnfiguration itemsConfig = new YamlConfiguration();
{
//if file doesnt exist
saveResource(items.yml);
itemsConfig.load(//items.yml file);
}
I'd already be happy if bungee API would include YamlCOnfiguration lol
my bad* Modern proxy dependencies
My bad i was going to mean the proxy imself*
Well, velocity guys doesn't need to use Firewall or even antibots to avoid this.
am I the only one around here who always accidently drags that thing somewhere instead of just resizing it like I wanted to?
Also forks won't be that famous.
Well, u improved in some way the proxy applying the limit of bytes on the protocol, but are some other type of layer attacks that doesn't follow it.
have you opened a bug report
Well i allways thinked that u just didn't want to fix it or something like that
yes I purposely make my software as bad as possible and hate improving it
Me too
XD i don't know i thing that u saw that are 400 bungee forks not because bungeecord fixes them.
Where can I find this in the buildtools? https://imgur.com/a/O9mO9Yj
I didn't say that just I thought that was hard or implied a lot of changes.
what do you mean
looks like the maven repository
that's because it is
what exactly is your question?
where you can find the finished .jar, outside of your local repo? o0
Well, i don't thing that it's a bug but can be avoided, mostly that's why people switches to the knowed proxy.
well open a feature request; though that wording makes me skeptical
because you see people that fork bungee, add absolute garbage that does nothing, and then claim its an improvement
what "bug" are you even talking about? 😄
yeah but there some little % that works good.
packet api when?
ProtocolLib
nah ProtocolLib sucks
Ill give u a question why you use waterfall instead bungeecord.
it's 10 times more complicated than NMS packets
Well is not really a bug as i said?
no idea, because I also use paper on my server. bungee would be fine too I assume
you havent said what it is at all
yeah just wondering what you are talking about at all
I only recently made up my first proxy server and just instantly used waterfall without any proper reason
well im trying to update it so I can use the new buildtool
huh? Just get latest BuildTools from spigotmc and then run it
?buildtools
?bt
Uh, well i thing u know that most of people won't use bungeecord or + an antibot always due the fear of getting crashed off.
ProtocolLib is bad
and hard
maybe explain what your problem is, then
yeah I absolutely don't like it
😂
lol
IMO easier to use
Tbf I mostly only use it for listeners
I don't think so.
packet.setDoubles(...)
with NMS I just use the proper constructor^^
so I can see in my IDE directly what it needs instead of looking up everything on some website
also I can use the proper packet names instead of Packet.PLAY.OUT.WHATEVER
yeah for listeners I can undersatnd that
And yeah, really hard thing to do on a proxy level give a solution to avoid "anti-bots" getting benefices by your way.
That's why velocity it's getting more famous.
if(ProtocolLib.isBad()) {
System.out.println("Change your library, otherwise your server will be detonated in 3... 2... 1...");
}
https://pastebin.com/dtbtkKFF Can anyone tell me whats going wrong with these logs? My server dev is currently away and it needs fixing asap
some json file is corrupted
just remove the if, it'll run anyways
Aight thx for your help
assert ProtocolLib.isBad(); // will always be true
K
im gonna post my issue now
because most issues rn seem solved
having some config weird things happening, i have the default config as a resource
it loaded right, and i set the config once and restarted.. and the config reloaded, and the values were displayed correctly
now, i'm trying to reload the config in-game, or on console (via-command) and it does not reload the new values... not exactly sure why either, because i dont have a reload config on my onEnable()
and like heres the config
show your code to reload pls
😭
that's eclipse
- why do you save your config after loading it?
idk i used code from an older plugin i made with a config
Error 404: No IntelliJ IDE found.
that plugin works on reload
- why don't you use the inbuilt reloadConfig() method?
Error 404: No fucks given
i tried that before, and it didn't work... i'll try it again assuming i did something wrong
it makes no sense to save the config directly after loading it
also your file is called config.yml, you can use bukkit's javaplugin's builtin getConfig()
this one?
you only need to create your own FileConfiguration / YamlConfiguration objects if you need additional config files NOT called config.yml
bruh my older plugin, i just fit the code from it 😭
must be leftover from 2012 code then 😄
😭
I'd suggest to get rid of all your custom config code and use the builtin methods
they are made to make your life easier 🙂
thats my only custom config method
everything else (making the config) is built in
how do you access your config?
file?
by doing yourPlugin.getConfig()
oh yeah
yeah but the code you sent does not reload JavaPlugin's getConfig() but only your custom fc config
np 😄
yeah because log4j is so awesome lol
is there any good way to get the shulker box item that spawned as a result of a block getting broken by a piston?
i already have a bad way of doing it, but im searching for a better option.
what's your bad way?
BlockDropItemsEvent?
store the location of where the block was (method of storing doesn't matter) then in ItemSpawnEvent get the spawn location and check if the locations match
yeah ignoring this 2021 XD
docs say:
"Called if a block broken by a player drops an item"
hm
good question
what's the updated method for sendBlockChange?
sendBlockChange
it still exists
Yeah but it's deprecated sadly
No it's not
The other one is not
Player#sendBlockChange(Location,BlockData)
player.sendBlockChange(someLocation, Bukkit.createBlockData(Material.STONE));
Oh wow
Isn't there also Material.X.getDefaultData or something
that code looks a bit... messy 😄
it is
But i had to hard code it
It's a cage with a 3x3 room with invisible barriers
I am dumb at math
So ...
I understand 😄
yeah I was an A student in school in math and a year later, I forgot everything
anyway, just use Bukkit.createBlockData(Material) 🙂
Only for players, because it can be spoofed
thx
reason for deprecation:
This value is controlled only by the client and is therefore unreliable and vulnerable to spoofing and/or desync depending on the context/time which it is accessed
as @young knoll already said
so yeah, better use Entity#isOnGround
although it's a bit strange that the subclass declares a non-deprecated method that it overrides as deprecated lol
Quick Question
even when casting to Entity, doesn't it still call the isOnGround method from Player?
yes
I just made my own method that involves subtracting a small amount from the players Y value
And checking the block there
the method sucks, but anticheat developers are the worst
thats the only reason it exists
I agree lmao
maybe another method could be added to get the actual Entity's isOnGround?
that is the entity's isOnGround
vanilla lets the client set it for who knows why
thats why things like nofall exist
Oh mojang
Movement really should be server side
I still remember when I started MC, multiplayer and singleplayer had different code
then some update came and single player was just local multiplayer from then on
WOW intellij really is stupid sometimes
I removed the "player" parameter from new CustomBlock
and now intellij says "can't find block.getState()" instead of telling me to remove "player" from "new CustomBlock"
is there a shortcut in intellij to comment code?
uh does not work for me?
yeah me too
use / from your numpad
it will work
Ctrl+ Numpad /
the one above the 8 ^^
yeah you could probably change it to Ctrl+Shift+7
Ctrl+7 is more comfy i think
but then toggle block comment would not work so youd need to set that to Ctrl+Shift+Alt+7 or sth
yeah makes sense
lol
still having problems with comparing inventories.
I'm just not good in comparing stuff i guess XD
inventories will be == if they are the same
if only their content is the same - you'll have to loop over them I think
yeah, Inventories are just Iterable<ItemStack>, it doesnt have their own equals method
so equals() is the same as == for inventories
still, use == for reference and .equals for comparison for convention 😼
yeah but equals in inventories is the same
👍🏿
so you need write your own method if you just wanna compare the contents 🙂
I think i will develop my entire plugin once again sometime
Refactoring takes too long lol
However refactoring this was not useless because I can write my new version of it even easier now.
Yea sometimes you just gotta scrap everything and rewrite
It's annoying but a must-have if your plugin doesn't take care of name conventions, etc.
I am shocked how much my coding style has changed over years...
Yeah
yeah I do that every other year too
I mean
I don't rewrite entire projects that are too large
I will often rip out and replace functions or classes though
Think I will open twice IntelliJ and just recreate it by copy pasting and like comparing what I could do better.
I won't copy paste everything dw lol
Just some pieces
Step by step and then I improve each little part
I normally refactor everything with git
I have rewritten custom enchantments so many times
so I can always go back
They're kinda hard to do right
fk how do I create a random again between 2 numbers?
wasn't it random.nextInt(high + low) + high;
Or something like that
package de.jeff_media.jefflib;
import lombok.experimental.UtilityClass;
/**
* Random number related methods
*/
@UtilityClass
public class RandomUtils {
/**
* Returns true with a specific chance, otherwise false, with a range between 0 (always false) and 1 (always true)
*
* @param chance chance to return true (0-1)
* @return true when the chance succeeds, otherwise false
*/
public static boolean chance(final double chance) {
return getDouble(0, 1) <= chance;
}
/**
* Returns true with a specific chance, otherwise false, with a range between 0 (always false) and 100 (always true)
*
* @param chance chance to return true (0-100)
* @return true when the chance succeeds, otherwise false
*/
public static boolean chance100(final double chance) {
return getDouble(0, 100) <= chance;
}
/**
* Returns a double between {@param min} (inclusive) and {@param max} (exclusive)
*
* @param min min
* @param max max (exclusive)
* @return double between {@param min} (inclusive) and {@param max} (exclusive)
*/
public static double getDouble(final double min, final double max) {
return JeffLib.getThreadLocalRandom().nextDouble(min, max);
}
/**
* Returns an int between {@param min} (inclusive) and {@param max} (exclusive)
*
* @param min min
* @param max max (exclusive)
* @return int between {@param min} (inclusive) and {@param max} (exclusive)
*/
public static int getInt(final int min, final int max) {
return JeffLib.getRandom().nextInt(max - min) + min;
}
}
that's my RandomUtils class
just copy paste what you need lol
This does it.
What's it look like?
Currently making some fairly big changes, but it's on my github
Here is a sample enchantment file
Yes
I got a lot of money by him