#help-development
1 messages · Page 1442 of 1
yes
what java ver
how do i even get that container this doesnt seems to work
CustomItemTagContainer container = new CustomItemTagContainer()
@quaint mantle
or i need to implement methods or something...
Can anyone help me with world population? Is it possible to modify an existing ChunkGenerator? Basically I want to add my stuff to a world and not mess up any other populators by other plugins.
found it i believe
I am really struggling to toggle open trapdoors/doors/fencegates in 1.12.2:
public static void toggleOpenable(Block b) {
MaterialData data = b.getState().getData();
if(!(data instanceof Openable))
return;
Openable o = (Openable) data;
o.setOpen(!o.isOpen());
b.getState().setData((MaterialData) o);
b.getState().update();
}```
Anyone see anything wrong there? (please ping)
Why
new org.bukkit.scheduler.BukkitRunnable ()
sometimes it returns NoClassDefFoundException error?
uh that makes no sense at all
"sometimes"?
what are you doing inside
the bukkitrunnable
and also show the exception
Do you use that class outside the server or what
help i want to store an users uuid in container pdc but it wont work 😢
is there any way to detect a totem being used?
I have been struggling with this problem for a long time. At some point in the plug-in operation, this class suddenly returns the NoClassDefFoundException error. When that happens, only restarting the server helps.
?help
i will list them all, maybe they will solve it, but here let me ask this
I'm a beginner ... What's wrong?
some one can send the libory for the spigot api 1.16
Ok let me explain whats very wrong here...
I will make a list
maybe fixing them potentially could solve the issue
Tuinity (Spigot fork).
just use maven or gradle
I am using the Spigot API, so here I asked ...
tuinity does have a discord server at /tuinity
no, its probably the server's fault
you are using spigot api and tunity, and they have changed some classes
you have to use the tunity api
and also, let me explain what the heck is wrong
Listen
nobody got insight on this?
-
Naming conventions. They are bad. For package names, make sure they are all lowercase. For example
me.Adixe.SuperHeroWars.Game.Magics.Magic4->me.adixe.superherowars.game.magics.magic4. And also, do not name your main plugin classMain. Read this thread I made: https://www.spigotmc.org/threads/why-you-shouldnt-name-your-main-plugin-class-main.493289/ -
Dependency Injection/Singleton. Currently, you have an instance of your plugin which is both static but you are also using DI (dependency injection) with it. Choose one only. Though dependency injection is better in terms of OOP. I am referring to this part:
private static Main plugin;
public ArrowAnimation(Main m) {
plugin = m;
}
change to
private Main plugin;
public ArrowAnimation(Main m) {
plugin = m;
}
``` (and obviously rename Main)
3) Your method is static. Learn about what static abuse and when to use `static` and when to not. In short, you only use `static` (for methods) that are utility methods. Your method here isn't a utility method.
4) Be consistent with your class imports. Instead of using `new org.bukkit.scheduler.BukkitRunnable`, import the actual class.
5) For what's inside the run method, please please PLEASE store `Config.getSettingsFile()` as its own variable. All of us programmers have bleeding eyes from seeing this multiple times.
6) There is no need for `this.cancel()` if you are already exiting out of the `BukkitRunnable`
7) You have to be consistent with your APIs and Server types. You can't use `Tunity` with the Spigot API because Tunity modifies many classes (that likely cause the NoClassDefError because it can't find certain classes that Tunity added). So either switch to Tunity API and get support at their discord, or switch to a Spigot server.
@mossy loom
🥲🥲🥲🥲
would it be possible to hide an armor stand except for one arm?
and can it be done with libdisguese api?
i wanna make a rig of armor stand parts
and combined them
That’s not possible afaik
i saw it be done with player parts in libdisguised
I am grateful for this advice! I will certainly use it.
how can i link the uuid of a player to the pdc of a container?
why is this not working?
container.set(key, new UUIDDataType(), uuid);
it doesnt find UUIDDataType
playerLocation:
location1:
==: org.bukkit.Location
world: Mineville
x: 60.80454229417847
y: 76.04952297318391
z: -6.534091548579546
pitch: 5.3418207
yaw: 89.94321
location2:
==: org.bukkit.Location
world: Mineville
x: 60.80454229417847
y: 76.04952297318391
z: -6.534091548579546
pitch: 5.3418207
yaw: 89.94321
``` How would I go on setting this up? The last thing I had only got the locations but deleted it all when the server reset so that's not the way to go
giving somone 20$ to find a small severs plugins or give me best plugins for a factions sever
factions plugin, world guard(spawn), crates plugin(p2w aspect)
$20 please
hey guys, what scope should jetbrains annotations be in my pom? i know they are provided in the newer versions of spigot but i'm using 1.8. should i shade it in?
no bruh i said plugins meaning not just 4
i gave u 3
best factions servers create their own plugins
u gotta make something to stand out
what website dp i go to to make my own
well its a learning journey of a few years at least
yeah you have to shade it in
for 1.8
ive done coding for 2 years
you dont have to add a scope
by default its set to <scope>compile</scope>
and shading uses that
thank you!
np
learn java + spigot/bukkit api
alr
i've learnt from this when i started
the key is knowing the bukkit api if you already know java
mk
is it impossible to hide armorstand body?
i thought it could be cool to hide part of it
have you check you're not making the same file over and over again if so it be blank i believe
hey
im tryna make a simple plugin which cancel the event if the block breaked isnt dirt
heres my code
can someone help me?
package me.mlgrush.axfx;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent e)
{
Material x = e.getBlock().getType();
if (x == Material.DIRT)
{
e.setCancelled(false);
return;
}
e.setCancelled(true);
}
}
I'm 100% not. I'm not even sure how I'm supposed to make the stuff that makes the yml I replied to
that's my issue ^
Firstly I would do the opposite. != Cancel. Then there shouldn't be any problem. Be sure to register the event in the main class.
What the issue actually ?
You don't know how to retrieve serialized locations from a yml ?
that's not it
gimme a sec
well yeah that's it yeah
but I can't get it to do location1, location2, etc
which
Send some code
oh woops i messed up and didnt define windows shell
So I would like to make a countdown from 5 to 1 seconds but I dont know how to add a delay.
i kinda deleted what I had hours ago
I used arraylist to create the list, I know the arraylist resets when the server restarts but didn't know it reset the config
hm its using bash on windows
public static List<String> locations = ArenaConfig.get().getStringList("playerLocation");
public static void setSpawnLocation(Location location, Player player) {
location.add(player.getLocation());
ArenaConfig.get().set("playerLocation", locations);
ArenaConfig.save();
}```
yeah I don't know what I had hours ago, deleted it and can't get it back
The config should not reset after you restart the server
Are you saving it properly?
it does because the config section is set via an arraylist
so when I add a new object after restart, all gets wiped
and starts again
That doesn't matter if you are setting the array list in the config it will not reset. As long as you get the string list add the location and then set the string list and save the config
If its resetting that means you aren't getting the list properly
Hello everyone I was wondering about a part of my plugin thats locks chests based on people their UUID, I'm trying to store the UUID of the owner of that chest inside the persistent data holder
someone who has ideas how to fix this?
What's the issue?
Can i increase the friction of a falling block?
I need it to not slide as much
Maybe detect when they are on the ground and zero there velocity?
well i want to store the UUID of the owner of the chest inside the pdc of the chest and then inside my eventHandler i can lock it for other player
What do you mean by sliding because it should become a block when it hits the ground
Ah, so for my usecase i cancel that event
so it slides around
Ah ok so whe the event is called try zeroing or lowering the velocity
thats not the issue and so on i need to store the uuid in the persistent data container
I have to figure out a way to do that
so when reloaded the server, the owner is still linked to the chest
I think the java docs of persistent data type even show an example impl of a uuid type
If i set it to (0,0,0) nothing happens, do i have to apply an inverse?
wel yea I've been looking for it half the day and didnt realy find anyrhing
chest.getPersistentDataContainer().set(ownerKey, player.getUniqueId())
chest.update()```
😮
Are you using getVelocty and then zero()?
and whats that ownerKey again?
declaration: package: org.bukkit, class: NamespacedKey
basically makes it so plugins cant interfere with each other
oh i think i implemented it before
No, I was just doing setVelocity( new Velocity(0,0,0))
You could try an inverse, you just have to experiment and see what works because velocity is weird.
Try getVelocity().zero()
how do you add a delay
Unless the sliding isn't caused by delay but idk what else it would be
BukkitRunnable
I have something like this: look for the thing you said earlier
@EventHandler
public void onContainerClick(PlayerInteractEvent event) {
ItemStack itemStack = new ItemStack(Material.CHEST);
NamespacedKey key = new NamespacedKey(plugin, "MBN");
ItemMeta itemMeta = itemStack.getItemMeta();
Player p = event.getPlayer(),
UUID uuid = event.getPlayer().getUniqueId();
Block block = event.getClickedBlock();
Location loc = block.getLocation();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if (MagmaBuildNetwork.playersWantingLock.contains(event.getPlayer().getUniqueId())) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getState() instanceof InventoryHolder && block.getState() instanceof Lockable) {
event.setCancelled(true);
//container.set(key, new UUIDDataType(), uuid);
//locks the UUID together with the PDC
MagmaBuildNetwork.playersWantingLock.put(loc, uuid);
Chest c = (Chest) block;
c.getPersistentDataContainer().set(key, p.getUniqueId())
c.update();
...
declaration: package: org.bukkit.scheduler, class: BukkitRunnable
run task later?
Yes
0,0,0 didn’t do anything, I will have to try and see
uhh that was something from before
and again, you can't store the uuid, you have to store the string
but you also have to specify the PersistentDataType
.toString()
how do I cast the state?
declaration: package: org.bukkit.block, interface: BlockState
getState() ?
hello, all! Is it bad practice to have an @EventHandler in the same class as a CommandExecutor?
Yes
Put events in there own class
Any advice for how best to pass information from the command that initiates the listener to start listening? E.g. I want to listen for a crafting event, but only from the player who ran /craft
Single responsibility principle
Delegate that to a manager class maybe
pass that player to a list and listen for that list inside the eventHandler
Probably wanna use a set in this instance
ok good that's what I'm doing, but i thought it seemed a little too complicated maybe.
i did this
public static List<UUID> frozenPlayerList = new ArrayList<UUID>();
No no no
what's up conclure?
and now I'm working at that lock problem :///
That list has no reason to be static
nor a reason to be a list
oh not me haha
doesnt matter
And a set can be used to make lookups more efficient
you're not gonna store the player twice
it works
Scalability is important tho
How make an on armour equip/ de equip event
well yea the second time i did this
public static final Set<UUID> playersWantingLock = new HashSet<>();
so i would change that first one to a hashset?
hashset implements the set interface, so you can leave it as Set unless you need HashSet's features
.
Liskov substitution principle ^
something like this?
public static final Set<UUID> playersWantingLock = new HashSet<>();
yep, that works
!!! This will do https://github.com/Arnuh/ArmorEquipEvent ?
but for some reason i can leave this <> empty
public static final Set<UUID> playersWantingLock = new HashSet<>();
is that used to be like this?
what if a plugin sets the armor
yeah you can leave the type empty
because it's inferred
ke
when the plugin is compiled, it puts the type in the definition too
Yeah idk gecko just took the first thing that came when searching for it
would i use a hashmap or hashset to store UUIDs for later look if someone is inside?
set
Is it also bad practice to have two @EventHandlers in the same Listener? For instance, I want to check if the player crafted the right item (CraftItemEvent) and only then check if the player exits the crafting interface (InventoryCloseEvent).
you don't need to store duplicates
oke
fine, usually have one class for all the events
unless you have a lot of stuff going on within
Totally fine
Again if would advocate to do this as long as you follow single responsibility principle
but i was also going to use a hashmap to store the uuid of a player and the location of chest but dont know how to export information from that
when i want to use it an eventhandler
dont need to
thanks all!
did you figure this out?
whenever someone tries to open the chest, just check whether the stored uuid matches the uuid of the clicker
oh
how would i do that the best way?
well storing that does not really work
thats the problem
I may have something that might help you , but prob not fourteenbrush
might be also useless for you
As far as organization I usually have a package with classes to manage each part of my plugin. For example I'll have a player package with a class that manages player data another class that manages player teams a class for the player data config and so on...
I always put events and commands in there own classes
I have everything in one class 
I used to do that
this is strange i never saw that my name changed to fourteenbrush xd
It's such a mess in one class
It has its uses tho
Minimalism it is
Yeah lol besides laziness it has no advantages
I tend to write a plugin all in one class, then realise I should of split it out and do it afterwards
The one thing I instinctively make a new class for is packet adapters
Other than that, it’s a main class party
🥳
When I make a plugin I always think through and make the packages and think of the classes I will need
Before I write any code
Yeah, I wish I did that
ow yea is there a way to make the plugin.yml usage output another color?
You said SOLID? What’s that never heard of it
if you understand what i mean
Idk to be honest
What do you meN
Can you put colour codes in the usage
Mean*
i know §1 works but maybe there is a way to put it a class and automatically do it
mmm
Just use &1 with translate codes
I mean, I try and avoid returning false and instead print the help command or whatever
What data structure do you guys use to store huge amount of data? But I want one that supports faster fetch and update(like add and remove), and if possible it should by thread-safe and concurrent
What type of data
return false does print the command usage right? :/
Yeah
well yea i can try this
But what I do is return true and print out one manually
Would be surprised if your data consisted of classes
Didn't understand
Anyways I usually use a ConcurrentHashMap with a loading function or a caffeine expiring cache (also thread safe) but ofc this very much depends on how you’re storing data
For instance maps aren’t suitable for permissions nodes
I'm using concurrentmap to store "<UUID, ...>" informations, but I want something like an ArrayList, with fast random access and modification, the problem is that want a thread-safe option of it.
CopyOnWriteArrayList
Thread safe stuff will always be slower
They have to use some sort of lock mechanism assuming the data structure is mutable to avoid certain issues
I saw that option, but a guy on stackoverflow said that CopyOnWriteArralist is not a good option to store a huge amount of data.
Depends on what type of data
Also everything on stack overflow isn’t probably the best source for learning data modeling etc
could use an auto-incrementing Integer key as the index in a ConcurrentHashmap
Let's suppose that my plugin will store 50k+ instances of a custom class, which data structure should I use?
PersistentDataType.
Still what type of data is this
dont know how to make that
you type PersistentDataType.
how are you going to use the data
i want to store uuids inside a container
Can you elaborate further
well this seems easy for you but not for me
he wants to have chest locks with owners
whoever places it down probably becomes owner
oh
no only the people who do /lock and they become inside a hashset or something
I would take forever to explain the whole plugin. So, supposing that the class has just 3 fields and them doesn't hold that much of informations, is ArrayList good enough to store them?
i have to stop maybe tag me with an reponse :))))
ArrayList probably not
But as I said
Depends very much on WHAT data and HOW you’re going to use it
Is it permissions? Is it homes?
Things like that matters
No, it's:
Owner owner;(a custom class that has 2 fields: a string and a UUID)
int maxValue;
List<Integer> numbers;
What do you recommend?
What is the maxValue and numbers doing
What are you doing with the data
Why do you need that
First and foremost we develop an idea then we create the model design which suits that idea
The maxValue will be a final and I will update the numbers, adding and removing them as I need
seems weird to store 50000 owners in memory
😂
lol
:]
always forget, does entity.Damageable#damage ignore armor? if so, how can i make it not?
yes it does ignore time for nms
hi
Hello
what we use depends on what it's for
arraylist is a good default implementation
usually it doesn't matter enough to give a shit about
hey guys ! someone know how to drop an item ?
player.getWorld().dropItem(player.getLocation(), new ItemStack(Objects.requireNonNull(Material.getMaterial(reward[0])), Integer.parseInt(reward[1])));
It seems not working
define not working
Well that's the correct method but we can't really help with that info
hum very strange because I saw on forums that this method don't work for some people
That code isn’t the best
Objects::requireNonNull and Integer::parseInt may throw exceptions with the given inputs
well what would you expect of the spigot forums
literally everyone who posts there is sub 70 iq
Yes but I'm sure that it's working
Working != good
player.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.getMaterial(reward[0])), Integer.parseInt(reward[1]))); because this is working
Objects.requireNonNull high iq, that'll show em!
Assume the elements in the array is always satisfying parseInt and getMaterial then it works
pretty sure itemstack has a validate check for null
If I do it it don't work too
player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.GRASS, 1));
That should work fine
Is there an error?
Also make sure that code is actually running
maybe item spawning is disabled
What is the method for Executing when right clicked a block in ur inv
you can also use dropItemNaturally
same
maybe you have a pre check
event.getclickedblock?
Sysout and make sure the code is running
the best way is to provide the whole code
i didnt mean that
PlayerInteractEvent
i meant this
we won't need it, i promise :>
yeah but can be null, interact is triggered on anything a player interacts with
even oxygen
lol'
playerbreatheevvent
ss it
public void onInteract(PlayerInteractEvent event) {
Action action = event.getAction();
Player player = event.getPlayer();
Block block = event.getClickedBlock();
if(action.equals(Action.RIGHT_CLICK_AIR)){
if(block.getType().equals(Material.STONE)){
//Exectue a cmd
}
}
}```
I think redempt has a good inventory checker waits for @wraith rapids to have a seizure
Will this work as intended
/stop
no
you literally say right_click_air
There are some null checks needed
it has to be click block
As well
no air
Right_click_block
Wtf is that texture
Yeah lol
change it to right click block to check for the right clicketh of a blocketh
intel edit
lol
Lmao
I mean like, Do u know when u click the compass (server selector) on some servers nd it opens a gui
Yeah
Like click the object not ON it
Lol check for right click block and get hand
but
?
yeah block or air
He must click the item
Yeah, so check the item in their hand is the correct item using a pdc off something
I am tryna make a gui thing
Yeah, then, open a gui
Lmao check if they right click the item and open the gui
How to check if they are holding the item
Its not hard
.
Check the item data
Name lore material literally anything
I am trying to get a list using a dependency injector, and I am having a NPE.
personally i use an &0 tag in my lores
Show code
xd
```java
code here
Where I am storing the list:
private List<String> hunter = new ArrayList<String>();
private List<String> speedrunner = new ArrayList<String>();
private boolean hasGameStarted = false;
public List<String> getTeam(Team team){
if(team.equals(Team.HUNTER)){
return hunter;
}
if(team.equals(Team.SPEEDRUNNER)){
return speedrunner;
}
return null;
}
public boolean getGameStatus(){
return hasGameStarted;
}
public void setGameStatus(Boolean b){
hasGameStarted = b;
}
Where I am trying to get the list
private Main main;
public ClearInv(Main main) {
this.main = main;
}
List<String> hunter;
boolean gameStatus;
private final ManHuntInventory inv = new ManHuntInventory();
private ManhuntGameManager manhuntGameManager;
public ClearInv(ManhuntGameManager manhuntGameManager){
this.manhuntGameManager = manhuntGameManager;
hunter = manhuntGameManager.getTeam(Team.HUNTER);
gameStatus = manhuntGameManager.getGameStatus();
}
Make is static as well for the lols
You won’t piss off anyone
if(action.equals(Action.RIGHT_CLICK_BLOCK)){ if (player.getItemInHand().equals(Material.SKULL_ITEM)){}
^^
oh sry
and the item in main hand will never be equal to a Material
the item in the main hand is an ItemStack
which will never be equal or == to a Material
get the type of the itemstack and compare it instead
it worked but ok xd
How lmao
what
literally not possible lmao
he is the master of code
in fact you should be getting a compiler warning about it
hm i didnt
dont diss paint ide
nah notepad is best
you dont understand he made his own Material enum with itemstacks
That’s not a thing, but ms paint ide actually is:
its the best ide
loool
I can see it
Does anyone know how to disable animation of the double chest?
Packets
or something to do with Lidded
I can get the animations out of the chest
I just have a problem doing this with the double chest
Does anyone know the proper way to run another task from a task that is being executed? For example, if the user runs ./gradlew build, I want it to also run the shadowJar task
Or, cancel the event and show the inv of the chest to the player
at monitor priority of course
Does rubba still work on that?
No clue mate
I don’t think I’ve seen an update i a while
I mean you can use build.finalizedBy shadowJar or smtng
Or shadowJar.dependsOn build
tell the bukkit scheduler to run shadowjar
Yeah, not since October
o ic
rip
Bro... 😂
The fuck is this...
Lmao
Bruh😐
Actually that's pretty cool
So you make the pictures of code in paint
Ocr? I don't that that term
And then it compiles
quite a bit of technology and software acually goes into making that happen
Yeah I've tried using an ocr before they take alot of work to be accurate
Yeah I can imagine
who had the nerves to do it?
i'm so stupid if guys create ides just for the memes
Good
Image if the guy tries to do something seriously
😅
nvm
https://paste.md-5.net/sezojowise.cpp
hey i have this scoreboard system (its pretty crap)
this method is ran in a runnable every second
how do i make it not flicker and be able to have teams
i've had this system for like 3 months
i kinda wanna change it
consider using a plugin
nah i need it to show important stuff in my minigame plugin
and also im here to ask for help with my plugin
not to be told to use another plugin
sometimes the best move is not to play
i need it to show stats in my minigame
consider finding a library
oh thats what u mean
no not really what I meant at first but using a library is the "i'm making a plugin" version of "consider using a plugin"
basically there is little need to reinvent the wheel and someone probably has already put the effort in
that said i'm not sure if any good scoreboard libraries exist
doesn't hurt to look though
Yeah you could use a plugin which might provide an api which you would use then
featherboard api?
can i get the material type of the result when a specific block is broken?
eg
Grass -> Dirt
Stone -> Cobble
Dead Bush -> Stick
getDrops()
how does that work now? i remember there being butthurt about it being changed recently
Hmm
something about the default overload and fortune
it didn't worked
i feel like that could work
at all
What if i say that if the first drop in the getDrops() is not equal to the type of the block?
then i would know something different is the result
you can use BlockDropItemEvent maybe?
If you want it item/player specific https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Block.html#getDrops(org.bukkit.inventory.ItemStack,org.bukkit.entity.Entity)
do you guys know of any way to extract all the strings of a class?
it really depends on the use case
are you talking about strings for translation or just String fields?
like, if you want to modify the drops of a broken block, use BlockDropItemEvent
if you want to get the theoretical drops before it's broken, you can use getDrops
any string a class has
or compile time string literals
as fields, as variable, or even passed as a parameter
then no, not without a crazy amount of reflection
damn
why
i just had a cool idea
it doesn;t sound cool so far
are you afraid that i'll create viruses or something?
How is this always true?
No, just some abomination that will become sentient and start WW3
are you sure it's not saying always false
the collection is annotated as not null
i think it can never be null
or rather the method is
i thought that not every block drops though
it may still be empty, but you will always get some sort of a collection
ahh
ok
huh
if(exploded.getDrops().isEmpty()) continue;
Collection<ItemStack> drops = exploded.getDrops();
if(Iterables.get(drops,0).getType() != exploded.getType()){
if(!Iterables.get(drops,0).getType().isBlock()) continue;
}
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
i thought the top line would weed that out
why are you getting it again after the isEmpty check
point
actually i know
cause i was doing null
so i didn't want to get until i knew it wan't null
But still
Collection<ItemStack> drops = exploded.getDrops();
if(drops == null || drops.isEmpty()) continue;
if(Iterables.get(drops,0).getType() != exploded.getType()){
if(!Iterables.get(drops,0).getType().isBlock()) continue;
}
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
idk why it's doing that though
try it this way
maybe it returns a different collection the second time or some arcane shit
it didn't error
there is an iterable? :O
yuhuh
oh, it's from google
yeah
i thought i didn't knew my jre
Is there a way to make falling blocks not slide all over the place
you'd have to control their velocity manually
they never got any friction code associated with them since they normally turn into regular blocks when they touch the floor
Can i add friction 😈
it also might be semi-clientside where the block will keep sliding even though it's not moving on the server side
the client will try to simulate everything and will just yield to whatever the server says actually happened
that's happening because they're entirely clientside
I tried to zero their velocity on the block change but i think i need to send a packet?
the server isn't applying the regular air resistance and friction to them
since they're entirely clientside you'll need to manage them manually with packets
why are you torturing yourself with this
can you guys give some hint to me? I want to do this
Has this player already got a shulker inventory? If so: open that inventory by looking through a map for it If not: create a new shulker and add it to a map with the player uuid as a key
I have the shulker check I did it
my SHOULDERS
Sheeeed
Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type short exists in class PacketPlayOutEntityVelocity.
check the source
net.minecraft.server.PacketPlayOutEntityVelocity
For Bungeecord, is there a way to detect when there are No default or fallback servers to send a player to? And then connect them to a different sever before they get kicked with that message
Nope, not that
huh
sorry not for you
oh
lemme read ur q
sorry
oh nice lol they can be a pain sometimes
yuhuh
Im trying to make a EntityVelocity Packet, but idk what i am writing wrong
final PacketContainer veloctiyPacket = new PacketContainer(Server.ENTITY_VELOCITY);
veloctiyPacket.getIntegers().write(0,id);
veloctiyPacket.getDoubles()
.write(0,(double) 0.0)
.write(1,(double) 0.0)
.write(2,(double) 0.0);
Yeah
cant get em to SIT
Huh, it didn't error if i used integers
but it didn't do nuttin
@EventHandler
public void onBlockChange(final EntityChangeBlockEvent event) {
final int id = event.getEntity().getEntityId();
if (this.blockIDs.remove(id)) {
cancelVelocity(id);
event.setCancelled(true);
}
}
public void cancelVelocity(int id) {
final PacketContainer veloctiyPacket = new PacketContainer(Server.ENTITY_VELOCITY);
veloctiyPacket.getIntegers().write(0,id);
veloctiyPacket.getIntegers()
.write(0,0)
.write(1,0)
.write(2,0);
Bukkit.getOnlinePlayers().forEach(player -> {
try {
RealPhysics.this.protocolManager.sendServerPacket(player, veloctiyPacket);
} catch (final InvocationTargetException e) {
e.printStackTrace();
}
});
}
It must just be because they are technically gone or something
idk
wait
but im overwriting the id
when I first tried using fallingblocks I peeked into the original block physics plugin's code
it was from 1.8, they imported an entire physics engine and applied that to falling blocks
to prevent them from disappearing, they just cancelled the event (I believe?)
that no longer works in 16.5 and I couldnt find a better solution to keeping them alive, and at the same time keeping their velocity
but packets might work
they are clientside so the event should never fire
yeah, i am cancelling the destroy packets
oh so you went back to the cancelling destroy packets approach
Yeah
it works
Just i need to stop the sliding
Hmm i really dk what the problem is here
dunno
i mean with that code above i am overwriting the id with the x
but the strange thing is that the wiki says they are doubles but it only accepts ints
guys, where do I find the logic responsible for thrown midair enderpearl collision detection?
they're probably ints in 1/8000 of a block
yeah the actual packet class uses ints
public void b(PacketDataSerializer var0) throws IOException {
var0.d(this.a);
var0.writeShort(this.b);
var0.writeShort(this.c);
var0.writeShort(this.d);
}
but it's sent as shorts over the protocol
which is what wiki.vg/protocol documents
did you try it without overwriting the id with the x
what, do 1,2,3 for the velo
yeah
yeah i did
id is 0
although
nothing happens?
no
What does 0 velocity actually mean
@EventHandler
public void move(PlayerMoveEvent event){
event.getPlayer().getVelocity().zero();
}
as a test i wrote this ^^^^ and it doesn't do anything
player velocity is entirely clientside
all player movement is entirely clientside
setting the player's velocity doesn't do anything
and you'd have to use player.setVelocity after modifying it anyway
get's generally clone the underlying value
Stary by not using that
the maven repo for the jar file im using doesnt work
and hasn't worked for like 3 years
^^
i don't remember how but that's a thing you can do
@EventHandler
public void move(PlayerMoveEvent event){
Vector velo = event.getPlayer().getVelocity();
velo.zero();
event.getPlayer().setVelocity(velo);
}
Ok yeah this works
Ok, so my packet doesn't work
as a test i set the y to 1
and i am running it like this:
@EventHandler
public void crouch(PlayerToggleSneakEvent event){
Player player = event.getPlayer();
Entity e = player.getWorld().spawnEntity(player.getLocation(), EntityType.BEE);
cancelVelocity(e.getEntityId());
}
This is good news though, because it could work
mvn install:install-file -Dfile=L:/Downloads/ScoreboardLib.jar -DgroupId=me.tigerhix.lib -DartifactId=scoreboard -Dversion=1.0.1-SNAPSHOT -Dpackaging=jar```
why isnt it working lmao
it says build success
but when i compile it
the thing still says the import doesnt exist
did you add it to your pom
you can
that's the point of using the command you pasted
to install it to your local maven repo
so you can add it to your pom
and pull it from your local maven repo
-DgroupId=me.tigerhix.lib
-DartifactId=scoreboard
-Dversion=1.0.1-SNAPSHOT
ah
this is the dependency information
i understand now
the repository information is not required
as you just installed it to your local repo
which is used by default
Absolutely not sorry
Why cant i use instanceof pattern matching in Intellij?
It says that "patterns in instanceof are not supported at language level 16"
the java version you're building for doesn't support it i guess
it was added in java 14 or something iirc, not sure why it would complain about it
I'm using AdoptOpenJDK 16
I seem to have got it to work somewhat @wraith rapids
There must be an error in my code
or just that the packets are unreliable, idk
Most freeze but you get a few that don't
could be some weird interpolation happening on the client
Yeah, idk
i suppose it's also possible that the server sends a velocity packet for the block just before it's destroyed by the event being cancelled
which would override the packet you send
try sending your velocity packets a tick or two later
also, über protip
instead of despawning them, make them fall into the ground
umm, is that possible
teleport them downwards by .1 blocks and they will no longer collide with the top side of the block they're on
and they just fall through
can just send a relative teleport or movement packet for each of them
i could do that and then remove them
yeah
delaying them like this:
new BukkitRunnable() {
@Override
public void run() {
cancelVelocity(id);
}
}.runTaskLater(this,2L);
``` dont help ><
try spamming the packet a shit ton and see if that helps
send it once every tick for each entity for like 20 ticks
lmao
I am trying to get a list using a dependency injector, and I am having a NPE.
Where I am storing the list:
private List<String> hunter = new ArrayList<String>();
private List<String> speedrunner = new ArrayList<String>();
private boolean hasGameStarted = false;
public List<String> getTeam(Team team){
if(team.equals(Team.HUNTER)){
return hunter;
}
if(team.equals(Team.SPEEDRUNNER)){
return speedrunner;
}
return null;
}
public boolean getGameStatus(){
return hasGameStarted;
}
public void setGameStatus(Boolean b){
hasGameStarted = b;
}
Where I am trying to get the list
private Main main;
public ClearInv(Main main) {
this.main = main;
}
List<String> hunter;
boolean gameStatus;
private final ManHuntInventory inv = new ManHuntInventory();
private ManhuntGameManager manhuntGameManager;
public ClearInv(ManhuntGameManager manhuntGameManager){
this.manhuntGameManager = manhuntGameManager;
hunter = manhuntGameManager.getTeam(Team.HUNTER);
gameStatus = manhuntGameManager.getGameStatus();
}
post actual code and post the actual error
is there an easy way to delay code without the whole 5 line runnable thing
yes with the 2 line bukkit runtasklater thing
bukkit.getscheduler().runtasklater(plugin, () -> {// code here}, delay);
oh i always forget about lambda
i find the arrows kinda goofy
for(int i = 0; i < 20; i++){
Bukkit.getScheduler().runTaskLater(this, () -> {
cancelVelocity(id);
}, 1L);
}
Ok, so this doesn't do anything
Idk what will
that just schedules 20 tasks to happen on the same tick
use i instead of 1L
make the velocity shoot them up instead of stop them
maybe some of the blocks get dropped out of the eid set or something
its that
some just don't move
but i don't know why or how
like
public void create() {
final FallingBlock fallingBlock = this.location.getWorld().spawnFallingBlock(this.location, this.blockData);
this.id = fallingBlock.getEntityId();
fallingBlock.setHurtEntities(false);
fallingBlock.setDropItem(false);
fallingBlock.setVelocity(this.vector);
packetInterceptor.setBlockedOnce(fallingBlock.getEntityId());
blockIDs.add(this.id);
}
This is the method i use to make them
But if i change it so that no matter what, if the EntityChangeBlockEvent gets called they get their velocity packet they still don't work
yeah it kind of just looks like some of them aren't receiving any velocity packets at all
dunno
when do you need to add api version to your plugin.yml
wdym by when
when you use materials that were added after 1.12
oh ok
ideally always
okay
Hmmm
as not specifying an api version has your entire plugin going through the batshit crazy compat layer
Im pretty stumped tbh with this. It seems like some entities just kinda don't exist at all even to the client
Or like their EID shifts or sommin
they clearly do though as they do respond to the destroy packets you resend
just not the velocity packets
try sending some other kinds of packets for them
maybe the teleport down by .1 block packet
see if the stragglers ignore that too
proobably
use the relative teleport packet
or movement packet
idr which it's called
there's one that lets you "move this by this many blocks to this direction from its current position"
so you can just tell it to go .1 blocks down rather than calculating the absolute location of where that'd be
sounds like it
i remember there is some sort of a limit to how far it can go, like 8 blocks or something
myeah
👌🏿
Does anyone know how to check an area for a certain block type and summon a mob at every one of their positions?I don’t even know where to start with it.
for (int x = -radius; x <= radius; x++) {
if (world.getBlockAt(x, y, z).getType() == yourMaterial) {
doThing
Am I able to do this with the worldguard API using regions? If so, how? And how would I spawn mobs at every block of that type in that area? Say for example I wanted to summon slimes to all the slime blocks
worldguard/edit api, good luck
horribly overcomplicated api, very unfriendly developers
they laugh at every question
they do have their own discord though
Which is better for adding players to a list (if in list has particle trail) HashMap or Arraylist?
- don't store the player object, store the uuid
- are you storing extra information for each player? (like the type of trail)
- ok
- no, cause theres only the 1 type, so it would only be the username/UUID
you're storing the trail that the player has selected, no?
there's only one type
so then use a set
hashset
Set<UUID> enabledTrails = new HashSet<>();
Oh word, never though to use HashSet
list is for when you can have duplicate objects
you won't be storing uuids twice, so there's no need
and Set has better performance in some aspects than List
and set is unordered
Apparently it isn’t possible with WorldGuard, which brings me back here. Are you able to provide me an example of how to spawn a slime at every slime block in that area?
get the min and max bounds of the region
iterate over all of the blocks contained between those points
spawn a slime for each slime block
or whatever
How can I make a command that changes a specific string in a players data.yml I already got the data part working but for some reason I cant seem to get the string changing part right?
You should never directly edit a player dat file
hmm ok then how would I go about making that then without doing it directly?
Seeing as all you've said is editing a string, no one can tell you
What more can I say the whole plugin works when a player joins a a default string is saved in a data.yml with there uuid then when a command is ran that string is suppose to change to something else
You are giving us literally nothing to work with
What do you want me to give u the code I have so far?
A String, a UUID, something is supposed to change
No, just tell us exacly what you are trying to achieve
my thing isnt working. the goal is when i hit something it replaces the current attribute with a differnt attribute. eg i have 20 attack damage the ability replaces the 20 with 21 or x, instead whats its doing it adds a new one it shows on the sword +20 attack damage and + 21 attack damage and idk why
So nothign to do with the player dat file then
Its suppose to change that default string that's set in the data.yml to a new string that is then displayed when they run a command
nope
i am currently using method remove attribute modifier and then do add attribute modifier method
Currently your code checks the config entry exists. If it does it changes that entry to "FireElement"
Yes bit it returns null when I run the command
that data manager is def null
So your real problem is you have an NPE error...
It helps a lot if you tell us all the info
?paste the FULL error
i wanna make a bet its the if statement
yep, betting data is null
if (this.data.getConfig().contains("players." + player.getUniqueId().toString() + ".element"))
correct
you never set a value to data
also what the fuck is that perm msg
wym data is just extending the datamanger thats already created in another class?
thats not how that works
data is never set. its just a definition
this is literally basic java
I am trying to get a list using a dependency injector, and I am having a NPE (Null Pointer Exception) .
Where I am storing the list:
https://paste.md-5.net/uketaqigag.cs
Where I am trying to get the list
https://paste.md-5.net/recuricika.java
Stacktrace
Could not pass event PlayerJoinEvent to ManhuntAbilites v0.9
java.lang.NullPointerException: null
at me.PACKAGENAME.manhunt.PlayerChecks.HunterChecks.ClearInv.PlayerJoin(ClearInv.java:44) ~[?:?]
line 44 is where I attempt to check if a name is in the speedrunner list.
ah
what do you pass into the ClearInv constructor?
public ClearInv(ManhuntGameManager manhuntGameManager) {
this.manhuntGameManager = manhuntGameManager;
this.speedrunner = manhuntGameManager.getTeam(Team.SPEEDRUNNER);
}
Sorry what do you mean? Do you mean in my gamemanager class where i do
ClearInv clearInv = new ClearInv(this);
you dont actually show line 44, do you?
oops sorry forgot to include
public List<String> getTeam(Team team){
if(team.equals(Team.HUNTER)){
return hunter;
}
if(team.equals(Team.SPEEDRUNNER)){
return speedrunner;
}
return null;
}``` you can use `==` for enums
will do
Here is an updated stacktrace: https://paste.md-5.net/luloyuyupo.sql
Line 39 is
if (speedrunner.contains(event.getPlayer().getName())) {
seems like you're returning null in this method
oh that's 39?
Yes sorry, I had to update the stacktrace
Line 39 is where it attempts to check if a speedrunner is in the list.
see if returning a new ArrayList in the getTeam method works
which is odd because it should be returning the list
try making hunter and speedrunner final, see if they're ever set to null afterwards
Ill try final first
yes it does
you set em to null at some point?
The list? No, I do not touch them until I have to add them to the list with a command
well you said it brought up errors
maybe getTeam returns null
Ill try returning a list that has something in it
Alright, so in my getTeam method, I cannot attempt to add anything to my test list, and if I try to get that testlist from my ClearInv class, it gives a NPE
add somethings to the team
ok
Adding anything to the list also causes a NPE
so it's null
Ok, so before I return the team, should I add something to the list?
new ArrayList();
at some point youre doing hunter = null
or whateverElse = null
which is why i suggested setting the lists to final
- more clarity and 2. helps you find where you set them to null
ok got it
This worked, it is now not throwing a null-pointer. I am going to do some more tests to make sure it works.
yes
this is the basic java problem
you should read gecko's answer/explanation again
Ok