#help-development
1 messages · Page 193 of 1
move the sysout in the listener above the isNewChunk test
k
You are going to have to change how you load that Structure as you are currently saving it to your plugin folder.
shared loot tables are a hassle to make
default load is from the world folder, so you need to use the load method that allows you to specify a path
so howww
Oh
mb
mb
@eternal oxide
i already did it
plugin.saveResource("backrooms.nbt", false);
load
not save
this.backroom = Bukkit.getStructureManager().loadStructure(new NamespacedKey(plugin, "backrooms"));Needs to load from yoru plugin folder
as saveResource defaults to your plugin folder
SO loadResource?
No
then?
this.backroom = Bukkit.getStructureManager().loadStructure(new NamespacedKey(plugin, "backrooms"));Change that
there is another load method which takes a path
which method is that?
File
instead of NamespacedKey
or I guess you could just InputStream from teh jar itself
so file
making a loot need / greed system is such a hassle
new File(plugin.getDataFolder(), "backrooms.nbt")
unhandled JavaIO exception
is there a file in your data folder called rooms.nbt?
backrooms.nbt yes
in your data folder?
You are not answering what I am asking
No, its in the resoruces folder
no, that is your project not your server
oh
your server has a plugins folder...
Im aware
inside teh plugins folder you have a folder for each plugin, IF you saved a config or created the folder
I dont have a config folder
lol
Haven't created it
calling saveResource tries to put the resource in your plugins data folder
then in onEnable this.getDataFolder().mkdirs()
before you saveResource
Oh, it did create the folder 🤦♂️
Its in there
so long as the name is correct
anyone know what its called
i totally forgot
trying to remember
thats a warning. hover over it and select wrap in a try/catch
but cant
worldguard?
BoundingBox
hello friends
not sure why i totally forgot that :(
Donee
Its in a try/catch
is there a way in the API to add an item to a player in a way that will drop it if the inventory is full by default?
I know it's easy to do it manually, just wondering
add to the inventory returns a Map of everythign which didn;t fit
its still somehow not calling on the listener
did you move the sysout above the isNewChunk test?
I already wrote the workaround, was just wondering if there was an api method for it
yes
is the event even registering with it not being in getServer().getPluginManager().registerEvents
oh very good point. I hadn't noticed
^
getServer().getPluginManager().registerEvents(new BackroomsListener(this));
silly mistake. probably mine for not noticing
lemem guess in oneable right?
yes
im having a really weird bug in my code and I cannot for the life of me figure it out...
@EventHandler
public static void playerPunch(PlayerInteractEvent event){
Player player = event.getPlayer();
if(event.getAction() == Action.LEFT_CLICK_AIR){
if(shiftTime.get(player.getUniqueId())>5){
int range = 100;
Location loc = player.getEyeLocation();
for (int r = 0; r < range; r++) {
/**
Block block = loc.getWorld().getBlockAt(loc);
if(block.getType()!= Material.AIR){
r = range;
}
**/
List<Entity> entities = (List<Entity>) player.getWorld().getNearbyEntities(loc,2,2,2);
for(int e = 0; e < entities.size(); e++){
LivingEntity entity = (LivingEntity) entities.get(e);
if(entity!=player) {
entity.damage(9);
entity.setFireTicks(60);
}
}
shiftTime.put(player.getUniqueId(),0);
//isFireShot.put(player.getUniqueId(),false);
player.getWorld().spawnParticle(Particle.SMALL_FLAME, loc, 15, 0.03, 0.03, 0.03, 0, null, false);
loc = loc.add(player.getEyeLocation().getDirection().multiply(0.5));
}
}
}
}
shiftTime is a map of ints, i have another method in order to iterate it for every tick a player is sneaking, and reset when release.
I have detection for if the ray runs into a block, but it is commented out.
my bug is that after I kill an entity, the place where the entity died will stop the ray.
its as if a barrier is blocking the ray.
Stop using sysout 
replace the line it's from
use sysout as much as you want for debug
Its only paper asses that don;t like it
Bukkit.broadcastMessage better imo
Or people who like to know where a message is coming from
if it's your plugin and you are doing debug it's perfectly suited
@eternal oxide erooor
show
yep
Also never used paper in my life
public class TotemPouchCache extends CacheLoader<UUID, TotemPouchItem> {
public TotemPouchCache() {
}
@Override
public TotemPouchItem load(UUID key) throws Exception {
return new TotemPouchItem(TotemPouchType.POUCH_SMALL);
}
}``` I feel like I'm totally misinterpreting how a cache should work, but its not clicking for me.
I want to allow multiple totem sizes in the cache. the docs for load say `Computes or retrieves the value corresponding to key.`, but shouldn't the cache be the one handling the storage of the value attached to the key. It seems counter productive to have to pull from my database and construct a new object every time I want to load from the cache. Honestly to me it seems like it defeats the sole purpose of a cache. again likely me just being dumb
^
do your sysouts now print?
nop
oh wiat
i didnt update plugin 😅
@eternal oxide
[ERROR] Error occurred while enabling Backrooms v1.0-SNAPSHOT (Is it up to date?)
java.lang.RuntimeException: java.util.zip.ZipException: Not in GZIP format
at backrooms.backrooms.BackroomsListener.<init>(BackroomsListener.java:28) ~[?:?]
at backrooms.backrooms.Backrooms.onEnable(Backrooms.java:15) ~[?:?]
?paste full error
https://paste.md-5.net/udinavigeq.cs @eternal oxide
corrupt jar?
no corrupt backrooms.nbt
BackroomsListener.java:28 probably where it tries to load the Structure
delete teh backrooms.nbt from your server
let the plugin create a new one
k
@eternal oxide
teh debug works
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
[INFO] Hi, this means that the code for structure placement works, sort of!
delete the world and startup
see if any Structures are spawned
you can remove the debugs now
k ill delete it and no structures spawned
@eternal oxide
no structures spawned
wdym startup
you can't delete teh world with the server running
so stop server, delete world, startup
yea ik
delete the backrooms world
or
the main
I thought you were testing all this in the main world "world"
I was testing in ze backrooms world
ah ok, then delete Backrooms
when you teleport to the new Backrooms world be sure you goto 0,0
@eternal oxide
[ERROR] Error occurred while enabling Backrooms v1.0-SNAPSHOT (Is it up to date?)
java.lang.RuntimeException: java.util.zip.ZipException: Not in GZIP format
at backrooms.backrooms.BackroomsListener.<init>(BackroomsListener.java:28) ~[?:?]
when i deleted it it didnt regenreate the nbt
it only creates it when you start the server
I did start the server
also that error seems to say it created an empty file
it didn;t copy the actual resource
so how would it cop ythe resource
Its encrypted
@eternal oxide
its a valid zip
so, what happened
it also has contents, but its a lot of nulls
No clue why you are getting a zip error. its fine
so what should I do
nope I just checked the file is fine
so nothing
show me your current BackroomsListener
public class BackroomsListener implements Listener {
Structure backroom;
Plugin plugin;
public BackroomsListener(Plugin plugin) {
this.plugin = plugin;
try {
this.backroom = Bukkit.getStructureManager().loadStructure(new File(plugin.getDataFolder(), "backrooms.nbt"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@EventHandler
public void BackroomsGenLoad (ChunkLoadEvent e){
if(e.isNewChunk()){
Bukkit.getScheduler().runTask(plugin, () -> {
Location loc = new Location(e.getWorld(), e.getChunk().getX() * 16, 40, e.getChunk().getZ() * 16);
backroom.place(loc, false, StructureRotation.NONE, Mirror.NONE, 0, 1, new Random());
});
}
}
}
what is line 28?
is it the loadStructure or the place thats throwing the error?
you could try this.backroom = Bukkit.getStructureManager().loadStructure(plugin.getResource("backrooms.nbt");
that shoudl load it straight from your jar, so no saving to file needed
says it might be null
@eternal oxide
then you need to test it or ignore the warning
i can delete save resource right?
yes
no clue then. There has to be something wrong with your Structure file
I've not tried loading it myself but it looks ok
I'm starting my IDE to test it
The Structure file is bad. It won;t load for me
how do i check every player on the server's killstreak at, basically like it constantly scans all online players killstreak
you'll have to track killstreaks yourself
like how?
check when a player kills another player, and reset to 0 if they die
so how would i consantly check that
player death event probably
in a while loop?
on player death event add the killer to something you can track, each time they kill someone add one to their kill streak, if they die remove their kill streak
Hey mates, would anyone know of a way to spawn an arrow where it doesnt trigger a EntityLaunchProjectileEvent, or apply PersistentData before spawning the arrow? Im trying to spawn a double/triple arrow, but since im spawning it in the projectile shoot event, it gets called infinitely. Any ideas?
Why not apply PDC to the extra arrows so that you can check for it and not spawn more arrows?
cause the event gets called right as the arrow spawns, so adding PDC after its created would be too late before the next event is called
It definitely should not
I wish, this is what I have, I create an ignore PDC and listen to if the arrow has it in the projectile event and it doesnt have it during the new event
I created something that worked, like an ignore list, but that only works for one arrow duplication, I want to be able to create 3, 4 or 6 shot varients
What about a custom arrow. You can then instanceof check it
huh, thats possible?
Should be
that would totally work if I knew how to do that xD
I just make a class and Extend the bukkit Arrow class?
Probably something you'd have to do through NMS
The only other solution I can think of is spawn the other arrows 1 tick after using a sync runnable
Why do I get incompatible types: java.lang.Class<com.neomechanical.neoperformance.version.halt.HaltWrapperLEGACY> cannot be converted to java.lang.Class<? extends com.neomechanical.neoutils.version.VersionWrapper> every time I try to compile for these classes?
package com.neomechanical.neoperformance.version.halt;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.server.ServerCommandEvent;
public class HaltWrapperLEGACY implements IHaltWrapper {
}```
package com.neomechanical.neoperformance.version.halt;
import com.neomechanical.neoutils.version.VersionWrapper;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.server.ServerCommandEvent;
public interface IHaltWrapper extends VersionWrapper {}
the ide doesn't warn me either
this only started happening when I changed my pom, my current one is:
my older one used the embedded neoutils on line 83
Since when can an interface extend a class
holy it can
didn't know that 🤔 crazy
I honestly don't see a reason your interfaces should extend eachother though since IHaltWrapper has no content you could just implement both in your target class
that could be partially your issue
nvm I have no fucking clue what I'm talking about apparently did research
The full code is here https://paste.md-5.net/qayilopeye.java
hi
Hello, please help, I made it send me a message when I entered a portal, but when I entered, it spammed me, how do I make it so that I only send it once?
yeah fax its line 69
@EventHandler
public void portal(PlayerPortalEvent event) {
Player p = event.getPlayer();
p.sendMessage("Hola!");
p.playSound(p.getLocation(), Sound.VILLAGER_YES, 10, 2);
}
?
Create an ArrayList with the players UUID to prevent chat spamming.
Show code
@EventHandler
public void portal(PlayerPortalEvent event) {
Player p = event.getPlayer();
p.sendMessage("Hola!");
p.playSound(p.getLocation(), Sound.VILLAGER_YES, 10, 2);
}
Yeah make an arraylist, add player to it, and then check if theyre in arraylist
Hi, I want to ask, I use ArmorStandTools and I do not know what and how about WorldGuard, someone please help me?
How to remove "This message has been modified by the server"
What about WorldGuard
Hello, please help, I made it send me a message when I entered a portal, but when I entered, it spammed me, how do I make it so that I only send it once?
Create a global HashMap with the Player UUID stored as the key and the current time in miliseconds, and in the event check if the UUID of the player exists in the hashmap and if it does then check how long ago it was, if it was shorter than 1 second then add a return statement
else make it add the player to the hashmap and add the current time in miliseconds
@hoary wing
HashMap<String, Long> playersInPortal = new HashMap<>();
@EventHandler
public void portal(PlayerPortalEvent event) {
Player p = event.getPlayer();
if (playersInPortal.containsKey(p.getUniqueId().toString()) && (System.currentTimeMillis() - playersInPortal.get(p.getUniqueId().toString())) < 1000)
return;
p.sendMessage("Hola!");
p.playSound(p.getLocation(), Sound.VILLAGER_YES, 10, 2);
playersInPortal.put(p.getUniqueId().toString(), System.currentTimeMillis());
}
this should work
Stop using statics and itll all be fine
what statics?
General advice ^^
“Static abuse” is rarely an issue but sure
If it makes sense for a variable to be static then make it static, otherwise don’t
it isn't a rare issue
Agreed
also, don't use statics if you don't know the implications of using them are
its not a make sense thing
Well yeah but most uses of static are fine
Like if u make ur plugin instance into a static variable
Yes that is allowed because the main class follows the rules in what is acceptable to be static
What’s an example of a static variable being problematic?
static prevents objects/classes from being GC'ed so if you were expecting to have multiple instances instead of 1, that would be a problem
GC’d?
Oh yeah true
there is other implications like getting null variables from invoking static methods in classes because they are not setup appropriately to handle being static
I am not saying statics should never be used, just if you have no knowledge of them or how they can be bad, it is better to just not use them
then to use them and then encounter all kinds of problems all because of using static incorrectly lol
Hi guys, I'm working on 1.19.2 version but sometimes, the plugin is null (I don't know why)
Caused by: java.lang.NoSuchFieldError: plugin
Below photo is more detail about it
When I restart my bungeecord server it changes one part of my config (plots.root) to {} even tho I never set that anywhere. That doesnt happen on my spigot server. Through what could that happen?
The only time I set plots.root is in a command
Hey so i made a plugin which allows a creeper egg to launch like a snowball, all works great apart from i'm struggling with the explosion part for impact on block and/or entity, I've tried it a few ways, the nearest i got was explosion on entity only
I know this is very wrong, it was the last attempt i done, just showing it so you can see what i'm getting at it
?paste
You probably have to store some data within the entity and then listen with a ProjectileCollideEvent
within the ProjectileCollideEvent you'd check the type of the entity (snowball) and then check if it has the data (use persistent data containers)
if it does you can prob spawn TNT at that location with a fuse of 0 and it should insta-detonate
I just need to check for block hit and hit entity but how i had it was only working for hit entity, i can make explosion world#createExplosion
id assume you dont want all snowballs to create an explosion right?
also maybe add a console log to check if ur if statement is being ran correctly
This works for entity's hit but I need it on block impact too, also I'm adding checks for meta to make sure it's only specific item, or will use pdc
Just trying to get it to work before i add that
Wait wouldnt item.getType().equals(Material.CREEPER_SPAWN_EGG) always equate to false?
No mate, in other class it's iitemstack set to thatr
So the actual item in the inv is a creeper egg, its the event on right click that changes everything
Is this for the persistent data container for a hopper?
yes
make sure u run the .update() function after u set it
Ah I see now. Is the problem that an explosion isnt happening?
I think the ProjectileHitEvent only triggers on entities
try ProjectileCollideEvent
Ahhh okay will give this a go
Hi im getting an error with the following code. The input items is of class ItemStack[], so why does this throw an error when it tries to cast the the resulting Object[] to ItemStack[] and how can i make it so that it works
Hi, I'm trying to get my boat (MyBoat extends net.minecraft.world.entity.vehicle.EntityBoat) move. However, when the player is sitting in the boat,
calling super.move(EnumMoveType.a, new Vec3(0,0.3, 0)) does not lead to anything. Please tell me how I can move the boat in which the player is sitting?
toArray(ItemStack[]::new)
thanks!
Try teleporting the boat or smth
also why use obfuscated nms 🙃
player controls vehicle movement iirc
^^
i think setting velocity works
You mean.. move the player, and the boat will move itself?
teleport doesn't work
probably localized pricing
Nitro basic
Args being a command argument?
Then null check
Obviously have null checks etc
soo 0 for 1st
Yup
arrays in java start at 0
unless you are using some lib where it creates arrays with indexes at 1 instead lol
Luacore
wait so once i get the player do i do smth like Player p = Bukkit.getPlayer(args[0])
orer
orr
i did i think
And check if args[0] exists
args != null
Args.length >= 1
Bukkit.getPlayerExact 🥺
i did if (args.length == 0){
Early returns?
getPlayerExact is smelly
Nice nice
i got "method invocation "setHealth" may produce NullPointerException" even tho i did null checks
Show ur code
?paste
IDE warnings are not the same as errors
did you compile and test it?
no cos i ghave some { errors i needa fix
Depends on how correct the warning is
not all warnings from the IDE are correct
i have 3 warnings
Condition 'args == null' is always 'false'
Implicit call to 'toString()' on array 'args'
Method invocation 'setHealth' may produce 'NullPointerException'
thats itr
getPlayer may return null
Did you null check the player ?
Also args will never be null, but it can be empty
args.isEmpty()
Length == 0
Check if null
args == 0 is not the same as args.length == 0
don't check for null....obviously
okk
remove it o.O
not sure why we are having to repeat this
i did remove it
only 1 warn
'class' or 'interface' expected
at last }
wait no thats an error not warn
you missing a closing bracket or semicolon somewhere
the player (client) controls movement of their vehicle
as I said try setting the velocity on the vehicle
just don't sent a high number for velocity
ok all fixed
unless you like to see it disappear into the distance 😄
also is there a way of auto-completing args to be tabbed to ojnline players?
if u get me
Yes
I need to move the boat vertically /
Implement TabCompleter
I mean you need code inside the method
- collisions of several boats, or its gravity is controlled by the server. I'm pretty sure there's some way
ok ity all works just when the /kill is not a player it says internal servere error
so i just need a msg fo that
is it possible to save variables without using a config file?
how do i fix Class 'Feed' must either be declared abstract or implement abstract method 'onTabComplete(CommandSender, Command, String, String[])' in 'TabCompleter'
Implement the method
Usually your ide has a button to do it
i gotta use the method
ah
figured out
nvm
Casting 'Bukkit.getPlayer(...)' to 'Player' is redundant
how to fix dat
if i can
why do u need to cast it
Don’t cast it
find java tutorials and better not ask such shameful questions here ..
im watching a tutorial but its outdated so im tryna do it myself 💀
do you know what redundant means
it means useless
instead of asking simple questions try and do some problem solving
you need java tutorials, not plugins
no reason to make a plugin if u dont understand why it works
you'll just run into more problems later
im just doing it for fun cos i have nunn better to do
that doesn't mean we like to help with useless things because you chosen to not to do your part either
it doesn't matter for what. If you don't know the programming language you're going to write in, then you don't even have to start.
how's the christmas cat
hello
I have a problem with teleportation
PlayerTeleportEvent may only be triggered synchronously
this is normal
But the teleport doesn't work
use bukkit tasks
for example, run the desired task synchronously, after a certain time
it is also possible, but I use a little different
please show me, I'm just starting to learn the spigot api))
1 min
?scheduling
@Override
public void run() {
//code
}
}.runTaskLater(PLUGIN, DELAY);```
да, но тут не принято использовать локальные языки .. используй как все, английский, чтобы другие нас понимали
ok
in ticks
th
🥶
Hi, I have the following code and it works perfectly fine but i feel like its quite clunky, is the a way i could do the same stuff but shorten it down? it seems a little unnessary repeating it twice, and the condition is quite long, but its not as simple as setting a Arrays.stream(items).filter(/*CONDITION*/) to a variable because it throws an error that the stream is closed or consumed
if (Arrays.stream(items).filter(/*CONDITION*/) != null)
items = Arrays.stream(items).filter(/*CONDITION*/).toArray(ItemStack[]::new);```
how would i give the player 64 of an itemstack
Setamount
inventory.addItem(new ItemStack(Material.getMaterial(item))); i have that
yeah a ,64 will do nicely
would i add ,64 after item or after the ) next to item
uh what
try it and see
just pass in a big filter ig
cxomes back with an internal server error
Player p = (Player) sender;
p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "ESSREVAMPED " + ChatColor.RED + "Please select an item to give to you!");
}else if (args != null){
String item = args[0];
Player p = (Player) sender;
PlayerInventory inventory = p.getInventory();
inventory.addItem(new ItemStack(Material.getMaterial(item),64));``` thats my code for the item thing
Why do you even need that if ?
if there are no items matching condition, you would just get empty array
why does this nto work
?
Going to need that error
yo, exists a method to create a countdown without scheduling?
No use the scheduler
okay thanks
where is the error thrown?
I usually do both
same
Version for each class and reflection as fallback should the version not be supported
but for now I do only Reflection
but if I wanna do custom Entities via NMS then I will need each version class because you cannot extend classes with Reflection
Caused by: java.lang.IllegalArgumentException: Material cannot be null
but i alr checked for null
so what tf am i meant to do
send code
try Material.valueOf()
and make sure its all in upper case
mh
what in upper case
i did the value of
valueOf() needs all Uppercase letters I believe in order to get the value
valueOf("STONE");
I think the rest should be googleable
inventory.addItem(new ItemStack(Material.valueOf(item),64));
all i got is that
and the item is set to arg
item.toUpperCase()
and then it should work if you type in stone just as well as with STONE
memorizing the methods of a class xD
yep it all works, is there a way to make it tab complete to all the blocks in the game?? probs not
ye there is
yes you can
you can use Material.values() to get all values
Use Material#values
also when using Material values
then a simple stream to convert them to strings
after that check if the Material#isItem
would i have to implement tabcompletions im guessing
it will get all the items and Item Blocks
if you do not filter it then there will be some items which are gonna be BlockStates
and they're are not gonna be certainly items
they're gonna be like AIR
if you don't know anything about TabCompletion check some tutorial in Youtube KodySimpson have a good one
kk
I have made myself a custom Command Handler with a lot of shortcuts
im trying to use forgegradle for 1.12.2, but im getting this error when reloading the project (build.gradle https://pastes.dev/eB1scqKxz9), gradle version 7.3 @ java 17
Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name 'compile' not found.
at net.minecraftforge.gradle.user.UserBasePlugin.configureCompilation(UserBasePlugin.java:526)
at net.minecraftforge.gradle.user.UserBasePlugin.applyPlugin(UserBasePlugin.java:158)
at net.minecraftforge.gradle.common.BasePlugin.apply(BasePlugin.java:213)
at net.minecraftforge.gradle.common.BasePlugin.apply(BasePlugin.java:90)
got dang 40 mins
he makes good and detailed tutorials
which ForgeGradle version you use?
I have 10GB ram with 27 plugins but the ram when the player joins the server the ram goes up when the player leaves the ram does not go down (The ram never goes down i need to restart the server) can some one help me ?
all information should be in the build.gradle paste i sent
you can ask this in the #help-server section
Please use older Java Version and Gradle v2 or something like this
I use Java 8 and Gradle 2.3 I believe
you can also try Gradle 4.9
yeah
Could not resolve: net.minecraftforge:forgeBin:1.12.2-14.23.5.2768
hmm
do you have an example build.gradle i could try
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class GiveTabComp implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (args.length == 1){
List<String> playerNames = new ArrayList<>();
Player[] players = new Player[Bukkit.getServer().getOnlinePlayers().size()];
Bukkit.getServer().getOnlinePlayers().toArray(players);
for (int i = 0; i < players.length; i++){
playerNames.add(players[i].getName());
}
return playerNames;
}
return null;
}
}``` how do i convert this into a block array not player
i just copied tt tbh
change the stuff in the if(args.legnth == 1) if statement
something > 1 safer
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.
what do you mean by Block Array?
array of all blocks i assume
Im trying to unregister custom enchantment via this code: https://paste.md-5.net/riyaticebo.cs
but I always get this error: ( I understand why I get it, but idk how to get rid of it) https://paste.md-5.net/xibicomera.md
you only need each version if it has changed
if it hasn't changed it is enough to use reflection to just point to the appropriate class
yeah
a good way to point to appropriate versions is to make use of Enums
what I mean is, you can put class names into enums
so does this allow like extend Enum.SOME_VALUE
yeah ik for this
but if I add a method which is for getting the class
so it will be like ENUM.SOME_VALUE.getClazz()
basically
basically this will work?
bro if this is right
you opened a whole new thing to me
how I can find more of this information
not entirely sure of decent resources on like everything enum
most of my information is because I have been using Java ever since it came out 😉
just following the specs and what not
How can I add a player to a luckperms group by code? Just give him group.(name) permission or?
well two ways exist for that
I am fairly certain luck perms has an API component you could use
or make your plugin invoke a command for given plugin
typically recommended to use an API if there is one
then you're a Java Boss
you can even use Reflection to set enum values too dynamically
the resource you posted is for Enums to extend Enums I believe
but still I don't know if its possible to Java Class extend Enum.VALUE.getClazzFromTheEnumValue()
You can't extend enums, however the appropriate way to extend an enum is to have an enum implement an interface instead
yeah I read that
but this is only for Enums
I don't if it is possible for classes
not sure what it is you are saying
Java classes can not extend enum....so not sure what exactly you are asking that is or is not possible
honestly if you are in a scenario where you would find yourself wanting to extend an enum you are probably structuring something incorrectly
I will show you a dynamic enum
that doesn't use reflection
okay
this particular enum that is linked, is dynamic
it is dynamic because of the code below, more specifically at the end of the enum class
You can use reflection however, to simply remove the end method and just stuff what you wanted into the enum itself
very handy for version specific things that only apply at say runtime
Yeah I use reflection in the Enum Value
instead of an overloaded enum, you could simply just have 1 value in the enum and said value is created at runtime 😄
yep
but my question firstly was
not certainly a question
but that if you want to create a custom NMS mob which extends NMS mob you will need to make it for each version because as far as I know Java cannot extend a Class which is got from runtime
also is it problem to use private in the Enum variables?
and final
you don't have to make it for each version unless it changed
yeah I know that after 1.16 the version packages doesn't have version number anymore
even before you didn't have to either
how?
you can call stuff by their complete path instead
in doing so you can use reflection to update that path
don't see why you couldn't
so here is an example
public class Zombie extends net.minecraft.entity.1_18.Zombie { }
now you don't need an import
and reflection can change it
for Object I know but can you show me how to edit the path of this example above
There is one and I alr put the dependency but now when I try to set the primary group throw code it tells me that „LuckPerms.getApi()“ returns null
declaration: module: java.base, package: java.lang.reflect, class: Proxy
this is really complex
lol
?paste
there is always more to learn 🙂
but it does make me happy though when I can impart knowledge that blows someone's mind away
I could be understanding you totally incorrectly but I think you are going about this in the wrong way https://paste.md-5.net/biqarocoma.java I think a model like such would be a much better model for something like this. Now you can implement every version and you don't really have as much nasty reflection to deal with. I don't really think there is an issue with dealing with impl for multiple versions in this way either as you'll be dealing with that issue either way
yeah that's one way of dealing with this
Yeah Programming is Constantly-Learning-Experience
You should grab the api instance after luckperms has been properly bootstrapped
i got it in my api and the following in my main class
RegisteredServiceProvider<LuckPerms> lpprovider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (lpprovider!=null){
LuckPerms api = lpprovider.getProvider();
}
how would i add a player to a group by code now?
Tracking items is tricky lol. Is there any way I can tell if an Item has despawned?
declaration: package: org.bukkit.event.entity, class: ItemDespawnEvent
Thats the wrong class
iirc its LuckPermsApiProvider.get() or sth
Maybe im in the wrong
thanks
How can I solve this error : java.io.StreamCorruptedException: invalid stream header.
Here is my code:
public void setObject(String path, Object obj) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
oos.close();
byte[] btarray = baos.toByteArray();
String data = new String(btarray);
getConfig().set(path, data);
} catch (IOException e) {
e.printStackTrace();
}
}
public Object getObject(String path) {
try {
byte[] buf = getConfig().getString(path).getBytes();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buf));
Object obj = ois.readObject();
ois.close();
return obj;
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}```
ah okay
I was wrong
use LuckPerms api = LuckPermsProvider.get();
and make sure ur plugin enables after LuckPerms
👍
it does, currently testing how to add a player to a group and remove them again by code
sure
do you know how to by any chance? seems to be buggy for me idk
check their wiki
i did and i couldnt find how to exactly add a player to a group
just pieces i picked up and it didnbt rly work
iirc
public static void addPermission(UUID uuid, String permission) {
// Add the permission
LuckPermsProvider.get().getUserManager().loadUser(uuid);
User user = LuckPermsProvider.get().getUserManager().getUser(uuid);
user.data().add(Node.builder(permission).build());
// Now we need to save changes.
LuckPermsProvider.get().getUserManager().saveUser(user);
}
this is what i got rn but it doesnt seem to work most of the time
and to remove i just change "add" but that doesnt rly work either lol
^i put that together from pieces out of their wiki btw
i might be being stupid but is there a way to put a block on another players head
for example, the /hat command. however, it doesnt work for other players
@rough knot Can you explain a bit further?
you know in essentials, the command that means you can put blocks or whatever on your head?
uh well, thats to add a permission?
okay :)
yes
hat command
think that example is broken
do you know how it would work
var um = LuckPermsProvider.get().getUserManager();
um.modifyUser(uuid, user -> {
user.data().add(PermissionNode.builder("perm").build());
});
@wind blaze
iirc
yes
if you want to do something after it has completed u can
modifyUser(bvlah).join();
codeThanRunsAfterTheOperation();
hi conc ❤️
tand 5.4 api?
how do u test it?
i want to use it within a spawn tag plugin and so its in entitydamageby entity event and i put checks before and after the addpermission so it should get called 100%
Spawn tag?
what event is triggered if an item burns in lava for some reason my EntityDeathListener isn't triggering
tagging up at spawn, otherwise you are not damageable
yes there is
hey guys how do I give the player's held item?
wdym
please learn java
player.getInventory().getItemInMainHand();
player.getInventory().getItemInOffHand();
ty
because im pretty sure instead of being an empty Object[] its just null, and it cant cast null to an ItemStack[]
Hi, how may I bump a player like 100 blocks in the direction he is looking ?
filter creates a new stream thus can't be null
👀
get the direction they are looking and then set their velocity
you can get the direction using their Eye location iirc
thats a stringlist so remove it from the list and set it back
wdym
List<String> materials = config.getStringList("ItemHoppers");
materials.remove("Diamond");
config.set("ItemHoppers", materials);
iirc
ohh will try that thx
Tell me what it might be related to. The message with the text "Test" is sent twice, although the action in the code is recorded once and must be performed once.
why am i seeing only one | there
How would I check if an Item entity dies? EntityDeathEvent -> only works with living entities doesn't work and I don't seem to be getting anywhere with EntityDamageEvent
@EventHandler
public void onPouchDeath(EntityDamageEvent e) {
if (!(e.getEntity() instanceof Item)) {
System.out.println("not item");
return;
}
final Item item = (Item) e.getEntity();
if(!item.isDead()) {
System.out.println("item is not dead yet");
return;
}
System.out.println("Item is dead");
}
I get 2 hits of Item is not dead yet, but no death notification possibly because the final hit doesn't mean its technically "dead" yet, but Item entities have no health attribute
are you only checking for despawn?
me?
yeah
Despawn event is different
Oh, I didn't even notice that I accidentally deleted it. But the problem still wasn't solved.
I want to know when the item will die, but items don't have any health attribute so I can't be certain and it wouldn't be good if I got a double event trigger on my database
if I remove it on the first damage I am opening the possability for a dupe too
I could always do a map to check if the item has been damaged already and if it has act on it 🤔 but I'm not sure that would be the best way in this situation
у тебя и на клик и на загрузку срабатывает ивент. Вот и два сообщения.
oh shit im not on ru bukkit
👀 be careful guys optic is scarry
I found a mistake. It also reacts to the player's resource pack
Is there any way to exclude this?
so that only on the server
are you sure it's cuz of players' resuourcepack
try removing if check on ACCEPTED
Just leave SUCCESSFULLY LOADED
Rotate 3 locations on 90 graus
ye
you sure they don't have health?
Works. But I wonder why he then repeatedly performed the actions. Even if I put ||
I'm only like 50% sure when I try to do Item#getHealth or Entity#getHealth I don't get anything I'd have to double check the docs but maybe getHealth is an attribute of LivingEntity?
event was just called 2 times. One time when player clicked "Download Resourcepack" button
seems like it Item isn't a LivingEntity and LivingEntity extends Damageable
items have health, you should be able to obtain it from its metadata
and second time when resourcepack downloaded i guess
items have a health of 5
oh? okay let me check
the exception to this is nether stars
I'm only checking for Totem of Undying here so I'll be fine
is there a list of metadata keys for Item entities
i see Item#getMetadata
Age: The number of ticks the item has been "untouched". After 6000 ticks (5 minutes) the item is destroyed. If set to -32768, the Age does not increase, preventing the item from despawning automatically.
Health: The health of the item, which starts at 5. Items take damage from fire, lava, falling anvils,[Java Edition only] and explosions. The item is destroyed when its health reaches 0.
Item: The inventory item, without the Slot tag.
Tags common to all items[
]
Owner: If present, only the player with this UUID can pick up the item. Used by the give command (and can be set in a summon command) to prevent the wrong player from picking up the spawned item entity.
PickupDelay: The number of ticks the item cannot be picked up. Decreases by 1 per tick. If set to 32767, the PickupDelay does not decrease, preventing the item from being picked up.
Thrower: The UUID of the player who dropped the item. Not present if the item was not dropped by a player.
Entity Data for Items
okay what i meant is i dont think i can cast an empty stream to ItemStack[]
or even do .toArray()
you can?
you can
can i?
yes
mb thanks
just try and see 🙂
?tas
Arrays.stream(new ItemStack[0]).toArray(ItemStack[]::new) will return an ItemStack[0]
kinda stupid this but just to show
I feel like I'm stpuid here I tried Item#getMetadata("Health") and got nothing in return how would I go about getting health i don't see anything in the Entity interface I could use either tbh
I would have figured it being something obtainable from metadata
generally nbt tags are
this may sound stupid, but I wonder if I could obtain it via NMS I mean I couldn't really find anything in the api
I mean I definitly can lol
you should be able to with NMS don't see it being difficult either lol
yea Its just slightly annoying for multi versioning xD
welp if thats what I gotta settle on its what I'lld o
might make a pr for updating EntityDamageEvent
to include items
also a pr to update the item interface to have getHealth()
depends on your country
US
also, you used ItemMeta right?
oh shit no I used the entities data
let me check the item meta
though I feel like that'd be a weird place to have its health
isn't the health of the item entity exposed to the API ?
i could have sworn I saw that exposed
oh
|| paper only
||
😂
welp NMS time :)
while that might be an odd place, you can get the itemstack of an item from the item interface
should be really easy with nms yea
does ItemStack even have metadata anymore
yea I figured it was replaced
they never were Metadatable
hmm 🤔 idk why I thought they were
declaration: package: org.bukkit.inventory, class: ItemStack
they don't have a unique identifier which is what you need to be Metadatable
like, for block its just their location
entity, their uuid
etc
System.out.println(item.getItemStack().getItemMeta().getAttributeModifiers(Attribute.GENERIC_MAX_HEALTH));
You can get generic max health but doesn't look like regular health is an option
could see what it does
I mean, an item stack and the entity item are two very different hings
we know this
might as well
the attribute modifiers of the item stack have nothing to do with the item entity itself
I'm just going to make my NMS handle
Can someone please help me with adding players to luckperm groups per code?
Hi, I managed to make a giant zombie appear and get my player to climb on it, but he's in the zombie's head and can't see anything. How can I fix this?
So for example I make invisible armor stands appear on my zombie and put the player on them?
Yes
think I know why its not in API looks like I can't find anything for Item entity health in NMS either
hmmm I'm so confused maybe looking in the wrong places
you would have to pull it from its NBT data
kinda random, but can anybody recommend a tutorial for working with particles
💀 reflection
wondering how a sandal can scream
thanks got it working
can you ask questions about java here aswell?
Im trying to unregister custom enchantment via this code: https://paste.md-5.net/riyaticebo.cs
but I always get this error: ( I understand why I get it, but idk how to get rid of it) https://paste.md-5.net/xibicomera.md
ye
is there a way to declare method variables later (so that the (Player) sender can be set later in the onCommand method)
Hmn?
First of all, why are u using Method?
im trying to see if its possible because that way i can very easily add more commands and arguemtns for them if it is possible
Are u trying to make your own command framework?
not really, more to make it easily expandable
let me show you an example
ok...
Hello, how do you use an api so that when you put /join, it sends me a game of bedwars
Depend on the plugin
First of all u need to check if the plugin has an APi
and if yes, check their docs to see how to implement it
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Hi, is here someone who can explain to me problem with new NMS ? 😄 I've looked everywhere I could ... I run BuildTools with --remmaped flag... I change things in my pom.xml file... I could after hours access NMS... but after I tried to code something and added this thing:
new ClientboundAddPlayerPacket(sp)
this error shows up:
java.lang.NoClassDefFoundError: net/minecraft/world/entity/player/Player
any idea ? 😄
I'm trying to spawn npc
hbedwars
https://paste.md-5.net/ugokuqecos.java is on their built by bit page
here is full code
You have to remap it back to obfuscated
The maven plugin can do that I believe
im sorry but how do I remap it back ? 😭
Uh md5 has a thread about it somewhere on the forums I just don't remember what it's called
you mean this ?
Yeah that's the manual way, there's a maven plugin that can do it also I believe.
okay... thanks a lot... I'll try to make it work 😄
but if you'll remember how this plugin is called... send it please 😄
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
my best bet would be to do it normally wouldn't it?
this is to my question ?
Oh ty
would appreciate if anyone could help with this
https://www.spigotmc.org/threads/tnt-circle.576858/#post-4495412
Thanks
if it's the plugin that was sended here ... i already have it there 😕
I'm not sure how the plugin works tbh, I don't use Maven.
My guess is that you're not applying it correctly or something.
yeah I already thougt about that... I can't just find anything on the internet 😄 and I tried a lot 😄 ... I will just keep trying 😄
thats the plugin
I have it there 😕
for 1.19.2
and I build it through "build artifacts" to the plugin folder on server
did you read the post linked above
you need to follow the links as well
literally tells you how everything needs to be setup
I did it... when I started the project 😕 I hope I have everything
then it should remap
but just one thing... I find it interesting that it shows error on Player and not ServerPlayer from nms 😕
are you depending on the appropriate jar from buildtools?
?paste your pom
the error shows after using
new ClientboundAddPlayerPacket(sp)
if I delete this... everything goes just fine
did you depend on the appropriate jar?
in this post, if you had read the post above you would get to this post
it tells you the commands you need to run for buildtools
and then it should spit out an appropriate jar for you to depend on
I run build tools only with java -jar BuildTools.jar --remapped
then shouldn't be getting a noclassdeffound if everything is setup correctly for player o.O
well wouldn't hurt I suppose
unless you are using the wrong versions
which is the only thing I could think of
are there any plugins compatible with luckperms, which help changing player name tags like scoreboard teams do?
Okay... thank you for help a lot 😄
essentials possibly, with nicknames
ill download and try, thanks a lot
thanks
would it be bad to create a task everytime the player moves
wanting to use it for this
since it'll probably be looping alot of bounds
im guessing it'll be best to make another task (thread) for this
but idk
Its obviously the reason, you cannot open 2 things on the same port
What can cause deserialization exception when u working with serializable objects?
Hey so I'm making an instance of a class that takes a BiConsumer as part of the constructor parameters, I want to access a method inside the created class from the biconsumer, any idea of how I can do this? I know that you can't access methods in the constructor because the class isn't instantiated yet, but is there a cheaty way I can do this inside of the BiConsumer?
No
Here's what I'm trying to do:
MaterialListMenu(
"&aSelect an icon for ${region.getId()}",
onMaterialClick = { onClick, material ->
onClick.isCancelled = true
region.setIcon(material)
back(it.whoClicked) // This is the method I'm trying to access
},
previousMenu = this
).show(it.whoClicked)
You need to change your design
Alright I figured, thanks
I mean
Set it afterwards
you can have a triconsumer
where a third parameter is the instance
and then
TriConsumer:::accept(..., ..., this)
That’s really messy
yeah
possibly you group the three args to a context object
and use a simple consumer
Why not just set the consumer after it’s been instantiated?
meh, Id advocate against mutations
Or make the class call its method by itself