#help-development
1 messages ยท Page 2063 of 1
Item gets removed on death
Which is why a curse of vanishing + curse of binding pumpkin is a great way to troll your friends
InventoryClickEvent#getCurrentItem() returns null when placing the item, am I using the wrong method?
D:
so you're telling me Mojang really spent one line to set a condition that makes heads not have enchantments, just to ruin my career?
;_;
?
amount iirc
I call it Mogiang
Yeah and?
Tiny bit of help with this?
Could you show your listener
(I do use player that's just a quickly typed method to show what i do before actually calling methods on the item stack)
Make sure that you're actually replacing an item in your inventory and not just placing it
ye
So what's the issue?
bump
The method your using gets the item in the slot
Not the one your placing
Which is why it is null
you did something wrong in your pom.xml/Metrics.java
oh
You want getCursor
Hello, I am new in the development of plugins, could you tell me where should I orient myself to add predefined things like on this screen to my commands? Thank you ๐
TabCompleter
its like CommandExecutor
but it returns List<String> for the tab completions
rather than a boolean
and is called each time you add a character
using gradle and I donโt understand gradle as I usually use maven
dang nw
Ohh okay ! I will check in this direction thank's !
np!
@ivory sleet Gradle help
Something like that
if you don't want to return completions (meaning that you have none), return null
otherwise a list with some text
you can use args to check what args there are
exactly like in a command
Wherever intellij put them, I cloned the project from Github and optimized a couple things. I didnโt touch any of the gradle related stuff though.
what task r u using to compile?
Ye gradle build won't cut it
Sadly they didn't setup the reactor task properly
๐ญ
I managed to do exactly what I wanted thank you for your precious help! Have a good evening ๐
is it a good idea to manage chat and players data from bungee plugin ?
Player data from bungee sounds pretty useless
Your consumer would be the spigot plugin for that data
like friends list and "network level"
oh yeah you cant use guis trough bungee ?
clienrside ?
client side ?
Np ๐
hey am getting an error code here please someone help i tried so many things
config = plugin.getFilesManager().getFile("MySql").getCustomFile();
filesManager class
private final BCore plugin;
private final LinkedHashMap<String,CustomFile> customFiles;
public FilesManager(BCore plugin){
createFile("MySql");
customFiles = new LinkedHashMap<>();
this.plugin = plugin;
}
public void createFile(String name){
name = name + ".yml";
CustomFile file = new CustomFile(plugin, name);
customFiles.put(name,file);
}
public CustomFile getFile (String name){
return customFiles.get(name);
}
}```
and the CustomFile class
private final String name;
private File file;
private Configuration customFile;
public CustomFile (BCore plugin,String name){
this.name = name;
file = new File (plugin.getDataFolder(),name);
if (!plugin.getDataFolder().exists()){
plugin.getDataFolder().mkdirs();
}
if (!file.exists()){
try{
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return;
}
}
try {
this.customFile = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) {
e.printStackTrace();
}
save();
}
public void save (){
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(customFile,file);
} catch (IOException e) {
e.printStackTrace();
}
}
public Configuration getCustomFile() {return customFile;}
public File getFile() {return file;}
public String getName() {return name;}
}````
bungee
if someone helps i will very much appreciate it i cant find why
null pointer here config = plugin.getFilesManager().getFile("MySql").getCustomFile();
Is there a way to get the itemmeta of the placed block in BlockPlaceEvent from before it was placed?
or would I need to cancel the event for that?
get it and then continue?
BLockPlaceEvent#getItemInHand()
thx
Hey, does anyone know how id be able to get the latest addition to a file and make a gui from it. For context Im making a gui that logs recent player deaths, the player deaths are being stored in a file, id like to know how I can get the latest changes to the file and update the gui accordingly.
Ehhh, don't store the player deaths in a file is basically the end here
Well txt file at least
Database would do wonders here with a timestamp you can sort over
(and an in memory cache)
How can I check if damage was caused by a certain item?
check the main hand item of the attacker in entitydamagebyentityevent
alr
is there a way to change the knockback of the projectile
don't think so but I'm not sure
hmm ok
all I can think of is cancelling the event, then doing the damage manually
I'm trying to make a knockback snowball
ohh
I thought you wanted to cancel an existing knockback
okay imagine this:
you want "100% knockback"
e.g. making the hit entity have as much "knockback" as the snowballs velocity
@EventHandler
public void onSnow(ProjectileHitEvent event) {
event.getHitEntity().setVelocity(event.getEntity().getVelocity().add(event.getHitEntity().getVelocity()));
}
if it should be less, just multiply the snowballs (event.getEntitiy())'s velocity e.g. with 0.5 for 50% or 0.1 for 10% etc
just start with this:
@EventHandler
public void onSnow(ProjectileHitEvent event) {
event.getHitEntity().setVelocity(event.getEntity().getVelocity());
}
this will make the hit entity get exactly the velocity of the snowball
lol it's more fun if you multiply the velocity
lol
knockback 1000 stick of justice
wtf happened to my formatting
ctrl + alt + L
Hello,
I'm new to MC plugin development. I'm a Python programmer but am learning Java to have fun on my MC server.
I'm trying to trigger something when a player is in range of a beacon. That part was pretty easy...
public static void onEntityPotionEffectEvent(EntityPotionEffectEvent event) {
if (!event.getEntityType().equals(EntityType.PLAYER)) {
return;
}
if (event.getCause().equals(Cause.BEACON)) {
Bukkit.getLogger().info("Player is in range of beacon.");
}
}```
But I want whatever I triggered to be disabled when the player leaves the beacon's range.
Initially I tried to do something like:
```if (event.getCause().equals(Cause.EXPIRATION)) {
Bukkit.getLogger().info("Player left beacon's range.")
}```
But I quickly realized that while this works for when a player leaves the beacon's range and the effects wear off, it would also work if a player drank a potion and it wore off while he's still in beacon range.
I don't necessarily want to look for a beacon in nearby blocks because I imagine that would be an intensive function.
I like the idea of using the EntityPotionEffectEvent as a trigger. If there was a way for me to verify that the effect that expired was from a beacon, that might work but I haven't found a way to do this. I was trying to take a look at the EntityPotionEffectEvent.java source code to see how Cause.BEACON was written but I can only see an ENUM that's passed to the EntityPotionEffectEvent class. I'm not sure how the getCause() method works behind the scenes.
Any tips would be extremely appreciated!
because id's were depreciated if my 1.16 server allows any version to join would anything under 1.13 not work as there is no use of id's?
if that makes sense
nests:
2d3eee13-e170-4e72-86ff-b6868b1edded:
name: unnamed-nest-0
level: 1
2d3eee13-e130-4e72-81ff-b6868b1edded:
name: unnamed-nest-1
level: 1
2d3eee13-e110-4e72-82ff-b6868b1edded:
name: unnamed-nest-2
level: 1
is there a way that i can get the LIST of UIDs in the "nests" section of this yaml file
if anyone knows a method even if it entails reorganizing the yaml structure let me know
am i using yaml wrong?
pls i've been trying to do this for 3 days lmao
use getConfigurationSection()
Which is the command tu buidl spigot 1.18?
tried this already, but i'll try to reimplement it
getConfigurationSection(โnestsโ).getKeys(false)
do you want 1.18 exactly or .2/.1
Just 1.18
use --rev 1.18 instead
Didnt work
Oh nothin
Im dumb
I didnt download java 17 that why
ah
trying to make my code readable/ nicer to navigate. I want to have sections of code which i can shrink (like subroutines). I know you can do it in c# but im not too sure how to do it in java/eclipse
for example in c# you have this
What's equivalent to implementation fileTree() for maven
eclipse has code folding but not for what i would like it to do ๐คฆโโ๏ธ
Yeah, we use cold folding comments in the Material enum, but it only auto folds on NetBeans and I think IntelliJ
There might be an extension for Eclipse to add those types of comments
Never really looked for one tbh
How would I make it look like when tnt explodes the block go flying?
I see it on servers but I cant figure it out
They turn some of the blocks into falling blocks and apply velocity to them
Hmm
oh okay
i thought i might need to make a million armor stands
but spigot has a createFallingBlock method
can any1 here explain to me how i can easily get a Set of classes that contain a certain annotation?
You can use a heavy lib like reflections or you can do it yourself. Are the classes loaded?
I do it using JarFile
no
yeah, just switched my project over to IntelliJ. I don't mind working in a different ide but if I cant fold my files I'd get something mixed up eventually.
i kinda want a lightweight way without any clunky libs
I wrote something to do that here. The library uses only base java methods so it's a super lightweight reflection library. It's also still in development so it's extremely buggy. https://github.com/MikeTheShadow/AutoRegisterLib/blob/master/src/main/java/com/miketheshadow/autoregister/util/ReflectionBase.java
looks interesting. but i need a way that will also work independent of a plugin
You can make it not plugin dependent
just dont print the collection
How do I make a baby/thicc wither? Do I need nms?
In 1.17.1 I am confused in NMS on which is the thing for Remove_Player in PacketPlayOutPlayerInfo since it is different in 1.16.5 and below.
Probably am going to need to know the new one for add_player too.
can a projectile be converted to a itemstack in 1.15.2
#getConsumable does not exist in 1.15 is the reason for asking this
It wonโt have the data
Correct
Um?
i made a custom command and gave a permission on join to use it, but it doesn't show up in tab complete if the player isn't opped
the command is usable though
is there any different in Bukkit.getServer.getWorld(worldName) & Bukkit.getWorld(worldName) ??
and can a spawn location be null?
no, all Bukkit.x methods are the same as Bukkit.getServer.x
read the docs/annotations
I love the fact that Bukkit also has a setServer method
Rip
Field field = Bukkit.class.getDeclaredField("server");
field.setAccessible(true);
field.set(null, myNewServerObject);
does someone know whether there's some kind of EnumSet Collector?
huh why is EnumSet.of so weird? why not just of(E first, E... rest)? Why is there a separate method for of(3 elements), of(4 elements), of(5 elements), ... o0
also huh am I stupid or is intelliJ stupid? Isn't the "bufferedReader.close()" statement useless here?
public static boolean replaceStringsInFile(final File file, final CharSequence toSearch, final CharSequence replace) throws IOException {
boolean changed = false;
try (final BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
final StringBuilder inputBuffer = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains(toSearch)) {
line = line.replace(toSearch, replace);
changed = true;
}
inputBuffer.append(line);
inputBuffer.append(System.lineSeparator());
}
bufferedReader.close();
if (changed) {
try (final FileOutputStream fileOut = new FileOutputStream(file);) {
fileOut.write(inputBuffer.toString().getBytes());
}
}
}
return changed;
}
So you read the file then want to write to it? Wouldn't that require the file to be closed?
try with resources generally invokes the close method
1s let me format the code
the code works fine
but to write to a file doesn't require it to be closed if its only being read
I am just confused why intellij doesnt say the "close()" method is unneeded
because it is proper
in case the try with resources fails for some odd reason, it should still close out
Intellij supports early closing of resources ๐
if I move it to the bottom, it says it's unneeded
Though intellij gets mad if you destroy a thread yourself
because the try with resources reaches the close before the statement if you move it to the bottom
however the way you have it, is actually proper
k I'll just leave it like this
should always close out resources early when ever possible even if using try with resources ๐
others may not like doing that, but whatever lol
Is there a better way of getting the instance of the main class?
I use it in namespacedkeys for example
I take after what Mojang does and I like to make a big class of keys and register them all in 1 go using a method.
not better but less annoying
With getters then?
opensource?
No. 1s. I can show and example
ah wait, you're talking about namespacedkeys
What does load() do?
So this isn't necessary?
you guess
It saves you on having to do that every time you want the key
its just DRY
If you only use it once it's w/e but when you're writing a plugin that is basically built on it then it's different
yea, mine kinda is
Yes, why?
Cause this
NamespacedKey key = new NamespacedKey(ComplexMMOStats.getInstance(), "whatever");
PersistentDataContainer container = stack.getItemMeta().getPersistentDataContainer();
container.set(key, PersistentDataType.INTEGER,5);
becomes
PersistentDataContainer container = stack.getItemMeta().getPersistentDataContainer();
container.set(CMMOKeys.Key, PersistentDataType.INTEGER,5);
bro these mfs
they seem to accept anyone but they didnt accept me lmao
like uh no offense
but your trial plugin is definitely worse than my level
idk how they didnt accept me
Yea it definitely wasn't "good"
oh
lmao
i made it eitherway and they denied me
after making me wait 6 days for them to review it
they gave me a chest that spawns on death with a sign. It drops its content on close
and despawns
BRO
not the most difficult haha
I have got some but I don't do them very often
I maybe got 2 in total where 1 client just closed it before I could get started
Is there a better way to convert an Stream<Path> to an Array<Path> than to do Stream<Path>#toArray?
But yea, ur clearly more experienced than me, I'm sure you can make it through
If I cast it to an Array<Path> it throws an ClassCastException
What's wrong with using .toarray?
It returns Object[]
the real issue here is using a stream ๐
probably just need to cast it
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.nio.file.Path;
ยฏ_(ใ)_/ยฏ
like
Path[] theArray = (Path[]) theStream.toArray(new Path[0]);
What's your initial stream
those mfs tho
wait isnt there a .collect method for this
I use Files#walk with a Path to a folder as the first parameter
do they like randomize the whole shit
thats pretty unfair
everyone i know got something easy
If they gave you a duels core, I guess
That doesn't support Arrays
interesting documentation for Stream (Object[]::new)
list.stream().collect(Collectors.toList());
Well, that role creates invoices, we help the client actually get a freelancer and we make sure the client gets a quality product that they are satisfied with
o
nah just
Does that work in Kotlin though
fuk if i know, i write java
kotlin moment
yeah it prob works in a java ripoff
n o
Gotta uninstall intellij then
n o
Then all hail our jetbrains overlords
what's wrong with kotlin
everything
give me an example
its existence bothers me
how does that make it a garbage language
if you have a class with a public field and a setter, you never know whether you access the setter or not when doing
myObject.field = newValue
and the syntax sucks as well
if it didnt have java compatibility no one would use it
would be left out same as scala i assume
also kotlin claims that "extension methods" are so awesome but in reality they are nothing more than a static method that accepts a given object
syntax sugar
oh and lombok has it
yes lombok has it as experimental feature
Files.walk(/* your path */).toArray { arrayOfNulls<Path>(it) } maybe @modern vigil
public static void other() {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
Objective objective = board.registerNewObjective("e", "e2");
objective.setDisplaySlot(DisplaySlot.PLAYER_LIST);
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
objective.setDisplayName("something"); //&k
for(Player online : Bukkit.getOnlinePlayers()){
Score score = objective.getScore(online);
score.setScore(1);
}
for(Player online : Bukkit.getOnlinePlayers()){
online.setScoreboard(board);
}
}
}``` I want to change the player's name so that it doesn't show its nickname but some other text. How to do it with this code?
To change a player's name don't you have to mess with like nms
completely different
go mess with nms then
Mama
joe biden
old joe
creep
๐ and how to do it?
Alex showing up to T pose on people
i dont know many men named hannah
yes, better say "unmale"
Whenever a player kills someone instead of dying the player gets launched 100k blocks from spawn and has to run back
a plugin for your simps? yes she's obviously female lol
i wanna say it was something that wouldve went under player
Please don't turn this into twitch chat
make players have to file a tax declaration every 30 ingame days and and if they don't, they have to pay a huge fine and go to jail for 10 ingame days
hmm
Make them do my crypto taxes
bitcoins
people can also hire tax accountants to do the declaration for them but they are expensive and not worth it
I should declare the spigot NFT as a charity donation
ill buy spigot and its developers and staff
Take a nap. Works for me
that's why you should always write down ideas immediately ๐
a backup for your brain
Better yet put them in extremely passive aggressive Todo statements
what is an "aggressive" todo statement?
How to make a invisible player name?
for all players?
ya
Put the players on teams and then hide the persons team from everyone else
I think NMS has a method for that, otherwise yu can just add players to a team and make the name invisible for that team
I think you can also make the player wear an armorstand as passenger
whoa
when the fuck was this added https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#loadData()
declaration: package: org.bukkit.entity, interface: Player
does this mean we could have managing an offline player? ๐
ik :(
Yuck actual organization
The method addEntry(String) in the type Team is not applicable for the arguments (Player) uh
you pass in the name
Player is not a String
what would happen when you pass in something random?
i prefer mine
oh
if you consider that a "todo", it's not surprising you forgot your idea
dont need todos if u do it
I do it the other way around
I always let people add stuff to the todo list and then I never read it
or I do add the stuff and then forget to mark it as done
or sth inbetween like adding the feature but never releasing it
Most of TODOs are just rotting away like this
like I'd ask what I was thinking but I imagine this was a 5am zinger
or there kind of todos:
public class TeleportLocationUtils {
private static final int[][] offsets = {
{-2,-2}, {-2,-1}, {-2,0}, {-2,1}, {-2,2},
{-1,-2}, /*{-1,-1}, {-1,0}, {-1,1},*/ {-1,2},
{0,-2}, /*{0,-1}, {0,0}, {0,1}, */ {0,2},
{1,-2}, /*{1,-1}, {1,0}, {1,1}, */ {1,2},
{2,-2}, {2,-1}, {2,0}, {2,1}, {2,2}
};
public static Location getFinalTPLocation(Block chest) {
Collection<Block> targetLocations = BlockUtils.getBlocksInRadius(chest.getLocation(), 3, BlockUtils.RadiusType.CUBOID, new Predicate<Block>() {
@Override
public boolean test(Block block) {
return false;
}
});
VectorUtils.lookAt(null,null);
return null; // TODO
}
}
Okay, TODO, but WHAT is there to do?
is it really coding if it isnt something u wrote at 4am that youre never gonna remember what it did?
hello i have a code which need Dotclass
import java.assist.runtime.DotClass;
this import is not working
that doesn't exist
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
Team team = board.registerNewTeam("justtest");
team.setPrefix("ยงc[INC] ");
team.addEntry(player.getName());
}``` why it isn't working?
u can see where he was heading with it
but if u couldnt figure out a wrong import u should not be using asm to any extent
Sometimes if I'm lucky my 5am self writes some really great documentation like with my translation library. Woke up to a lot of code and I had to read it too. Ugh
thats just a recipe for headaches and disasters
my 5am self writes code that awake me just leaves it be
or leaves it for the next 5am me
why did you add a comment for that lol
so that he knows what the param is for
Technically it's wrong too
perfect
It's the config file including the .yml part
Not just the name but the extension as well
?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
// TODO: Fix documentation```
lmao
why pascal case method names
why
just why
C# as well
yeah but thats java
bootleg java
I want my nickname to be invisible to everyone
I think my 5am self believes my 8am self to be a dumbass so all the methods have these almost sarcastically obvious comments
thats good comments imo
oh
Also I wrote a method that I instantly deprecated?
LOL
sounds about right
I need 2 git accounts so I can git blame someone else
i stopped adding documentation cause it was too obvious what things do
I only add docs when i feel its necessary
like, for ex i have a cache class and i don't document add, remove, get methods
because they do just that
It's a public library so I wrote docs as practice more than anything
i am so retarded
i found out why my saving system wasn't working
I was storing the amount
you weren't saving
not the slots
forgot to save?
so i was storing like
there are 23 items
not where
so it only loaded the 23 items
nothing past that
(it saves as uuid:slot so uuid:count 15 would load up until uuid:slot14, fair enough, but if you had 13 like that and 1 at 27 it wouldn't load)
F
i can just store the indexes i have like
that's indeed retarded lol
uuid:count "[1, 2, 5, 6]"
and then load
uuid:1
uuid:2
uuid:5
uuid:6
i could very well loop from min to max
but i need to make it as perf as possible
should now work
like FYI
the saving was 100% on point
the only problem was the loading
which i had to change what i saved
can i use this line to hook into other plugins commands to alterate their implementation?
plugin.getServer().getPluginCommand("cmd").setExecutor(new CmdExecutor());
am i getting that right?
In Gson, can I use my Gson object more than one time? So I can get it from my Main class evry time?
Is there a normal way to send player a message in ChatComponent?
I wouldn't see a reason against it
player.spigot().sendMessage ?
yes you can
i mean json message
getServer() just returns the server so 
click event to be exact
hm not sure, never seen it
maybe decompile the tellraw command and see what it does lol
javassist.runtime not working too
except tellraw has lenght limit
Alright before you attempt something silly what are you using javassist for
Uhhhh if it's from a library you need said library to access the class file?
@onyx fjord hi nft
have you even added it as dependency?
ill screenshot ur nft
cant find it on maven
for real?
I wonder what you need javassist for if you can't even find it https://mvnrepository.com/artifact/org.javassist/javassist
hi too lazy to become normal again
ETH just needs to remain at this level so I can get the NFT for 69
is there a method to get a registrated commands aliases?
like
/plugins
then getting /pl
bukkit:pl
have you even tried to check the javadocs?
bukkit:plugins
Command#getAliases
What exactly are your trying to do. Is the plugin you're messing with open source?
for me?
this really isn't hard to find https://hub.spigotmc.org/javadocs/spigot/org/bukkit/command/Command.html#getAliases()
declaration: package: org.bukkit.command, class: Command
yes
Hey! so my code just broke with the message that it couldnt resolve ItemMeta.setCustomModelData(int) though i have spigot 1.18.2 in my pom
I am trying to send the dtr in a message, but it gives a error at this line
String dtr = String.valueOf(manager.getFactionByPlayer(send).getDtr());
But what is wrong with this, i used string,valueof because its a double
mvn clean
does it fail on runtime or compile time?
Compile
?paste your pom.xml
Screams like something is including some old spigot API
put spigot-api at the top
currently you have vault as first dependency
OH
blocking command execution for certain users at runtime without touching the permission nodes
might that be it?
its already working
(or actively exclude Bukkit from vault)
that definitely is it
only been missing the alias part

Alright thanks!
Its easy let me be ;-;
yeah
PDC is easier
no it's for more support, not every version has PDC
btw Lynx I moved your PDC guide in the resources list to its own category in the wiki
iirc at least
yeah wait
check the resources list
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
1.14.1+
1.14.1 is so old, noone uses it anymore
I think 1.5 is more famous
but whose counting
my father's office still has one server with windows server 2001 or so lol
some ATMs in germany are also still on XP lol
Alright it's time to sleep lmfao. I've seen enough xp for a lifetime
wait wat time is it for u
its bank
taco time
3:30am
o
oh boy, 3.30am, time for the morning taco
gonna hit that ballmer peak of programming
lucky
i cant eat until like 8 pm
(fasting ramadan)
ugh
or drink too
why do you torture yourself
I dropped the plugin in your off topic Alex. Lmk if it's helpful or close to what you wanted. It's for my stuff but I imagine it can be made generally useful
oh yeah I'll check it out later, I have to make my awesome breakfast burger now
cya
Oh and stop drinking in the AM
lol XD
it's weekend, and I'm awake since 6 hours
Is there a way to set an items hit damage to less than the normal damage?
Like yes, attribute modifiers are cool, but why can't you Set an attribute to something instead of adding or multiplying
is multiplying by 0.5 not an option?
if it isnt an option (or possible) I usually put a tag in the PDC and then check the EntityDamageEvent for an item with that tag, then change the damage there
How to run code after async task it complete?
i figured out thanks anyway
why doesnt this show the texture?
the file on the right (generated by the code) is located at assets/minecraft/models/item/redstone.json, the custom model file is located at assets/example/models/item/ruby.json and the texture for the ruby is at assets/example/textures/items/ruby.png
it looks like this
just redstone
do you have the resource pack loaded? ๐
yeah
the server resource epack
pack
im pretty sure i had
yeah
this is the pack if you want to download it and look
i use filebin to host them automatically
Is that the "add scalar" operation?
yeah i cant rlly spot a problem either tbh
ok i reordered it putting the overrides last
and now the model is broken
which means its at least loading it
not sure, never used them
Hello, I just got a question. Can a server be paused? I mean clientside singleplayer uses vanila integrated server, and it's very similar to bukkit or spigot one, so maybe this feature exists here too? (When you press ESC you pause the server if it's not "opened for lan")
P.S. It's bukkit/spigot API related question
well you can pause the main thread but that will cause heaps of issues lol
yes
what if pause all threads
but no, it's a bad idea
even scheduller won't work then
yeah that will just end up crashing the server
so is that possible?
maybe you can change the tickspeed to 0?
not sure how that would effect everything though
try MinecraftServer.halt(boolean) lol
I think if you set MinecraftServer.running to false, it should be paused
the question is - how do you want to start it again?
Gotta love decompiled Minecraft code
basically we can just pause threads a bit over and over and try not to display warnings in console
The main question was does that vanila feature even exist lol
never saw that field before, who knows, maybe it's what we are talking about
maybe client just changes it when menu screen is opened/closed
dude i just cant get this resource pack shit to work
is it a 1.18.1 bug?
ima try it on 1.18.2
public CompletableFuture<Void> thenAccept(Consumer<? super T> action)
No
The method by its concept accesses entities in the world
Which is only safe from the servers main thread
how would i go about making it so that whenever a player sends a chat message, only the recipients in a certain radius will recieve the message?
The async player chat event provides you with all recipients?
so just loop through the recipients and check if theyre close enuough to the player
?
dude i swear minecraft resource packs are broken
#Doubt
#nodoubt lol
see anything wrong with this? (generated)
Its a method that allows you to remove entries from a collection if a predicate matches them
no i just thuouhgt it was an L not an i
font moment
my intellij font shows capital i as
wait do you need to put the namespace like item/<namespace>/<id> now?
because if so, thansk
nop
oh
i simply dont use namespace:...
i want to tho
yeah but i want each mod to have its own assets
like assets/<modid>/a/b/c
so you are wrting a mod?
so you dont need the namespace
i dont need it, i want it and if its possible i will use it
yeah
oh
ill try
maybe like mod_<id>
oh no wait but im copying the assets directly from the mod jar
into the resource pack
i mean it is possible
but it wont be very clean
wait i think it might be the way gson writes the json files
lmao
yeah gson has much smaller indents
whenever i manually edit a file it works
no
nvm
how do I check if a ProjectileHitEvent hits an entity or a block?
if i would hit an entity, check the EntityDamageByEntityEvent and check if the damager is instance of Arrow
btw you're a fake gandalf
that would also work but I just checked if the HitEntity is null and returned, works just fine
:o ?
you would need to check if the damager is an arrow or you might be handling other damage types too, also Arrow#getShooter instanceof Player is something
please help lmao
still doesnt work
the generated json file is the exact same as the on found here https://www.spigotmc.org/threads/advanced-resourcepack-mechanics-how-to-create-custom-items-blocks-guis-and-more.520187/
and the resource pack is packaged correctly (i think)
i tried manually moving it to my resource packs folder
but it still doesnt work
hosting code
Is there a way to make block changes not heavy on the server? I knew a plugin that did a lot of block changes and the tps was very low because of them. They were all done by block.setType(), but would player.sendBlockChange() be a better solution?
That would only change the block for the player
I know
setType(type, false) is pretty much the fastest you can get
What about packets?
only for players again
^
Mk. Thanks
why i get this error (using VPS)
https://paste.md-5.net/ejomazasiw.md
there should be a log message starting with caused by below that message. the first line containing a file name & line number in that points to where the error stems from.
Considering it's a EOF exception, you probably made a mistake with some file reader or writer
But on my localhost server it worked without problems
theres a chance the server software is different
if its like that you probably run a method which your localhost server has in its api but your online server doesnt
or is implemented differently
What do I do now? Do you have a solution?
could someone send the link to the list of the remapped things?
How can i get every block in a chunk?
what do i put in this for loop?
x, y and z
can you send me an example?
16 x 16 for x and z and use getMaxHeight and getMinHeight for the y axis
like this?
Yes
ChunkSnapshots are more ideal for this as they can be processed async and don't lag the server as much
Metadata is saved as a collection of metadata values
each metadata value contains its internal object, a reference of the plugin holding it and additional data when required
getValue or something
just use your IDE
because i cannot figure out how to disable the april fools joke on stackoverflow
can someone direct me to how to delete a yaml key and all of its contents
set(key, null)
yes
didn't work ๐ฆ
mye
ok no nvm got it
the spigot wiki is outdated
DB class doesnt exist anymore
and MongoClient is an interface now
and DBCollection doesnt exist too
god help me with mongo
2hex its pretty easy
to connect
sorta
i haven't been able to test
since mongo's atlas is broken, and their installer is weird af
You need a connection string
then mongo client settings
and then MongoClients.create(MongoClientSettings)
don't expect to be able to use that however
o
as its fucking difficult getting a db
ill use the old driver <3
yah
if i use return; in repeated task does it cancel the task or just waits until it runs again?
it runs again. you have to cancel the task to get rid of it I believe
What is the 1.17+ of Remove_Player, and Add_Player for PacketPlayOutPlayerInfo (NMS ofc) cause it was changed in 1.17 but idk what the ne one is?
Entity nestEnt = Bukkit.getEntity(nestID);
this returns null
public static void addMember(UUID nestID, Player player, String role) {
// checks if yaml paths exist
if (!nestExists(nestID)) return;
if (containsMember(nestID.toString(),player.getUniqueId())) return;
Entity nestEnt = Bukkit.getEntity(nestID);
if (nestEnt == null)
throw new RuntimeException("Entity was null when reached in addMember"); // throws every time
setNestSpawn(nestID, playerUUID, nestEnt.getLocation());
} ```
```Java
addMember(this.getBukkitEntity().getUniqueId(), placer, "leader");
^^^ above does not work
however,
addMember(this.getBukkitEntity().getUniqueId(), placer, "leader");
setNestSpawn(this.getBukkitEntity().getUniqueId(), placer.getUniqueId(), this.getBukkitEntity().getLocation());
^^^the above works
Hello together I have been programming on a Spigot plugin again for a long time. However, I forgot how to get plugin.getCustomConfig() in another class. Since I don't see a plugin. there.
Config Generation:
`
private File customConfigFile;
private FileConfiguration customConfig;
@Override
public void onEnable(){
createCustomConfig();
}
public FileConfiguration getCustomConfig() {
return this.customConfig;
}
private void createCustomConfig() {
customConfigFile = new File(getDataFolder(), "guild.yml");
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("guild.yml", false);
}
customConfig = new YamlConfiguration();
try {
customConfig.load(customConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
}`
create a get() member function that simply returns customConfig
public static FileConfiguration get() { return customConfig; }
thanks ^^
CustomConfig.get()
although i'm not actually sure why your CustomConfig.getCustomConfig() didn't work
nothing Changed. he said i must remove the Static and i cant get the function in the other class
huh
interesting so ig he just wants you to make a single CustomConfig object
which ig makes sense
you just have to import that object to each class
i have it so
public FileConfiguration get() {
return customConfig;
}
which is kinda dumb imo
so i think make a new CustomConfig object in your main class
and then import object into the classes that you want
i cant get any function out of the Main Class. is that normal xD?
im storing an inventory in redis each time a player closes a custom inventory
is that fine
CustomConfig customConfig(whatever); in ur main?
If you don't have an instance of your main class, yes
idk whats going on
If you don't have an instance, you can only use static stuff
...
uff how do i make a Instance and where?
but can someone tell me why Bukkit.getEntity(Entity.getUniqueId()) returns null?
here's my problem
To get the Main Class instance, you can do something like Main main = Main.getPlugin(Main.class); or make a static variable inside your Main class
If your main class is named Swasch, yes
okay but i cant get main in other Class?
Do it like this:
private static Schwasch main;
private File customConfigFile;
private FileConfiguration customConfig;
@Override
public void onEnable(){
main = this;
createCustomConfig();
}
public static Swasch getMain() {
return main;
}
public FileConfiguration getCustomConfig() {
return this.customConfig;
}
private void createCustomConfig() {
customConfigFile = new File(getDataFolder(), "guild.yml");
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("guild.yml", false);
}
customConfig = new YamlConfiguration();
try {
customConfig.load(customConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
}
After that, you can use Schwasch.getMain()
okay
Or just make your customConfig stuff static, I guess ยฏ_(ใ)_/ยฏ
fr
if you're only doing one customConfig ig
GUYS
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId()));
this is printing false
??????????????
Well, because it's inside the Main class, it's only going to be one anyway ๐ค
does anyone have any idea?
If the return of Bukkit.getEntity(this.getBukkitEntity().getUniqueId()) is null, of course it's going to print false ๐ค
this makes no sense whatsoever
nope
it is not
Huh?
oh wait you mean the whole thing
thought you meant getUniqueId
misread
yeah but the entity exists
i literally just created that entity inside of the method
why is it returning null?
public EntityNest(Location loc, Player placer) {
super(EntityType.VILLAGER,((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(),loc.getY(),loc.getZ());
CraftLivingEntity ent = (CraftLivingEntity) this.getBukkitEntity();
ent.setAI(false);
ent.setSilent(false);
ent.setCollidable(false);
ent.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(1000);
ent.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0);
ent.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(1000);
ent.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 3, true));
ent.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 1, true));
ent.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 1, true));
this.setHealth(1000); // FIX THIS to read from nest level
// write to data
int unnamed = 0;
while(!NestYML.Nest(this.getBukkitEntity().getUniqueId(),"Unnamed Nest "+Integer.toString(unnamed), 1)) {
unnamed++;
System.out.println("Found unnamed nest with the same name, iterating");
}
this.setCustomName(new TextComponent(ChatColor.GOLD + "" + ChatColor.BOLD + "Unnamed Nest "+Integer.toString(unnamed)));
this.setCustomNameVisible(true);
addMember(this.getBukkitEntity().getUniqueId(), placer, "leader");
setNestSpawn(this.getBukkitEntity().getUniqueId(), placer.getUniqueId(), this.getBukkitEntity().getLocation());
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId())); // <<<<<<<<<<<<<<<<<<<<<< RETURNS FALSE
}```
Hmm
https://ibb.co/Bq1JWJP it dont work
I have no idea... Bukkit.getEntity should work, I used it once too ๐ค
Make sure your Main class is actually named Swasch if it is, try using the whole path...
For example:
me.person.plugin.main.Main
ma Main is in SRC and the name is Swasch
Can you show me, please?
yea
Trying: System.out.println(this.getBukkitEntity() == Bukkit.getServer().getEntity(this.getBukkitEntity().getUniqueId()));
Anyone?
doesn't work.
Yeah... I think you shouldn't put your class files where you put your yml files ๐ค
this is gonna drive me mad
You could just make your own Map I guess?
what's that mean
who shoud i put ma ymls
Map as in?
Well... A Map which contains the Entity and the UUID of said entity.
Then you wouldn't be depend on Bukkit.getEntity anymore
HashMap for example
If you have a resources directory, put them there
and if not
Oh... The problem is restarting the server, isn't it?
wut
I mean, you want to have it across restarts, right?
Scrap it then, just save the Location of the entity.
You set it to not have any ai, so I won't be moving...
ยฏ_(ใ)_/ยฏ
can i make a Class with only Custom Config Generation and call the methods out of there in the Main?
so i can make the get in a Other Class the get Method
(โฏยฐโกยฐ๏ผโฏ๏ธต โปโโป
trying: System.out.println(this.getBukkitEntity() == (Entity) ((CraftWorld) (Bukkit.getWorld("world"))).getHandle().getEntity(this.getBukkitEntity().getUniqueId())); lmao
doesn't work
trying:
public static Entity getNestEnt(UUID nestID) {
for (World world : Bukkit.getWorlds()) {
for (Chunk chunk : world.getLoadedChunks()) {
for (Entity entity : chunk.getEntities()) {
if (entity.getUniqueId().equals(nestID))
return entity;
}
}
}
return null;
}```
this crappy shit
Hello, i've got a problem, i made a GUI that show the craft of an specific item with the method getRecipesFor but i've got new item with new craft, Cobblestone Tier 1, Tier 2, Tier 3 and Tier 4 but when i use my code to show the craft of cobblestone tier 1 my gui show me the craft of cobblestone tier 4 because it is the last in my craft init method.
doesn't even work
so something stranger is happening
what in the world.
player.sendMessage(String.format(e.getFormat(), e.getMessage()));
Asyncplayerchatevent
im not sure about string formatting i assume it needs a %s and a replacement string
the event provides a e.getFormat(), maybe that isnt the right hting to use?
hey, i'm pasting schematic with location loc.clone().add(0, 5, 0) and i want to remove it later
As i see there is getMinimumPoint() and getMaximumPoint(), but I have no head for such mathematical things, can sb help?
trying:
public static Entity getNestEnt(UUID nestID) {
for(World w: getServer().getWorlds()){
for(Entity e: w.getEntities()){
if(nestExists(e.getUniqueId())) {
return e;
}
}
}
return null;
}```
doesn't work
if(player.performCommand("pos1")){
this will detect if player performed pos1 command?
does the chunk.getEntities iterates all entities of the world?
No
This will perform this command
of the chunk it does
but i used this it's more sensible
how do I check then
and still doesn't work
This all sprouted from this
But why do you need this?
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId())); is always false
It is impossible to check if the player has ever performed a command without fun in bools
there is parent command /arena create
after that player gotta put /pos 1
then you have to create a bool variable and set it to true after performing pos1
can someone please rewrite this on their own to tell me if it's some deeper problem\
because this is really really stupid
why system.out.print?
idk
that's not the problem
simply a quick debug
the problem is the Bukkit.getEntity() does not work.
what is getBukkitEntity() and what does it do
it is supposed to return the entity with a given UUID
no
i mean the this.getBukkitEntity()
is the entity loaded
is it in loaded chunks
yeah
weird
i create it in the same method
public class EntityNest extends Villager {
// entity contains unique data to be compared
// entity name cannot be the same as another
public EntityNest(Location loc, Player placer) {
super(EntityType.VILLAGER,((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(),loc.getY(),loc.getZ());
CraftLivingEntity ent = (CraftLivingEntity) this.getBukkitEntity();
ent.setAI(false);
ent.setSilent(false);
ent.setCollidable(false);
ent.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(1000);
ent.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0);
ent.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(1000);
ent.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 3, true));
ent.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 1, true));
ent.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 1, true));
this.setHealth(1000); // FIX THIS to read from nest level
// write to data
int unnamed = 0;
while(!NestYML.Nest(this.getBukkitEntity().getUniqueId(),"Unnamed Nest "+Integer.toString(unnamed), 1)) {
unnamed++;
System.out.println("Found unnamed nest with the same name, iterating");
}
this.setCustomName(new TextComponent(ChatColor.GOLD + "" + ChatColor.BOLD + "Unnamed Nest "+Integer.toString(unnamed)));
this.setCustomNameVisible(true);
addMember(this.getBukkitEntity().getUniqueId(), placer, "leader");
setNestSpawn(this.getBukkitEntity().getUniqueId(), placer.getUniqueId(), this.getBukkitEntity().getLocation());
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId())); // <<<<<<<<<<<<<<<<<<<<<<<<<< ALWAYS prints false
}
}```
how do you create the entity?
is it registered to the server
the super() method i believe
if not how do i do that?
