#help-development
1 messages · Page 1749 of 1
but it's 6
hey, it's me again, now i would like to make a permission plugin for my server but i don't know how to deny all permissions to a player. Is there a way to do that?
Learn to read numbers before asking please.
it's 8 but without the bold &l and &x it's 6
Then it would probably me to learn to read numbers before answering question…
Tho it is kinda hard to see those characters in app discord…
don't make excuses, you were toxic for no reason whatsoever and it ended up you were wrong
now can i please get some help from someone who won't judge me?
Toxic?
that's toxic
my start.bat looks like this tho. Do I just change the %JAVA_PARAMETERS% to %JAVA_8% then?
@echo off
call settings.bat
:start_server
echo Starting SevTech Ages of the Sky Server...
java -server -Xms%MIN_RAM% -Xmx%MAX_RAM% %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
goto start_server
Change java-> %JAVA_8%
Thank you so much

@lost matrix thank you so much for always helping me aswell
how do i get the amount of values in a config file?
like a FileConfiguration type thing
getKeys(false)
.size
(true) would return all keys for the given section and all of their subsections as well
can i compare world instances or do i need to check for the name?
So if you just want the base section you use (false)
I’ve never really compared worlds any other way than by their name, considering you can’t have two worlds with the same name
Why don’t you test it out 🤔
yea true but i was just wondering
Yea not sure about that one
i'm not going to compile and run it every time 😂
Lol
gradle > maven == true ?
gradle brr
good, glad Ive been using Maven all along then
how do i know if i use maven or gradle
probably maven
maven is the buildtools one right?
Yeah they’re cached, no reason not to
is that IntelliJ?
yesh
wohh how u make it look liek dat
uhh a theme i guess
Can someone help me? How do i make a holographic display that displays the balance of the baltop, idk what placeholders
plz help out boys need this asap
Paying someone to do it would probably be the fastest
sort of like this
is setmarker a paper method or does spigot have it too?
I got this far but i dont know how to make it auto update.
spigot has it
If i have a command that runs every 15 second to auto update the entire holograph would that lag the server?
sweeeeet
spigot
no
and its the other way around, if spigot have it, paper would have it too.
depends on what you are doing
you might be doing it async if you have alot of scoreboards
Whats that?
yeah, anyways ty
is there a difference if i run it every 15sec or 1 sec (performance wise)
Yes
depends on what you are doing
it will run 15 times
updating placeholders
I've got to the placeholder part on display but i dont know how to make it updatre
since you will only notice a peak of performance if your operation comes over 20ms, i wouldn't think so
unless you are accessing some DB or files
does that else has a purpose?
I will use a plugin that runs commands and just redoes the entire command aka /hd setline baltop 1 %baltop_1_player%
as i do a return
Player shooter = killEvent.getKiller();
UUID shooterUUID = shooter.getUniqueId();
if(playerKills.containsKey(shooterUUID)) {
int val = playerKills.get(shooterUUID);
int time = val % 100;
val = val - time;
playerKills.put(shooterUUID, val + 110);
}
else {
playerKills.put(shooterUUID, 110);
}
if(!(playerStreaks.containsKey(shooter.getUniqueId()))) {
scheduler.runTaskTimer(myPlugin, task -> {
playerStreaks.put(shooterUUID, task.getTaskId());
playerKills.put(shooterUUID, (playerKills.get(shooterUUID) - 1));
if(playerKills.get(shooterUUID) % 100 == 0) {
task.cancel();
playerKills.remove(shooterUUID);
playerStreaks.remove(shooterUUID);
}
}, 20L, 20L);
}
int kills = (playerKills.get(shooterUUID) - (playerKills.get(shooterUUID) % 100)) / 100;
final char killMarker;
if(kills > 10) {
kills = 10;
}
killMarker = (char) ('\ue100' + kills - 1);
String killSound = "killmarker" + kills;
shooter.sendTitle("" + killMarker, "", 0, 10 + (kills * 4), 10);
shooter.playSound(shooter.getLocation(), killSound, 1, 1);
Okay so this event gets called whenever a player kills another entity.
It adds the killer's uuid to a map and assigns a score (100 for each kill, 10 points as timer)
Then it starts a streak timer which then removes 1 point per second from each players score
This task gets cancelled once the score is divisable by 100 and rest is 0
However, the line
playerKills.put(shooterUUID, (playerKills.get(shooterUUID) - 1));
returns an exception sometimes, saying that the return value is null.
Any ideas why that might happen or how to fix that?
(It is not really if a player kills any entity, it is related to CrackShot, killing entities is just for reference as it is the same effect)
Weird way to do that
I need that for killstreaks and different sounds and effects for each kill
I am trying to use Custom Enchanments for ItemStack items(Armors), but when i try to run it it says : Caused by: java.lang.IllegalArgumentException: Enchantment level is either too low or too high (given 3, bounds are 1 to 2)
You don't need two different hashmaps
one has the score, one has the task id's so I can cancel them
Yeah you can just make an object that tracks both
and so I know which player already has a clock to reduce the tasks
which object could have a UUID, Integer and Integer?
Anyone know how to make piglins dance the victory dance they do when killing a hog??
make a hashmap with the uuid key, and make an object that stores two integers
are you lacking the level restriction?
then you can have HashMap<UUID, yourRandomTwoIntegerObject>
ok couldve done that but it doesnt fix the problem
yes, i cant use enchanment levels like 10, 15
normally i had something like this
does no one know how to make piglin dance
can you send me that project? imma have a look
obviously not
if set to false it would normally accept higher levels
If you're getting a null exception try to figure out why that's happening
I'm gonna rewrite it with that, one sec
I really tried
might have something to do with how you're removing the uuid from the hashmap
the problem is: if it gets removed, the task also gets immediately cancelled
ooooh wait
it coul dbe
no wait
doesnt make sense
Would be much easier to just make a hashmap with a tracker object
instead of using hashmap.remove
then you wouldn't have to worry about it
Yes, make the tracker object like I said before
no like overall
is there a placeholder for economy top with vault?
Not off the top of my head
could anyone help me out please because im having alot of issues with it.
I figured out the problem
since the task has a starting delay before it adds it to the streaks map
it might be starting 2 tasks
which causes the problems
so i need to set it to 11 seconds and set the delay to 0
let me try this again
Hey guys I'm trying to make a custom terrain generator, but biome generation appears fragmented, could someone help me out?
public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(worldInfo.getSeed()), 6);
generator.setScale(0.01);
Material material = Material.STONE;
int worldX = chunkX * 16;
int worldZ = chunkZ * 16;
if(chunkData.getBiome(chunkX, chunkData.getMinHeight(), chunkZ) == Biome.MOUNTAINS) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
double noise = generator.noise(worldX + x, worldZ + z, 1, 1, true);
int height = (int) (noise * 40);
height += 84;
if (height > chunkData.getMaxHeight()) {
height = chunkData.getMaxHeight();
}
for (int y = 0; y < height; y++) {
chunkData.setBlock(x, y, z, Material.GRASS_BLOCK);
chunkData.setBlock(z, y-1, z, Material.DIRT);
for (int i = y-2; i > 0; i--)
chunkData.setBlock(x, i, z, Material.STONE);
}
}}}
if(chunkData.getBiome(chunkX, chunkData.getMinHeight(), chunkZ) == Biome.PLAINS) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
double noise = generator.noise(worldX + x, worldZ + z, 1, 1, true);
int height = (int) (noise * 40);
height += 84;
if (height > chunkData.getMaxHeight()) {
height = chunkData.getMaxHeight();
}
for (int y = 0; y < height; y++) {
chunkData.setBlock(x, y, z, material);
}
}
}
}
}```
Is there any way to check if a player already sees a title?
Maybe check outgoing packets to player
there are no packets sent after the initial
how can i remove effectivePermissions which i didn't set by self? Unset don't work
i tried this, but in the gotten attachment in line 3 do not exist the effective Permissions
playerPermissions.put(event.getPlayer().getUniqueId(), event.getPlayer().addAttachment(getPlugin()));
event.getPlayer().sendMessage("added uuid to HashMap playerPermissions");
PermissionAttachment attachment = playerPermissions.get(event.getPlayer().getUniqueId());
event.getPlayer().sendMessage("Attachment permissions: " + getAllPermissions(event.getPlayer()));
playerPermissions.get(event.getPlayer().getUniqueId()).unsetPermission("multiverse.help");
event.getPlayer().sendMessage("Attachment permissions after unset: " + getAllPermissions(event.getPlayer()));
someone help me
sendPacket(new PacketPlayOutEntityMetadata(19, true, DataWatcherRegistry.i);
private void sendPacket(Packet<?> packet) {
for (Player all : Bukkit.getOnlinePlayers()) {
CraftPlayer player = (CraftPlayer) all;
player.getHandle().b.sendPacket(packet);
}
how to make piglin dance, me sad inside dis annoy me
i tried to make gui in spigot but console says initializing legacy material
spigot version is 1.17.1
send code
?paste
and api-version is 1.17
does HashMap#remove(Object key, Object value) tries to remove as much as possible or does it only removes it the map contains both?
If its initializing legacy material then some plugin does use an old or no api version
no no i only have my plugin
have you got api-version: 1.17 in your plugin.yml?
yea
odd
name: MyFirstPlugin
version: '${project.version}'
main: me.ihsan.myfirstplugin.MyFirstPlugin
api-version: '1.17'
authors: [ ihsan ]
description: My first plugin
commands:
die:
description: Simple way to attempt suicide.
usage: /<command>
aliases:
- suicide
- killme
about:
description: About the server.
usage: /<command>
aliases:
- info
- server
tpa:
description: Send a teleport request to a player.
usage: /<command> <player>
fly:
description: Get ability to fly. Only for operators.
usage: /<command>
tpaccept:
description: Accept teleport request.
tpdeny:
description: Deny teleport request.
menu:
description: Opens menu.
usage: /<command>
api
verson is there
remove the ' chars
oh
?paste
i removed it and tried to but still didnt work @lost matrix
HashMap.remove() removes the attachment which i added from the hasMap, this do nothing with the effective permissions
Look inside the compiled jar (inside your plugins folder) and make sure your plugin.yml is in there
what
i wasn't responding to that
plugin.yml is there because all the commands in it are working
oh sry xD
If you looked inside your jar and the api-version is set then legacy materials wont be loaded
Only 1 or 0 can exist, so it removes it if it does and nothing if it doesnt
it is still saying initializing legacy even tho the api version is 1.17
anyone any idea?
?
this is the message in console
[21:21:15] [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
?paste
is tehre something wrong in the class where i made the gui?
how do i put code here
Just click that link
and then ctrl + s
And copy the link in your browrser
browser*
Yes
Initializing Legacy Material Support issue
Kind of unrelated to development; is there a mod that allows me to see mob pathfinder goals?
similar to bedrock developer edition
if i only create one instance of a class, is static useful?
As in a singleton pattern?
Hey, someone know if I can avoid the name of the armorstand to turn black ?
Make it a Marker and put the armorstand above the block
I will try that ty
By above the block wdym ?
This happens if the physical part of an armorstand intersects with a Block.
One solution is to simply disable the whole body of the armorstand. This is done
by making it a marker.
Ty it works !
The only one I found is here but it doesn't look to be updated past 1.15.x
https://www.curseforge.com/minecraft/mc-mods/debug-renderers
Otherwise, if you're capable of Forge (or Fabric) modding, you can definitely enable those renderers yourself. They're built into the client, they're just not activated
where would I start with doing this??
can't i use someString.replace() instead of someString = someString.replace()?
Strings are immutable. This means every time you want to change a String you need to create a completely new Object which includes the changes
StringBuilder is mutable
i have a question about substring
for example
skull-blablabla
if i want the blablabla
should the startindex be 6 ?
Program it position agnostic
public String getStringAfter(String line, char delim) {
return line.substring(line.indexOf(delim));
}
This will return the String which comes after the first delimiter char
Doesnt matter where its located at
I mean you shouldn’t use static just because it happens you only need one instance of a class.
Uhm. I think it will get "-blablabla"
So then
public String getStringAfter(String line, char delim) {
return line.substring(line.indexOf(delim) + 1);
}
is there an easy way to figure out where lost connection: Internal Exception: java.lang.IllegalStateException: Asynchronous getNearbyEntities! is coming from?
I legit can't figure out where it's coming from as I use a util function to fetch nearby entities and it worked and now it doesn't?
Why are there so many places where this method is called? That sounds like a big design problem.
Do you call this method in an event that starts with "Async"?
Or in a task that was started using ".runTaskAsynchronously()"?
some bob square pants
am busy reworking old messed up plugin, only events used don't use getNearbyEntities, uses packets, no clue if that effects anything
Might be easier to just start from scratch lmfao
Yeah scrap that
How would I change mob textures in my plug-in, I want to make the creeper texture blue
Instead of green
You cant unless you distribute a resource pack to the clients
With a forge mod probably
giant zombie exists, otherwise mods
you can do it with phantoms?
And add new Blocks, Items and GUIs
which ones are phantoms again? Im a 1.8 user
The annoying ones that spawn if you don’t sleep
ah
😂
placed a world folder in my server dir, renamed it, now trying to teleport to it with a location and a Bukkit.getWorld("world_name") and it returns a NullPointerException, what's the cause?
hello there, i want to play a sound to a player from this event. I would normally use Player.playSound(...) but I'm not sure how to get the player from this event, or if theres a better way to do so.
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if (e.getEntity().getType() == EntityType.PLAYER && e.getDamager().getType() == EntityType.PLAYER) {
e.getEntity().sendMessage("");
// Play sound to entity?
e.setCancelled(true);
}
}
You need to load the world before you can use it
and what would be the method for that?
With an instanceof check and casting
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player player) {
player.sendMessage...```
Bukkit.createWorld(WorldCreator.name("world_name"));
got it thanks
Im pretty new to Java but to cast I would do something like Player player = (Player) e.getEntity() correct?
Also is it better to use instanceof instead of checking the type with Entity.getType()?
in some instances the object you get may be null. in which case you will throw an error, instanceof will not
Ohh okay, gotcha. thank you :)
One sollutuion:
@EventHandler
public void onDamage(final EntityDamageByEntityEvent event) {
final Entity attacker = event.getDamager();
final Entity defender = event.getEntity();
if (!(attacker instanceof Player attackingPlayer)) {
return;
}
if (!(defender instanceof Player defendingPlayer)) {
return;
}
attackingPlayer.playSound(...);
defendingPlayer.playSound(...);
}
Or this:
@EventHandler
public void onDamage(final EntityDamageByEntityEvent event) {
final Entity attacker = event.getDamager();
final Entity defender = event.getEntity();
if (!(attacker instanceof Player) || !(defender instanceof Player)) {
return;
}
Player attackingPlayer = (Player) attacker;
Player defendingPlayer = (Player) defender;
attackingPlayer.playSound(...);
defendingPlayer.playSound(...);
}
top one is cleaner and uses java 16 methods.
This gets me thinking if there is a functional way of calling instanceof and casting...
((Player) e.getEntity()).playSound ?
ah it was already answered
nvm
but yeah u just gotta cast it
*Dont forget to check the instanceof
he pretty much does by calling getType and making sure its Player
if (entity instanceof Player player) {}
idk what you meant lol
cries in still using java 11
oh
still waiting for graalvm to have a j16 on scoop.sh
top 10 reasons i shouldve switched to linux when i built my pc
less waiting most of the time 😔
@EventHandler
public void onDamage(final EntityDamageByEntityEvent event) {
IsInstance.of(Player.class, event.getEntity()).ifPresent(player -> player.playSound(...))
}
public static class IsInstance {
public static <T> Optional<T> of(final Class<T> clazz, final Object obj) {
return Optional.ofNullable(obj != null && clazz.equals(obj.getClass()) ? clazz.cast(obj) : null);
}
}
😄
Isnt 17 the next lts version? I dont think graal will release for java 16
i think so, but graal for java 16 is out, just not available using scoop PM
could probably find it with winget but
or choco
Just build a docker with native linux code ^^
The windows kernel sim of linux is quite good
wsl?
yeah WSL 2
ill just use linux then 😼😎
wouldnt using Class#isAssignableFrom be more suitable than .equals? just incase obj isnt the exact class of clazz but is still an extension of it
true
Gosh we get the fancy new inline casting with instanceof all y'all still love your lambdas :p
How many chained lambdas is too many chained lambdas
no such thing
No limit
-> go brrr
Code an entire plugin with Lambdas
rewrite command system to use brigadier
buildergadier
@EventHandler
public void onDamage(final EntityDamageByEntityEvent event) {
Optional.of(event.getEntity()).stream()
.filter(e -> e instanceof Player)
.map(Player.class::cast)
.forEach(player -> player.playSound(...));
}
is that overhead for making a collection ?
hello guys I'm trying to integrate minecraft with Discord, but when I use "JDABuilder" it keeps giving an error. Can someone help me? (I've already tested 6 versions of JDA)
Use the latest
send the code ur using to create it? (and dont include the bots token in the paste)
Wait a moment
are you saying that my message is too long ;-;
Could you send it to your private?
Do you get a compile time error or a runtime error?
Send the stack trace
I can't send any files, but it's at runtime
But you can send text. Just send us the stack trace
ok
when I teleport a player who was falling, it makes the "player fell" noise, is there a way to stop the sound from playing?
Try setting his falling ticks to 0
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.JDABuilder
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_301]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_301]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_301]
... 12 more
You dont shade JDA into your plugin.
Do you use maven?
that prevents the fall particles, but not the sound
yes i use maven
Change his velocity to a zero vector before teleporting
Do you have a scope set on the jda dependency?
no
Add the maven-shade plugin to your pom:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
And make sure that dependencies which are present at runtime get the scope "provided", like this:
<dependencies>
...
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.1_253</version>
</dependency>
</dependencies>
and it's still giving an error
- Latest version is 4.3.0_339
- Make sure that you have the maven shade plugin in your pom
- Actually
usemaven anddontbuild artifacts because then you are ignoring maven completely and you could just throw your entire pom in the trash
You dont have JDA loaded at runtime
If ur using gradle use shadowJar to make a jar with dependencies
Its imported or else it wouldnt even compile
Yeah the problem is that the dependency is not shaded.
True sorry
U need to find a way to include it in rhe jar
So that it gets loaded by bukkit
Ive sent him a setup for the maven-shade-plugin
But i think he builds artifacts anyways so the pom gets ignored completely ^^
Bruh
@final star if ur building artifacts use the include dependencies in project and then add JDA jar file
But rhen using maven is conpletely pointless
how can i get the uh player from an AsyncPlayerChatEvent
What's the Bukkit.isPrimaryThread() equivalent for proxies?
Also u need to regenerate the artifact afterwards
Its a PlayerEvent so you can just use the usual getter
CTRL F is your friend
A plugin that lets you define a multiplier for every type of damage. Name it DamageControl
any one can suggest how could I get rid of decimals in double
I got option in config to disable decimals for my economy plugin
but qustion is there a way to remove all decimals which shows sometimes
of double without DecimalFormat
because I currently only found suggestions using DecimalFormat that will turn it to string and then I need to get it back to double and save it to data base
Just cast it to an int
wont work because it goes over max int
*long
Cast to long
^^
Can someone help me figure out why this isn't working?
public static Map<Integer, Integer> trackExp = new HashMap<>();
public static Map<UUID, Map<Integer, Integer>> bdExps = new HashMap<>();
public void addPlayerExp(UUID playerUUID, int track, int exp) {
if (bdExps.containsKey(playerUUID)) {
int totalExp = exp;
totalExp += bdExps.get(playerUUID).get(track);
bdExps.get(playerUUID).put(track, totalExp);
}
else {
Map<Integer, Integer> tempTrackExp = new HashMap<>();
trackExp.put(track, exp);
bdExps.put(playerUUID, trackExp);
}
}
public int getPlayerExp(UUID playerUUID, int track) {
if (bdExps.containsKey(playerUUID))
return bdExps.get(playerUUID).get(track);
return 0;
}
Invoking "getPlayerExp" results in
Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
If thats not enough then go for a BigInteger...
But max value of long is about 9.2 Quintillion which should be enough for most cases
MapMaps
First:
If you see nested collections then its time to create some new classes.
Is nesting hashmaps ineffiicient?
Eh. If its exactly one MapMap and you have exactly defined relations then sure... but as a general rule: Make new classes
Why would it be?
Im assuming thats why you suggest making new classes
Is an antipattern to make maps in maps in maps
New classes just improve the modularity, maintainability and expandability of your code
And it looks log dog sheet to
I’d say yes
Yeah I recently used a table for cooldowns, works well
Hmm okay. How would I convert my nested maps into a class to hold the values?
I think that was a statement, not a question XD
It was statement
private final Map<String, Map<Integer, Integer>> trackMap = new HashMap<>();
To:
private final Map<String, TrackedMatch> trackedMatchMap = new HashMap<>();
public class TrackedMatch {
private final Map<Integer, Integer> tracks = new HashMap<>();
public void addTrack(final int key, final int value) {
this.tracks.put(key, value);
}
public void removeTrack(final int key) {
this.tracks.remove(key);
}
// And so on
}
And make sure you enforce strong encapsulation. Meaning that you never make your data structures public and you never write getters or setters for them.
My favorite class is abstractmap.simpleimmutableentry when I'm super lazy
Great, thank you, however, I'm still confused on how I'm supposed to get the value from a nested hashmap
Dont use nested maps
But how can I save the values to a specific UUID now using your way?
Example for the class i wrote:
private final Map<String, TrackedMatch> trackedMatchMap = new HashMap<>();
public int getTrackedValue(String holder, int track) {
TrackedMatch trackedMatch = trackedMatchMap.get(holder);
if (trackedMatch == null) {
return 0;
}
return trackedMatch.getTrackValue(track);
}
Ahh okay, thank you!
getOrDefault 😉
More like computeIfAbsent
🙂 Just assumed you didnt want extra data stored as your werent adding it xD
idk
Hello ! i search for CraftFallingBlock the noClip in 1.17.1 😢
in 1.16.5 it's this : ((CraftFallingBlock) liftedBlock).getHandle().noClip = true;
and i search for the 1.17.1
If you dont use moj mappings then the NMS source code is obfuscated.
So its probably something like A or af
Read here how to apply the mojang mappings and work with 1.17 nms:
https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
Mappings are for dweebs
it is not A nor af 😢 when the falling block falls it becomes a block
Do you want the FallingBlock to just disappear or fall through the world?
disappear
?jd
Then you dont need any CraftBukkit or NMS. This can be done with the spigot API.
@EventHandler
public void onBlockLand(final EntityChangeBlockEvent event) {
final Entity entity = event.getEntity();
if (entity instanceof FallingBlock fallingBlock && this.shouldBeIgnored(fallingBlock)) {
event.setCancelled(true);
}
}
private boolean shouldBeIgnored(final FallingBlock fallingBlock) {
return true; // Make a check here so not all falling blocks get ignored
}
This will lead to bugs and lag as the blocks just fall through the whole world
ho
They probably get killed past y-64
I still wonder why a no clip option exists in the first place
thank you !
Im having issues with opening a custom inventory. I printed out the player's current open inventory and it appears to be changing, but no GUI appears..
Before openInventory(): org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
After : org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer$1@686a2933
What are you opening
hey so I have a list of player UUIDs, im trying to create a list of players FROM those uuids,
return new ArrayList<>().addAll()
Trying to convert all UUIDs to players and add them to the new list in one line with lambda. any ideas..?
Sure there are several ways
one moment
dope
One example:
public List<Player> toPlayerList(final Collection<UUID> uuidCollection) {
return uuidCollection.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).toList();
}
Its basically the same as:
public List<Player> toPlayerList(final Collection<UUID> uuidCollection) {
final List<Player> playerList = new ArrayList<>();
for (final UUID uid : uuidCollection) {
final Player player = Bukkit.getPlayer(uid);
if (player != null) {
playerList.add(player);
}
}
return playerList;
}
alright sweet thx for that, im trying to do something like
// Gets all currently playing players
public List<Player> getInGamePlayers() {
return new ArrayList<>().addAll(uuid -> inGamePlayerUUIDs.forEach(Bukkit.getPlayer(uuid));
}
with the little lambda arrow bois, they look high tech
am I close..?
// Gets all currently playing players
public List<Player> getInGamePlayers() {
return inGamePlayerUUIDs.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).collect(Collectors.toList());
}
this should do
if statements not working
Hey guys,
I'm not sure if this is even possible but I plan to develop it if it hasn't already been done but...
Is there a way to redirect players who join a Java server on Bedrock or Pocket Edition to another server that is bedrock/pocket? If so, is there a plugin out there that already does it or am I gonna have to make one?
nevermind I found one
does anyone know how to create a lobby system like hypixel? I dont want to know all the code, just how to approach it?
Lobby system like Hypixel meaning what exactly?
open a menu, select a block, and get moved to the server
Or are you going to code it?
I want to code it
well first of all you want to establish some sort of message broker
do I need bungeecord api for that?
Which in this case redis or rabbitmq could be alternatives
I would just use a pre-built plugin like SSX personally
alright, thanks
Im having issues with opening a custom inventory. I printed out the player's current open inventory and it appears to be changing, but no GUI appears..
Before openInventory(): org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
After : org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer$1@686a2933
Heres my methods. The message "Opening Win Inventory!" does appear.
public void WinBattleGUI() {
WinInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "" + "Exp");
initWinInvItems();
}
public void initWinInvItems() {
WinInv.setItem(0, createGuiItem(Material.PURPLE_CONCRETE, ChatColor.DARK_PURPLE + "" + "Test"));
}
public void openWinInventory(final HumanEntity e) {
WinBattleGUI();
e.sendMessage("Opening Win Inventory!");
Bukkit.getServer().broadcastMessage("1: " + e.getOpenInventory().toString());
e.openInventory(WinInv);
Bukkit.getServer().broadcastMessage("2: " + e.getOpenInventory().toString());
}
I dont think ssx has the lobby thing, this is for like 40 lobbies, each holding like 30 people, and it randomly puts you in one when you join.
and you can choose what lobby you want by opening the lobby selector
Oh in that case you would want to use a proxy that has a team balancer no?
If someone could help me out in #help-server I'd be very grateful
Be patient
If someone wants to assist you they’ll surely look in the right channel (:
I've never coded anything before but I'm trying to make custom ores in 1.17. I want to replace all deepslate ores with a new custom ore; this is because custom blocks aren't effective as ores in my opinion. I believe I'd be better off replacing deepslate ores with new blocks if possible.
-
I need to rename all deepslate ore blocks, as well retexture all deepslate ore blocks.
-
I need to make a custom ore item, which would then need to be replaced with what the normal deepslate ore block drops.
-
I then need to remove the ore blocks from being able to be smelted, or if they're smelted, make it smelt into the custom item.
Is this something that is possible to do? ^
yes, as long as there is a resource pack the user downloads when they connect to the server
Yes, of course. haha
Is this simple or should I pay someone to do this for me? I've never coded anything a day in my life but I'm up for the challenge if it's not advanced.
um, I havent done anything with changing blocks that are generated, so I cant gauge the difficulty. someone else will have to do that
ah okay, no worries
I am getting this error in my command and I dont know what is wrong, couldnt find any info on what file or what part was wrong
org.bukkit.command.CommandException: Cannot execute command 'staff' in plugin StaffPlugin vA.01 - plugin is disabled.
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[patched_1.17.1.jar:git-Paper-351]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.17.1.jar:git-Paper-351]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:869) ~[patched_1.17.1.jar:git-Paper-351]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2262) ~[app:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2073) ~[app:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2054) ~[app:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[app:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:6) ~[app:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[app:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[patched_1.17.1.jar:git-Paper-351]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[app:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[app:?] at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1423) ~[patched_1.17.1.jar:git-Paper-351] at net.minecraft.server.MinecraftServer.shouldRun(MinecraftServer.java:192) ~[patched_1.17.1.jar:git-Paper-351]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[app:?]```
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1401) ~[patched_1.17.1.jar:git-Paper-351]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1394) ~[patched_1.17.1.jar:git-Paper-351]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[app:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1372) ~[patched_1.17.1.jar:git-Paper-351]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1283) ~[patched_1.17.1.jar:git-Paper-351] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-351]
at java.lang.Thread.run(Thread.java:831) ~[?:?]
understanding stacktraces can really help you to reduce the amount of time to wait for other people to help you...
yeah ik
First: We see the PluginCommand
yeah
Which is about your command.
Did it said Caused by in the stacktrace? Or that is all you got?
thats all I got
how many commands do u have
only show relavant code
if u have too much
yes
How do you register it then
getCommand("staff").setExecutor(new StaffCommand());
like my 3 other commands that work fine
what is ItemManager
this is what StaffCommand uses from it: ```java
public static ItemStack vanish;
public static ItemStack[] createStaffItems() {
vanish = new ItemStack(Material.INK_SAC);
ItemMeta vanishMeta = vanish.getItemMeta();
vanishMeta.setDisplayName(ChatColor.GOLD + "Vanish");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Toggles your total vanish");
vanishMeta.setLore(lore);
vanish.setItemMeta(vanishMeta);
ItemStack[] inv = new ItemStack[]{
AdminPanelCommand.createItem(), vanish
};
System.out.println("Created Staff Items");
return inv;
}
A
nope
This doesn't make sense
org.bukkit.command.CommandException: Cannot execute command 'staff' in plugin StaffPlugin vA.01 - plugin is disabled.
it says plugin is disabled
but your other 3 commands work?
... that is useful information
it means when you ran the command, it made an exception so bad it disabled the plugin or something
wait
so
I didnt notice this the first time
but upon initialization of the plugin
it runs into a error
saying it is already initialized
Lmao then thats why
You can't initialize multiple instances of your plugin
you can only keep one instance and pass it around
yeah...
I know exactly where that is leading to
thanks
yep
thats what the issue was
I'm trying to wait in a for loop, but it is waiting like the delay in the for loop and than it runs everything instead of waiting the time, do the thing, than waiting again and all that.
Use a repeating task instead of a for loop
?scheduling
guys if I have a lot of functions which needs to check for event handler, can I make multiple event handlers for same event. do multiple event listeners of same event execute at the same time or in the order they are registered?
Order they are registered I imagine
Generally it’s better to have 1 handler that calls multiple other functions
hey whats the best way to change a small part of a gui menu. I want the item in the menu to change to a grass block when they click on it and change them to creative mode, and vice versa. Should I make a whole copy of that and display back? Or is some efficient way possible?
Just change that slot?
Hey I have a 5 min countdown. How can I let the boss bar run down?
Use a repeating task to update the boss bar every second or whatever
i have a gamemode change event . How do i check if a specific inventory is open for that player
HumanEntity#getOpenInventory
what would it return if player hasnt any open inventory?
Read the javadocs
hey how can i check if a block that is not normally powered by redstone, is powered by redstone
specifically, a transparent block
you could check the blocks arround the one you want to check. If one of them is redstone or something which can power your block, the condition is true
I think you are also able to check if the blocks arround have isBlockPowered on true (just read about that rn)
should i use the BlockRedstoneUpdateEvent then
its osmething like that i can check for the actual event
yea that should work too
cool deal
hey how do I store player details for a tpa command which can be accessed by another class without using static hashmap? I made it using that way but I saw people saying static members are bad
Not inherently but yeah
It’s probably better to just pass an instance which encapsulates a map instead
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Believe that does go over it
ok thanks
Hello , any tips for access to config file outside the main class ?
learning java?
or just look at the guide above
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I'm learning, that why i'm asking so 🤓 , I'll take a look, thanks
in your main, make a public static MainClassName INSTANCE;
and in onEnable, at top of all code type INSTANCE = this;
then in another class, use MainClassName.INSTANCE.getConfig().....
you can access any method in main class
😩
I read that is not a good way to use singleton patern, and dependency injection better right ??
Most scenarios yes
why it is not a good way
Anyways you shouldn’t have to pass your plugin instance to any other class
If it isn’t something which for instance neeeds the scheduler or smtng
Read the article above
Or wiki page
Dependency injection
i always use constructor (di, but i like constructor word more)
you mean making a getter for it ?
@quaint mantle If I understand dependency injection inject just what you need in the method of your class.
So you’ve never ever used a setter?
No?
so what are the examples in that article
here https://www.spigotmc.org/wiki/using-dependency-injection/ at the bottom
Idk that article isn’t entirely written by me and iirc it doesn’t go over the best practices
But generally
Using singletons will make your classes have to tightly rely on specific instances
It can get hard to unit test
And you will experience a loss of reusability in long terms
So static singletons actually complexifies your code architecture as opposed to just passing dependencies
so will it do anything bad to optimization ??
Performance is negligible
I need help with cancelling player to taking out their helmet, so I equip helmet using packets to player, and I want prevent player to taking out the helmet, how can I do that?
In terms of runtime
Though I’d argue for that passing dependencies is more optimized for the developer themselves
Well
I can write an example
is this what you mean ?
doing something like this
private static MainClass instance;
@Override
public void onEnable() { instance=this; }
public static MainClass getInstance() { return instance; }
// In class "Hello"
private final MainClass main;
public Hello(MainClass main) { this.main=main; }
// On enable in main class
command.setExecutor(new Hello(this));
Or use record classes
public record Hello(MainClass main) {}
class JavaPluginImpl extends JavaPlugin {
@Override public void onEnable() {
PluginScheduler scheduler = new PluginScheduler(this);
this.getServer().getPluginManager().registerEvents(new ConnectionListener(scheduler),this);
}
}
class PluginScheduler {
private final Plugin plugin;
public PluginScheduler(Plugin plugin) {
this.plugin = plugin;
}
public BukkitTask runTask(Consumer<BukkitRunnable> action) {
new BukkitRunnable() {
public void run() {
this.action.accept(this);
}
}.runTask(this.plugin);
}
}
class ConnectionListener implement Listener {
private final PluginScheduler scheduler;
public ConnectionListener(PluginScheduler scheduler) {
this.scheduler = scheduler;
}
@EventHandler public void onLogin(AsyncPlayerPreLoginEvent event) {
this.scheduler.runTask(task -> {
//TODO
});
}
}```
Typed it on phone but yeah
In this way you avoid passing your highest order component (class extending javaplugin) to one of the lowest ordered components in the system
Assuming what we are talking about dependency injection, Am I fine for accessing config in a command ?
public final class TestMaven extends JavaPlugin {
@Override
public void onEnable() {
getCommand("test").setExecutor(new Test(getConfig()));
}
}
public class Test implements CommandExecutor {
private final FileConfiguration config;
public Test(FileConfiguration config) {
this.config = config;
}
}
Thank you guys for help
someone help me
my tpa command is not working when I removed the static from hashmap
I dont understand it
help someon pleaasa af ap
\
/
how do I paste it
oops didnt see the pastbin
in that code when I used static before hashmap it worked
But when I removed, it didnt
why is that so
what I dont understand is
are you creating a new instance of TPACommands for each player? I don't see a reason why it wouldn't work
also instead of using names i woudl recommend using UUIDs
well UUIDs are unique to each player
yeah they can be, but its just better practice. Not that it will happen but names cna overlap
hmm your code looks perfectly fine to me
if its working static but not non static that implies that you are accessing different instances of it
in this video
he makes flying plugin
in 7:01
he makes non static arraylist to store players and it works
but why doesnt the map work when I do
nothing
have you tried to debug the contents of the map?
let me check it
itll help show which bit of the code is failing
ok ok
did someone know how i get a ItemStack from a id likr this 1:3 in the version 1.17.1
as in a number id?
easyly i will get a itemstack from a number id. In the past it was Material.getMateriel(int) but doesnt works
unless you make your own lib to map number ids to a material, no
all traces of number ids were removed a while ago
names are changeable
but why it was a realy god and easy system
not really
you had to remember a bunch of arbitrary numbers
imagine if everyone on earth had a number instead of a name, its just harder lol
yeah ok but why not number and the new system
minecraft stopped supporting numbers not spigot
number's completely useless with the new system lol
if spigot were to continue supporting numbered ids, they would have to make their own id for new items
adding even more complication to the process
yeah but i like the numbers more then the new system
so did I for a bit, then i realised how useless it was
far easier to reference an item as its name than a random number
after all, you can implement your own method for it, will just take a bit
^ Material.GOLD_ORE is much easier to remember than whatever its id is
yeah it will but i have a shild with a id and like to get the item. Not everyone who create a shild like to write the word the most writing the number id
I think the fact that we don't need cheatsheets to remember material ids speaks volumes about it's effectiveness
so i will my own class for that
yay it "makes" me smile
and maybe even sub-sub-ids
as of 1.17 there are 1058 obtainable items in survival mode, so ya know, good luck
i know i will get a old list from the internet and will complete then
still, good luck 🤷♂️
You've got quite a few new items to map to ids.... that's not even including 1.18+
How do I make terrain generation with noise more variant?
most of it is pretty flat
with small hills scattered about
I can't wait to see the mess that is Pierre's implementation of the old system 👀
yeah i too vut when it works i am happy
just use an enum
1k+ items, a bunch of entities, among other things
all because they like dealing with IDs more than the current Material.RED_BED situation
best part is they'll have to update it every time an update comes out
pog
no for first its still for the 1.17 XD
You've still got a bunch of new things to make IDs for
then once 1.18 hits, you've got even more ids to create
1.19? Probably more IDs
yeah its ok i am a developer with many freetimeXD
for all minecraft 1.17 item you will need 1200 double chests
and I don't know anyone else who'd be willing to learn all the IDs needed just to use your resource tbh
yeah but i doo it what ever you will talk to me XD
wait so lemme get this right, you'd rather write 1k+ LOC instead of maybe 3 extra letters
yes
in the 1.17 its round about 64.800 Items it makes me smile XD
^
all obtainable and non-obtainable
that's....still way off
i mean you could always just write a tool that generates ids automatically but it wouldn't retain the legacy ids
some items you can't even get in any way, shape or form anymore lol
so not only are you going to be writing a bunch of IDs, you need to test them all as well to make sure they're all correct lol
Gonna pray for the resource performance too
its just gonna be one big hashmap lol
easyly i take the creative inventory and a few other items like commandblock XD
you will see
hey all I posted a thread about that tpa comand class in spigot forum https://www.spigotmc.org/threads/my-tpa-command-doesnt-work-when-removing-static-keyword-from-hashmap.531561/
Not that easy lol, you'd still need to get all the old ids
and make a bunch of new ones that make sense
yeah but yet i beginn, when i write here anymore then i end this never
can't wait to see that mess though 👌
have fun
there is no way to do that nicely imo
enum with mat, id and sub id is best way i can think of
oh wait we are in help-dev??? i assumed this was general cause optic was here
Yea, but that performance hit though lol
theres no other good way of doing it without a performance hit lol
immutable hashmap?
sql database???
....using the new material system
i think thats out of the picture rn lmao
Our boy Pierre wants to work with the old ID system
so I'm considering the current one new lol
using the New and Improved Material System (NIMS)™️
"It's just IDs, but updated!"
Trying to create a hologram after a player types in some text in chat, but getting this error:
at com.gmail.filoghost.holographicdisplays.util.Validator.isTrue(Validator.java:27) ~[HolographicDisplays-2.4.9.jar:?]
at com.gmail.filoghost.holographicdisplays.object.DefaultBackendAPI.createHologram(DefaultBackendAPI.java:40) ~[HolographicDisplays-2.4.9.jar:?]
at com.gmail.filoghost.holographicdisplays.api.HologramsAPI.createHologram(HologramsAPI.java:46) ~[HolographicDisplays-2.4.9.jar:?]```
When hooking into `AsyncPlayerChatEvent` ... is there another approach I could take?
Why can't you make a hologram async?!
so fire off a scheduled task inside the async event?

interesting, ok will go try this. Thanks @opal juniper
yeah you need to run a synchronous event in the async
thought I had tried that already... sure enough just worked!
Block block = e.getBlock();
Material block_mat = block.getType();
switch(block_mat){
case DIAMOND_ORE:
player.sendMessage("DIAMOND!!!");
break;
}
``` why is this not sending me the diamond message?
e is from a block break event
did you register the event?
yup
isnt it Material.DIAMOND_ORE?
it sends me a message when the event gets fired
u
i dont think you need to put "Material" if its in a switch case
atleast thats what i know...
alright 1 sec
It appears that 2 seconds have passed…
switch cases on enums don't require you to declare the enum class
@EventHandler
public static void onBreak(BlockBreakEvent e){
Block block = e.getBlock();
Material block_mat = block.getType();
Player player = e.getPlayer();
player.sendMessage("runned");
Random rand_int = new Random();
if(Prosperity.getPlayersAffected().contains(player)) {
player.sendMessage("its");
if (true) { //true will be changed to rand_int
switch(block_mat){
case DIAMOND_ORE:
player.sendMessage("DIAMOND!!!");
break;
}
}
}
}```
the method?
yes
why is that? its getting runned even its static...
But it makes no sense
true ill remove it
yup
Oh “ran” btw
Do unsafeEnchanments break villager trades?
as in the output item having an unsafe enchant?
having, yes
Mostly not… I see in some servers use shopkeepers with an enchant 30 sword and it didn’t break
I don't think it does
Can i force the player to refresh chunks (F3+A) when it joins the server?
Why?
why?
Hi, which event is called, when a falling sand block collides with a torch, and dies?
maybe nothing?
lemme check
I would like to cancel the action and let the sand block sit on top instead.
why dont u check it too?
Which event to use?
Should be something like EntityDeathEvent as FallingBlock is an entity
You can only send unload packets and then chunk packets again
Some things i would test:
EntityCombustByBlockEvent
EntityDropItemEvent
EntityInteractEvent
EntityChangeBlockEvent
Pretty sure its that with target block as air
If not then probably no event, open a feature request
I read, that the EntityChangeBlockEvent would only fire, when the sand block is placed, but not when it dies by a torch.
But I can check it out of course.
I see. But the EntityDropItemEvent looks viable too as it actually drops itself.
Though the EntityDropItemEvent doesn't provide a spawn cause, so it might be hard to track right?
But you would have the Entity that dropped it.
Ohh right. I thought of the ItemSpawnEvent. Let me check whether yours fires for sand.
I was given some good help yesterday but I can't seem to implement it... I created a thread, (Generating items from config) could I request some assistance there, please?
I looked, I don;t see what you are stuck on. You have been given pretty much all you need
Indeed... I am aware of that, I've just been trying to implement the code and it seems I am not capable of that... I've been spending some time watching some java tutorials and a lot of googling trying to implement it properly.
Yea i thought that too
Okay, so indeed the EntityChangeBlockEvent fires for the first air block. Then you could scan down in a hacky way.
But the EntityDropItemEvent also fires and has the falling block as dropper/entity, which makes it the clear winner.
The other events don't fire and can be ignored for the most past.
Thank you guys. 🙂
Why are NBTTagCompound.entrySet() values LinkedTreeMaps instead of normal objects like String, List, Double etc...?
Especially since you can't set a linkedtreemap in the compound.
tags.entrySet().forEach(entry -> {
String key = entry.getKey();
Object value = entry.getValue();
String found = "None";
if(value instanceof String) {
compound.setString(key, (String) value);
found = "String";}
if(value instanceof int[]) {
compound.setIntArray(key, (int[]) value);
found = "IntArray";}
if(value instanceof Integer) {
compound.setInt(key, (Integer) value);
found = "Integer";}
/*7 other if statements for other instances*/
ConsoleOutput.debug("Tag: "+key+" Value: "+value+" Value Class: "+value.getClass().getCanonicalName()+" Instance: "+found);
});
[DEBUG] [**String of values list**]
[DEBUG] Tag: Unbreakable Value: {x=1.0} Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
[DEBUG] Tag: HideFlags Value: {c=6.0} Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
[DEBUG] Tag: display Value: **display json** Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
[DEBUG] Tag: Enchantments Value: [**enchants**] Value Class: java.util.ArrayList Instance: None
[DEBUG] Tag: Damage Value: {c=1560.0} Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
I was given some code to help me with creating items automatically from my config, but I am little bit confused for the final part, what do I put there?
public class CustomItems {
private static final Map<String, ItemStack> namedItems = new HashMap<>();
public static ItemStack getNamedItem(final String name) {
return namedItems.get(name);
}
public static void loadFromConfig(final FileConfiguration configuration) {
final ConfigurationSection itemSuperSection = configuration.getConfigurationSection("Path.To.Super.Section");
for (final String key : itemSuperSection.getKeys(false)) {
final ConfigurationSection itemSingleSection = itemSuperSection.getConfigurationSection(key);
loadSingleItemFromSection(key, itemSingleSection);
}
}
private static void loadSingleItemFromSection(final String key, final ConfigurationSection section) {
// Load the ItemStack from a section and put it in the Map
}
}```
Talking about the last bit "loadSingleItemFromSection", wording confuses me a bit
I understand the "pathtosupersection" being just the path to the part of my config I want to get stuff from, but that "load the ItemStack from a section and put it in the Map" has me confused
section.getItemStack
Right, but for the path it requires there, do I just put the string-value of section or something static to point it to the part of the config I want it to take from?
the section is already extracted from the path
Is it possible to have custom GUI on the player screen with spigot? like Hypixel has
I am just as confused. Do I just namedItems.put(key, section)? If I am completely off the reservation here, could you point me to the correct resource to learn more about this?
Hello, i would like to edit the name of a player above the head. Is it possible to do that with spigot?
you are getting items not adding them
section.getItemStack insists on having a String path
"Load the ItemStack from a section and put it in the Map" has me confused a bit then
yes, you use teh name of the item
How do you create 2D GUIs like this?
yeah I am very confused. I am trying to create items from a config so now I am thoroughly confused
Is it possible with Spigot?
that is a scoreboard
Yes, it's a scoreboard
technically its possible in vanilla
but spigot makes it easier
imo
aaah oke
so am i able to change the position aswell?
Like on top of the screen
no
So how would you create something like this?
BossBar
Alright, thanks for the help
Man I must be thicc as bread... I want to generate items automatically from a config, what's the most efficient way to do that?
If there's some article I can read, video I can watch or whatever that'd be great
I've been trying to find resources myself, figuring out from code I already have etc etc but I just can't seem to crack it.
I'm looking tutorial with onBowShoot event, but I can't find this event in the documentation. (he's teleporting where the arrow hit) Maybe it doesn't exist anymore and replaced by ProjectileHitEvent ? Or am I looking at the wrong place ?
Man I must be thicc as bread...
I have never heard this saying once in my entire life.
Yeah well there you have me. I've been stuck at this for days, even with someone having written code for me I just can't understand how to use it? Like am I just that thick?
Hello, does someone knows how to create a new MobEffect (NMS)
Would like to give invisibility to an EntityPlayer
just get its bukkit entity
and use the spigot methods
EntityPlayer#getBukkitEntity()
I can't do that since it's not a logged player
it will try to send the packet to the player to add the potion effect
but you have an instance
sure
?paste
Saying that the connection is null
@SuppressWarnings("deprecation")
MobEffect invisibilityEffect = new MobEffect(MobEffectList.fromId(PotionEffectType.INVISIBILITY.getId()), Integer.MAX_VALUE, 2);
pc.sendPacket(new PacketPlayOutEntityEffect(ridable.getId(), invisibilityEffect));
Tried that but doesn't work 😢
ProjectileLaunchEvent is when someone shoots a projectile, ProjectileHitEvent is when an arrow actually hits something
Yes ok, but where I can find event like this one : onBowShoot
I tried to search on spigot doc but i don't know how to find it
ProjectileLaunchEvent
That's fired when someone shoots a bow
You just need to make sure it's a bow @acoustic widget
How can I set the skulltype?
What version
1.12.2
Are you trying to get a Player head or what
yeah
If Material.PLAYER_HEAD doesn't exist, make a skull item with a data byte of 3
guys how can i force a player to walk somewhere?
Set their velocity, there's not a way to do that gracefully I don't think
Ok so you are agree with me onBowShoot doesnt exist anymore right ?
I don't think that ever existed
If it did it's really really old
I was watching a video on 1.13 (2018)
and then tp them, right?
I think you're looking at the name of the method and not the actual event name @acoustic widget. If you go watch the video again I'm guessing they use ProjectileLaunchEvent
Setting their velocity should slowly move them towards whatever location you want, shouldn't need to teleport
ohh
that's what i'm doing wrong then lol
i've been using this method
target.setVelocity(vel.normalize());
target.teleport(loc);
Yeah you should just set the velocity
i'll try that ty
LOC.get(i).getBlock().setType(Material.SKULL);
Skull skull = (Skull) LOC.get(i).getBlock().getState();```
But how can I set the skulltype to a playertype?
Hmm, I'm not sure. This was all changed in 1.13 so I don't remember how it was done, you might just have to do some Googling.
okay ty
Hey, I'm trying to get player inventory information like so, I know I can use item.getType() and item.getAmount() to get the type and amount, is there something to get the slot it was in in the inventory as a number?
ItemStack[] items = player.getInventory().getContents();
ArrayList<String> itemList = new ArrayList<String>();
for(ItemStack item : items) {
if(item != null) {
// item.getType(), item.getAmount(),
}```
what
sorry let me rephrase
you mean get the index of the itemstack when its in the arraylist?
I'm trying to build a list of items in a players inventory, I know how to get the item type and amount, but I'd also like to get the position (slot i guess?) of it in the players inventory
hi, what about built in bukkit ORM? Is it good?
can’t you do like Inventory#getSlot
i think he means to get the original slot index or something
dont
manager.setupCommands(this);
manager.setupListeners(this);
manager.setupBungeeCord(this);
try ```java
Manager manager = new Manager(this);
instead
you understand what i mean?
i did it like this but that looks the same
private boolean setupChat() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
return chat != null;
}
also i don't know if the extra space before Vault in your plugin.yml causes it
i think it does
probably the rsp is null in that way
quick question, how would I go about constantly making zombie piglins angry at everyone all the time? I found the PigZombieAngerEvent in docs but dont know how to use it.
Cant you make them angry when they Spawn?
oh yeah, could i use zombifiedpiglin.setAnger(1);
or this zombifiedpiglin.setAngry(true);
i think this could work. thank you!
Hey friends, I wanna make days a little bit longer my SMP using a plugin. Can I just set DO_DAYLIGHT_CYCLE to false while the sun is up and then set it back to true a few thousand ticks later or is that gonna cause some problems I'm currently not thinking of?
should be fine
the best ways are the ones already in minecraft
don’t work harder than you have to
Haha true, thank you! 🙂
Hi. I'm pretty new to Java. How would I fix this error?
You need to pass an instance of your Announcement class into JoinListener()
And how would I do that?
Show more code
In what class?
That one
Okay so
Instead of doing new Announcement() inside of the setExecutor
Make a variable for it
Announcement announcement = new Announcement();
ok
Then you can put setExecutor(announcement); and also new JoinListener(announcement);
It's giving me an error
It's yellow
What parameters?
new JoinListener and “this”
Wait
Confused. What is your announcement class and JoinListener class
Also I’m pretty sure you have to use registerEvents instead of registerEvent
That’s prob why it’s not working
No error now?

What exactly about it doesn’t work
I'm trying to debug my plugin because it lags the server
How am I supposed to pinpoint the exact location in the code that causes it?
0.39% 666.33% 0.33 s 333.17 ms 0.0 0.0k Task: Database$$Lambda$4362/0x0000000801797878(Single) I got this from /timings pase
You could run a timings report
Oh
Okay are you calling to the database on the main thread?
Probably
Database calls need to be executed asynchronously
it looks like it but
I am wrapping the calls in an asyncv scheduler
Hmm
Show?
Bukkit.getscheduler.runasync()
How would u guys go about solving this issue:
- kicked with message asynchronous getNearbyEntities
- getNearbyEntities is never called
Something is messing up hard here
this seems to happen here:
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Map.add(e.getPlayer(), System.currentTimeMillis());
Database.getInfo(e.getPlayer().getUniqueId().toString(), (result) -> {
Map2.add(e.getPlayer(), result);
});
}
Ok show your get info method
I'm look for a plugin which I can make teleport command so like I can do /plots and it teleport me
Also I hope you aren’t mutating the Map2 asynchronously or you’ll have problems
inside getInfo:
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
int result;
PreparedStatement statement = connection.prepareStatement(Queries.get_info);
statement.setString(1, uuid);
ResultSet set = statement.executeQuery();
if (set.next()) {
result = set.getInt("info");
} else {
result = 0;
}
set.close();
Bukkit.getScheduler().runTask(plugin, () -> callback.accept(result));
} catch (SQLException e) {
Logger.logError(e);
}
});
That looks fine, only thing I see is you not closing the connection
Are you using a connection pool?
no
I would suggest looking into doing that. HikariCP is a good one.
Also you never close the statement either. Closing the resultset doesn’t close the statement, however closing the statement should close the resultset
oh
so am I supposed to replace set.close with statement.close?
Yep
You could leave the set.close if you want, for clarity
And put the statement.close after it
Basically you want to close things in the reverse order that you made them
yeah