#help-archived
1 messages · Page 91 of 1
just color trans
show
public static String format(String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}```
and the null pointer occurs on that line?
Again, you'll get the error if the message argument is null
Yes - it's clear from the stacktrace ...
but its looking for the display that is specify &9&l» &5&lServer Selector &9&l«
Perhaps you got your lines mixed up between the source and the stacktrace?
No i didnt.
mhm
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
char[] b = textToTranslate.toCharArray(); // line 206 -> your input string is null
for (int i = 0; i < b.length - 1; i++) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) {
b[i] = ChatColor.COLOR_CHAR;
b[i+1] = Character.toLowerCase(b[i+1]);
}
}
return new String(b);
}
Different version on server than in IDE?
No, so the error was getServerGui in ServerInventory because in the config it suppose to have the size of the inventory and the name but i deleted it on accident
wait
arent you getting the inventory stuff from config every time that method gets called
mhm
yes?
um thats pretty bad thing to do
You'd be better off creating the instance once and storing it. And when you need it, just use its getGUI method or whatever you need
public final class Main extends JavaPlugin {
private final List<String> inventoryTitles = new ArrayList<>();
private final List<Integer> inventorySizes = new ArrayList<>();
private final List<ItemStack> inventoryContents = new ArrayList<>();
private final List<InventoryHolder> inventoryHolders = new ArrayList<>();
@Override
public void onEnable() {
}
private void loadInventories() {
}
}
just do it this way and then u can save all inventories u create to a list
i only create one inventory lol
better than getting it from a file each time
All the more reason to do it once...
hmm
Map<String, Object> would be better
instead of using the index
u can use the inventory title to get the value
or just
Map<InventoryHolder, Object>
if(holder instanceof Menu) {
int size = map.get(holder);
}
etc
menu would be for example
interface Menu extends InventoryHolder {
//...
}
yes i do.
i mean just not get it every time
for my queues i get them from the queue and thats pretty much it then save it
So @brisk mango, you're suggesting custom implementation os InventoryHolder?
That's a misuse of the API:
https://www.spigotmc.org/threads/using-to-compare-inventories.374324/#post-3411177
@wraith thicket I believe that an instanceof check is more efficient than a string comparison
InventoryHolders are fine
no
lol
"random bukkit interfaces" I thought you are the one that maintains the API
InventoryHolder= random bukkit interface
don't implement it in your plugin
you're not supposed to
is there any good reason to not use it though?
any more than you would implement Cake and expect setBlockData(MyCake) to work
wait so you're saying that its better to compare inventory titles in InventoryClickEvent?
since there is then no other way to check the inventory
Exactly - just keep track of the inventories and check the instances.
because u would use ==
@EventHandler
void onClick(InventoryClickEvent event) {
if(event.getInventory() == inventories.get("inventory")) {
//...
}
}
ignore what i just said lol
im just dumb sometimes
Anyone here familiar with NMS NPCs?
Having trouble getting an NPC to jump and crouch, I got it to spawn, rotate and hit so far.
what are you using right now
im talking to you
you said youre having trouble
so are you getting an error for example or u just dont know what to use / how to use
not getting an error
I just dont know what to use
I have some things that I tried but with no success
public void entityVelocity(short x, short y, short z){
PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity();
setValue(packet, "a", entityID);
setValue(packet, "b", x);
setValue(packet, "c", y);
setValue(packet, "d", z);
sendPacket(packet);
}
this is what I have for jump
I dont know what setValue does
public void entityAction(int animation){
PacketPlayInEntityAction packet = new PacketPlayInEntityAction();
setValue(packet, "a", entityID);
setValue(packet, "animation", (byte)animation);
setValue(packet, "c", 0);
sendPacket(packet);
}
and this is what I have for crouch
Do you know that Vector exists
it has X-Y-Z
you dont need to use short x, short y, short z
to set the velocity
you can just do new Vector(..
I'm aware but the packet requires you to set x y z indpendatly
Sure, but that's not the issue right now
what head-rotation?
I'm not trying to rotate their head, i already got that to work
I'm trying to get them to jump and crouch
and does setting the velocity not work?
the velocity packet doesn't make it jump no
it just does nothing
my crouch code makes the client looking at it disconnect
Unserialized packet exception i think it was
Internal Exception: io.netty.handler.codec.EncoderException: java.io.IOException: Can't serialize unregistered packet
Sorry this is the right error
There wasn't any stack trace
i dont think i can help you this much with NMS since i havent myself done alot of NMS, just some basics
damn
welp if anyone who's reading this can help me please let me know (and ping me)
the client only uses the entity velocity for some stuff like the minecart sound
to make an npc jump you have to send move packets
@daring crane which packet exactly?
what does entity velocity packet to do with a sound
you need the packets like PacketPlayOutRelEntityMoveLook
@brisk mango minecarts use their velocity to determine their sound volume
@daring crane what about crouch?
makes sense
sneaking is a datawatcher field
https://wiki.vg/Entity_metadata#Entity
the Pose field
@daring crane what are the fields in the jump packet u said?
are your npcs not able to walk?
the "right" way: keep track of the client-side position on the server, use the different move packets to move it
the easy way: just use teleport packets instead (PacketPlayOutEntityTeleport)
velocity doesnt move the entity
it depends on the entity
at least not in this case because they only exist in packets
PacketPlayOutEntityVelocity
doesn't work.
the server uses the velocity to move entities every tick
but in this case the server doesnt even know the entity exists
@daring crane wouldn't teleportation make it seem like... well teleportation?
back when I use to create fake falling blocks two packets were sent to the player to update the entity velocity
falling blocks are one of the only exceptions where the client uses the entity velocity to move the entity
not true, you can move any entity with velocity as it does the same as org.bukkit.entity.Entity#setVelocity
thats because the server is performing the movement
funny because the server doesnt send the packets to everyone online
the packets are only sent to players who actually see the entity
= are in range
except that it wont in this case because setting the velocity doesnt move the entity
thats why the server performs the movement every tick
let me guess, the other one is a move packet
Entity#setVelocity didn't work
I've already tried that
it didn't make the NPC move or jump. it just did nothing.
@fluid marlin but Entity is an bukkit class, NPC is an packet
wwhich has nothing to do with Entity
You make a new EntityPlayer
and then do Player npcPlayer = EntityPlayer#getBukkitEntity()#getPlayer
I know
I tried that at first, it didn't work.
Hence why now im using what @daring crane suggested ^
EntityPlayer is an NMS class @fluid marlin
and Use EntityPlayer#getBukkitEntity#getPlayer
no not a new player
Player npcPlayer = EntityPlayer#getBukkitEntity#getPlayer;
could anyone with a busy server that uses LP please run /lp verbose record ...wait a bit then /lp verbose paste please, just trying to get a large set of data
30secs to a min is all
@pastel basin This guy just litterly told you like 3 times that setting the entity's velocity with packet wont work
@fluid marlin what are you doing with the bukkit entity api
are you not spawning the entity using packets?
because if you do you shouldnt use the bukkit entity api at all
no
yes
you still didnt say which magic packet that is
teleporting the entity besides being performance expensive it will not look smooth to the player
im making very smooth roller coasters using teleport packets
using velocities will make the entity look like it's walking
using velocity for smooth movement is wrong, it might even make it worse
if its the right way why doesnt the vanilla server do it?
its not bukkit so its not performance expensive and its not laggy @pastel basin
only shit in bukkit is performance expensive because its shit designed API
How to get Material of raw fish (bukkit 1.15.2)?
Does not exsists
PacketPlayOutEntityMetadata is 100% unrelated to movement
Is deprecated
well, you did Entity#setVelocity
which is completely unrelated to this conversation
oh right, your falling blocks
@brisk mango Do you have any idea ?
so im sending a PacketPlayOutSpawnEntityLiving for an armor stand and a PacketPlayOutEntityVelocity with (0, 1, 0)
its not moving at all
and no, PacketPlayOutEntityMetadata wont change that
congratulations, youve arrived at what i said 20 mins ago
did the same thing with a zombie now, its not moving at all
did you send the metadata packet?
i guess you have to teleport it because zombie is an exception @daring crane
lmao
@pastel basin i think youre braindamaged somehow
alright, ill send a metadata packet
look who's talking
breaking news: the metadata packet didnt change anything
i mean this is not the first time ur saying stupid shit
u did before too when i said BukkitRunnable is an useless class and u argued about it with no reason why should it be useful
fine
I just said that BukkitRunnablr looks cleaner
it doesnt really look cleaner, its about if people prefer/like more lambda than doing new BukkitRunable(), it might look cleaner but the code is more shit. Anyway, how did you change the entity's velocity with the packets if this guy cant get it to work?
but I'm pretty sure I used it before and it worked
fine
Actually, the advantage of the BukkitRunnable class is the #cancel method
the only advantage
omg please stop talking about bukkitrunnables
but you know that a Consumer<BukkitTask> exists right @wraith thicket
It's a convenience, really
You can just do task -> task.cancel();
I recently moved my website to a https domain and ever since when i try to join my proxy on the same ip i get 'Error occurred while contacting login servers ,are they down?' do these two have something to do with eachother
this subject was argued 100 times already
@fluid marlin what are you doing with the bukkit entity api
@daring crane I am spawning the entity using packets.
then you should never even have an Entity instance
i dont
I used to
@daring crane can you remind me what's the packet for crouching?
PacketPlayOutEntityMetadata
What are the fields in that packet @daring crane
entityId, dataWatcher, true
you have to create a DataWatcher and set its Pose item
btw the DataWatcher needs an Entity in its constructor, its not used for anything important though
so you can just pass a fake object
can I pass a null?
.set(net.minecraft.server.v1_15_R1.Entity.POSE, net.minecraft.server.v1_15_R1.EntityPose.CROUCHING)
i'm trying to make the NPC work on all versions but i gotta start from lowest lol
should i cast the second one to (bye)
yep
👍
public void entityMetadata(){
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
setValue(packet, "a", entityID);
Entity fakeObject = null;
DataWatcher dataWatcher = new DataWatcher(fakeObject);
dataWatcher.a(0, (byte) 0x02);
setValue(packet, "b", dataWatcher);
setValue(packet, "c", true);
sendPacket(packet);
}
@daring crane this is what i got, aint working.
fakeObject cant be null
Setting a DataWatcher to null works for me in my spawn fucntion btw
What does it need to be?
actually i think it can be null in 1.8
@fluid marlin You realise that some classes dont have to be visible if they are package-private?
not talking specifically about NMS but in general
and alot of shit needs to be accessed using reflection
why don't you use the constructor instead of setting values? 🤔
packetplayoutentitymetadata has a constructor for entity id
@fluid marlin seems like you have to use watch
and if you use watch the entity really cant be null
but you are setting the value after you instantiated this class
The first value im setting is the entity id
@daring crane what should I put it as then?
Should i get the EntityPlayer and have the entity be the entityplayer?
just create an nms Entity using its constructor
that sounds so wrong tbh but you kinda have to
new Entity(null) should be enough
nvm Entity is abstract
maybe new EntityEgg(null)
the EntityEgg constructor is a world
the world can be null
should I set it as null or just give it a world
okok
[NPC] Task #607 for NPC v1.0 generated an exception
java.lang.NullPointerException
at net.minecraft.server.v1_8_R3.DataWatcher.watch(DataWatcher.java:110) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at me.moshe.npc.ver1_8.NPCManager.entityMetadata(NPCManager.java:77) ~[?:?]
at me.moshe.npc.commands.NPCCommand$1$2.run(NPCCommand.java:46) ~[?:?]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
@daring crane ^^
is the entity still null
the error is on the DataWatcher#watch
nope its an entityegg
and i set the world to null
and youre really passing that entity in the datawatcher constructor?
the entity is the only thing that could possibly cause that exception
public void entityMetadata(){
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata();
setValue(packet, "a", entityID);
EntityEgg fakeEntity = new EntityEgg(null);
DataWatcher dataWatcher = new DataWatcher(fakeEntity);
dataWatcher.watch(0, (byte) 0x02);
setValue(packet, "b", dataWatcher);
setValue(packet, "c", true);
sendPacket(packet);
}
hmm seems like .a(...) was right
I thought so, so i tried switching it back to a
which just didn't do anything
without any errors or anything
I'll try lol
wish there were good tutorials on this shit
I understand things much better when there's a voice or a person explaining it to me but that's just me personally
i learned using datawatchers by looking at other open source plugins
but i have no clue how they worked in 1.8
a() then watch() isn't working
just doing nothinhg
doesn't generate any exceptions either
try using new PacketPlayOutEntityMetadata(entityID, dataWatcher, true)
instead of setValue
seems like its doing important stuff in the constructor
field "c" doesnt even exist, its only a constructor parameter
should i use a or watch?
a
set 0 to (byte) 0x00
👍
but you have to use .watch for that
you only need .a once to register the item, then you should use .watch
thats why watch wasnt working earlier btw, the item wasnt registered
👍
tysm @daring crane
np
oh right, because youre not reusing the datawatcher
would be cleaner (and probably better for performance) to just make one datawatcher for the entity and modify it
👍
I'll probably come back for more help once I start making this for other versions if minecraft changed a lot of how it works in different versions
lets hope so :v
and since some version you have to set the pose (DATA_POSE) instead of the flags (0)
@daring crane Would I have to create an NPC class for each version or is there an easier way
imo the best way is to make one class for every mc version
and make them implement an interface
On the chat is says []CoBra5332 how do I take the [] away?
I've got a question :
I am coding a programme which checks .minecraft files to check if someone is cheating. My question is : is it possible to detect an injected client such as vape with tasklist ?
Try it out and see is what I'd suggest.
Bare in mind that people can play this game on MacOS or varius linux distros as well, so a Windows-only application will not really be a good "anticheat" solution.
Not to mention that even if you do find the client that way, modifying it in a way that you cannot would not be all that difficult.
client sided anticheat are not a really great idea
theres always bypasses to them...
if (event.getItem().getItemMeta().hasDisplayName() && event.getItem().getItemMeta().getDisplayName() != null) {
``` reason for null apointer?
item can be null
so add check to see if item isnt null ok
what event is that?
@daring crane I'm now using it for later versions and a() is removed and there is a register() instead like you said but what's a DataWatcherObject?
checking if an item is null worked thanks.
@fluid marlin they changed the keys from numbers to those objects
pretty sure you need Entity.T instead of 0 there
Whats Entity.T
oh rip its not called T in all versions
instead of 0 you need the datawatcher key now
for example in 1.13.2 its Entity.aC (its protected so you need reflection)
just look at Entity.setFlag(int, boolean) with a decompiler, it should say datawatcher.set(...) somewhere
the first parameter is what you need
Hi I am getting a weird bug where commands are not being displayed in the command preview area and I can't figure out how to fix that.
If anyone knows it would be appreciated.
Plugin list:
Plugins (56): AdvancedPortals, AuctionHouse, BuycraftX, ChatControl, ChestShop, Citizens, ClearLag, Coins, CommandNPC*, CosmicVaults, DeluxeMenus, DeluxeSellwands, DeluxeTags*, EpicFurnaces, EpicRename, EpicSpawners, Essentials, EssentialsSpawn, FastAsyncWorldEdit, FeatherBoard*, FogusCore, GoldenCrates, GUIShop, HolographicDisplays, HolographicExtension, IridiumSkyblock, Item2Chat, LuckPerms, LuckPermsMVdWHook*, mcMMO, MoneyNote*, MovingDevApi, Multiverse-Core, MVdWPlaceholderAPI*, PlaceholderAPI, PlugMan, ProtocolLib, ProtocolSupport, RewardPRO, ServerlistMOTD*, StaffChatReloaded, SuperMobCoins, SuperVanish, TAB, UltimateModeration, UltimateStacker, UltimateTimber, UltimateTroll, Vault, VoidGenerator, VoidTeleport, VoteParty, Votifier, VotingPlugin, WorldEdit, WorldGuard
what is an preview area
also how do you expect us to tell why its not displaying by showing us all the plugins
you should know lol
this what I mean by preview area: https://imgur.com/vcvbVcl
Perhaps you've set it to not tab complete in your spigot.yml ? https://www.spigotmc.org/wiki/spigot-configuration/
let me check
hey how do i give /tpa perms to other player? (plugin : Simple Tpa 3.7)
wat
@frigid ember It's literally written on the resource page... look for the Permissions bit: https://www.spigotmc.org/resources/simple-tpa.64270/
Hello guys,
idk if this is okay but I need some advice for a modpack server.
So I want to host a modpack server for about 15-20 people. The modpack is about 150 mods big. Over the past years I hosted many servers but almost every time the server got lags (12-18 TPS). Now is the question: what is the best way to host a modpack server? Should I use something like SpongeForge or use waterfall? Which hoster is the best/cheapest? Root server or just a minecraft server?
I hope you guys can help me with this because I just don't know how to go on with this
Also what would be the best 'performance' modpack for example
Anyone know why line 31 isn’t working correctly (with the color) https://repo.voidcitymc.com/ramdon-person/ChatMentioning/src/branch/master/src/com/voidcitymc/plugins/Chat/Chat.java
what is the exception?
i want to spawn an npc but i need to have the minecraftserver.
i the tutorial he has done this:
MinecraftServer ms = (MinecraftServer) Bukkit.getServer();
This isn't working for me because it says it cant convert.
Does somone has an idea?
Bukkit#getServer returns a CraftServer instance. You'll need to use CraftServer#getServer to get the (NMS) DedicateServer instance (which extends MinecraftServer): https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/CraftServer.java#1024
@wraith thicket so like this ? MinecraftServer ms = DedicatedServer.getServer();
No.
oh
You do Bukkit#getServer , cast to CraftServer, then do CraftServer#getServer
@hollow thorn no this isnt implemented anymore
@wraith thicket okay i will try thanks
if i were to make a crafting recipe
for obby
where you combine a water bucket and a lava bucket
how would i make it so it leaves the buckets
I don't know, but you can get the vanilla recpie for a Honey Block (e.g) and see what it's like.
@wraith thicket yes it works, thanks. but know i got the error at casting this:
WorldServer ws = (WorldServer) p.getWorld();
...
Cast world to CraftWorld then use CraftWorld#getHandle
I assume p is a Player object?
yes
Then yes, like Epicnity said, first cast its result to CraftWorld, then #getHandle
well it happens
anyone know when boundingbox was added?
Somewhere between 1.13 and and 1.13.2
Also, I use this for stuff like that:
https://www.spigotmc.org/wiki/spigot-nms-and-minecraft-versions/
Hello, can a member of staff please PM me on discord?
hi
i have problem with my chat plugin, so when im typing something on chat i have "[]" behind my nickname. I cannot remove it and I changed all essentials chat config. How can i remove this?
multiverse prefix most likely
is it a dumb ideea to have a object named instance?
Hello I need explanations on this
public void onEnable() {
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
// Do something
}
}, 0L, 20L);
}```
So
- the scheduler starts
- He do line by line the run()
- he waits 20 ticks doing nothing ???
- he redo run() line by line ?
etc etc ?
You can think of it like that
okay
Hello, I need help and want to loop entities with a certain UUID but that doesn't work because the chunk is not loaded in this area or there are no players nearby. Is there any solution?
What are you actually trying to achieve?
I use vehicles with ArmorStands and with a car key you should have your position and distance. But that's not possible if the chunk is not loaded there
The distance between you (the holder of the key) and the car?
yes
Why would it matter if the car is in an unloaded chunk?
The distance is simply "too big", isn't it?
I.e you could set the maximum value for the distance if the chunk is not loaded
yes the distance is 2000 meters long..
But how can I do it anyway?
How do I set the maximum
You mean how to set a maximum value for your distance? If you're using double, then https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#MAX_VALUE
Now don't really understand how to put it, can you give me an example?
What? double val = Double.MAX_VALUE; ?
How does that work with the entity and the player distance?
Really not sure what you're trying to ask
double dist2; // distance squared
if (!chunkLoaded) dist2 = Double.MAX_VALUE;
else dist2 = locEntity.distanceSquared(locPlayer); // would encourage using #distanceSquared to avoid the costly square rooting
Entity car = Bukkit.getServer().getEntity(uuid);
player.sendMessage(""+car);
player.sendMessage(""+car.getLocation());
player.sendMessage(""+player.getLocation().distance(car.getLocation());
``` That's how I do it, but if the player is not close to that, I get the message "zero"
You mean "null", right?
yes
Okay, but how do I load that now?
double dist2;
dist2 = Double.MAX_VALUE; }``` Do you mean so?
Yes, but how do I get the distance now when the car is far away?
You've just defined the distance as its maximum value
And then I can loop the entity again or how?
Yo, still with my:
public void onEnable() {
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
// Do something
}
}, 0L, 20L);
}```
How can I cancel the runnabe ? I don't find method for ;-;
scheduler#cancelTask(id)
you can use that id to cancel tasks
but in my case it has to be inside the runnable.
use a Consumer<BukkitTask>
Bukkit.getScheduler().runTaskLater(task -> {
task.cancel();
}, 20L);
and dont use scheduleBlaBla
runTaskTimer/Later exists for a reason
So in your code "20L" is the period ?
it doesnt matter what is my period, it was just an example
Okay
also take look at lambdas
also you know that you dont have to declare a variable for everything you use @lament wolf
you can just do Bukkit.getScheduler().schedule
Does anybody know what this crash message means? My minecraft installation isn't even directed at that file location.
Its not your minecraft installation
it has to do something with the lightweight java game library
but no idea
Do you know of some potential solutions?
but no idea
fixed it, apparently my ssd ran out of space
Xdddddd
So i have the latest mc version with protocall support but people who use 1.8.9 forge or Baldin cannot join my single Kitpvp server
i need a solution to this
When I do
player1.hidePlayer(player2);```
player1 can't see player2 or inverse ?
or both
I'm sorry to come again but I encounter some issues with my yaml configuration :
I have the following yaml :
leaderboard-displays:
- title: "main"
location:
world: "world"
x: -60
y: 66
z: 0
objectives:
- "kills"
- "balance"
I can't use a mapping for retrieving the list of displays, because it would have no sense to give them a name, and the titles aren't unique, because they refer to which leaderboard they display (there can be several displays for one leaderboard)
LeaderboardDisplay implements ConfigurationSerializable, so that's ok, and take and return a Map which contains the title, the location (in form of a Map) and the objectives (a List of String)
so now, how can I retrieve this ?
with a getList() and then downcast each objects to a Map ?
player1 cant see player2 @lament wolf
youre hiding a player to a player
i didnt understand anything from your question @surreal sedge
what is an leaderboard display lol
it s an object I made, that's not the point x)
I want to create it from the configuration file
Create what from configuration file
eh... yes
but with getList i don't know to which object I should cast it
So i have the latest mc version with protocall support but people who use 1.8.9 forge or Baldin cannot join my single Kitpvp server
i need a solution to this
public List<Object> getList() {
final List<Object> list = new ArrayList<>();
for(Object object : getConfig().getList("your_list")) {
list.add(object);
}
}
or just
yes, I'm here already
getConfig().getList("your_list").forEach(object -> list.add(object));
but wat is the type of the underlying Object
I want to create a list of a custom class, not a list of Object, it has no interest for me
what do you mean a list of custom class
this custom class is named LeadeboardDisplay, and implements ConfigurationSerializable
it cant be saved to YAML though like the way you said?
it can be only serialized
why wouldnt you be able to do anything with the object
for example if you had a list of strings
and then u would use the method on the list of strings
it would return a list of strings
Object is just an abstract thing
can be pretty much anything
and how can I deserialize them ? I wrote a deserialize method wich takes the map returned by serialize and return the same object
but for string there's a special method getStringList
here it's yaml objects
it doesnt matter tho
you should know what you are storing in lists
in a YAML file
so you can tell if it should return a string list or integer list
or boolean list
yes, I know what I'm storing
I'm storing element with this forms
- title: "main"
location:
world: "world"
x: -60
y: 66
z: 0
objectives:
- "kills"
- "balance"
but how can I convert that to a java object ?
so just getStringList()? like idk whats ur point pretty much rn
It's not string
strings would be like ```yaml
- title
- location
- objectives
no you pretty much dont know what youre saying
objectives:
- "kills"
- "balance"
is an string list
as it doesnt have to be in the quotes though
objectives is an string list
yes, I know
۞๑,¸,ø¤º°๑۩ ןєคภ ๑۩ ,¸,ø¤º°๑۞dnes v 16:41
It's not string
@surreal sedge
but this is an element of my list
so whaaaaaat?
my list looks like this
leaderboard-displays:
- title: "main"
location:
world: "world"
x: -60
y: 66
z: 0
objectives:
- "kills"
- "balance"
- title: "something"
location:
world: "world"
x: 100
y: 50
z: 0
objectives:
- "life"
so I have a list of string (objectives) inside an other list
thats not a list inside of an list
why is there an - before title
leaderboard_displays is an section1
title is string
so I mistake by writing this file ?
wikipedia use a similar syntax
leaderboard_displays:
main:
name:
world:
x:
y:
z:
objectives:
- objective1
- objective2
main1:
name:
world:
x:
y:
z:
objectives:
- objective1
- objective2
this looks way better
bruh i dont even know whats this dudes point
cannot get a list of objects from a yaml
the problem here is that I have to named each objects, whith names that don't have any sense
because several LeaderboardDisplay (the class I'm trying to deserialize) can have the same title
bruh thats not my problem though xD
what im i supposed to do about that
design it with a better way and then u wont have that problem
ok, but I tried to use an other syntax
here you named objects main and main1
np, I will use this syntax since I didn't attempt to do what I wanted to do
thanks for the time you spend
like
i dont understand how an object class can have same title
final LeaderboardDisplay display = new LeaderboardDisplay("name", location, objectives);
got the same problem as yesterday when i put a new plugins files isnt creating
what
what?
?
wdym what
????
stop being a troll
why would you have to reinstall your whole server just to make a file directory for plugin
you make no sense
Learn java
or the spoonfeed is
public final class DataFile {
private final Main plugin;
private final String name;
private File file;
private YamlConfiguration config;
public DataFile(Main plugin, String name) {
this.plugin = plugin;
this.name = name;
}
public boolean setup() {
if(!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdir();
}
file = new File(plugin.getDataFolder(), name);
boolean succeded = false;
if (!file.exists()) {
try {
succeded = file.createNewFile();
config = YamlConfiguration.loadConfiguration(file);
} catch (Throwable reason) {
throw new RuntimeException(reason);
}
}
return succeded;
}
public void save() {
try {
config.save(file);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
public void reload() {
config = YamlConfiguration.loadConfiguration(file);
}
public YamlConfiguration getConfig() {
return config;
}
}
ok
i just said plugins doesnt create his directory
and after creating my self his directory it doesnt work either
just use my class
i reinstalled it
Looking for people in the cosmic test server or cosmic communty that have access to cosmic plugins or cosmic test server plugins (Aka looking for a dev that will be willing to help me and my jouney on creating a cosmic test server) Dm me and we can get talking
Hi, does someone know how to get a uuid from a name ? (player not online)
Bukkit.getOfflinePlayer(String name).getUUID()
okay thanks
@brisk mango title don't represent the title of the LeaderboardDisplay but the title of what it's displays, so several LeaderboardDisplay can displays the same datas, which are stored in a map with their title as key
bruh i cant do nothing about that tho because i havent designed the plugin
try thinking of something better
Looking for people in the cosmic test server or cosmic communty that have access to cosmic plugins or cosmic test server plugins (Aka looking for a dev that will be willing to help me and my jouney on creating a cosmic test server) Dm me and we can get talking
@brisk mango but this method is marked as depricated?
idk why
its the only way to get an offline player tho
or just
for(OfflinePlayer player : Bukkit.getOfflinePlayers())
or
Bukkit.getOfflinePlayers().forEach(offlinePlayer -> offlinePlayer.getName());
i will try some, thanks for your support 🙂
@brisk mango @tardy lance Just because it's depreciated doesn't mean you can't use it, it's just letting you know that there are changes in new Minecraft versions. As you may know it's not deprecated in new Spigot versions, but it's deprecated in older Bukkit versions due to the switch from usernames to UUIDs in 1.8, many years ago.
@cloud sparrow did I say that you cant use it?
Is there an existing event which can be called when a player define a new spawning point (by right-clicking on a bed) or i must use PlayerEnterBedEvent ?
Does someone know how to add argument suggestions like /gamemode creative/adventure (Version 1.14.4)
tab completion
you need to set its tab executor to a command
JavaPlugin#getCommand(String name)#setTabCompleter(...
okay thanks i will try some 😄
so-i got cmi through balckspigot(dont judge me too harshly please im broke) and it seems to work as intended, does this rule out the possibility its a virus?
lol not my code, my friend is asking me to debug and i cant think, whats the problem???
error: https://paste.md-5.net/natanavimi.bash
command: https://paste.md-5.net/ecikapetim.java
@wind dock why would you even say that here?
Talking about leaked resources or similar stuff should be avoided Geometry
yes geometry there is a possibility, usually people who broke rules broke other rules too
@oak stump which line is 21?
I can’t see on phone currently
And the bin lines is messing up :/
Is there any way to get the cause of a PlayerDeathEvent? I want to test if the player died by falling out of the world.
damage
you can do it on entitydamageevent
check if their health is less or equal to the damage and do your thing
How does that work?
I want to know if the cause of their death was by falling out of the world, regardless of their previous health or damage
@oak stump which line is 21?
@naive goblet thats the problem, line 21 isplugin.getCommand("book").setExecutor(this);
Can be invalid argument when invoking it’s constructor
Maybe a field that isn’t declared
but they all r xD
i dunno, only just looked at it, not my code
Can you find where they invoke the constructor
If you don’t know what I mean it’s when you add new Class()
Send main
oh thought i did
package me.dubleu.cenchants;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import me.dubleu.cenchants.commands.BookCommand;
import me.dubleu.cenchants.enchants.SpaceWalkerEnchantment;
import me.dubleu.cenchants.enchants.SpeedEnchantment;
import me.dubleu.cenchants.utils.Utils;
public class Main extends JavaPlugin {
public void onEnable() {
Bukkit.getServer().getConsoleSender().sendMessage(Utils.chat("\n\n &8[&a*&8] &aSuccesfully enabled SpectrumEnchants v1.3.2 \n\n"));
//Load the enchants (Listeners)
new SpeedEnchantment(this);
new SpaceWalkerEnchantment(this);
//Load the commands
new BookCommand(this);
}
public void onDisable() {
Bukkit.getServer().getConsoleSender().sendMessage(Utils.chat("\n\n &8[&a*&8] &aSuccesfully disabled SpectrumEnchants v1.3.2 \n\n"));
}
}```
wtf is wrong
my brain isnt working
i dunno, only just looked at it, not my code
pretty sure it is btw
have you declared the command in the plugin.yml?
cuz he didnt have a main class or anything
commands:
<commandname>:```
have you declared the command in the plugin.yml?
yeah he did it already
commands:
<commandname>:```
not to be rude but i aint stoopid xD
code seems to be fine
It is
lol so wtf is problem
He probably changed something since the error
I mean NPE is normally thrown when invoking un-assigned fields
my premium resource got reset to universal catagory and now I have to wait for the thing to be approved again
is any way to contact resource staff or smth?
Pretty sure dm works
I added Inkzzz but he hasn't responded yet
I added on discord
Why lol
figured it'd be faster
Just dm him instead of friend requesting?
Like you don’t need him as friend to start a convo?
I do
He has that turned off?
probably
should I private message them on the forums?
I'm kind of in a rush bc I've got people dming me trying to buy the thing
Dm a resource staff member on the forums
Is there a way to convert Block to Door like ((Door) block).isOpen(); explanation 100
Yes do an instanceof check and then cast
Idk if door has some sort of meta or data that should be casted instead of the block itself
Door and TrapDoor aren't interfaces like everything else but that doesn't mean anything does it?
Not really
Im clicking a door which should return a door block, trying to cast it to Door and thats when I get an error
org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock cannot be cast to org.bukkit.material.Door
?jd
I tried to setup bungeecord, and I'm getting this message
found it
okay found the error but when i try to execute the command it says it doesnt exist lol
Block block;
if (block.getType() != Material.DOOR) return;
BlockData data = block.getData();//might be getBlockData();
if (data instanceof Door) {
Door doorData = (Door) BlockData;
}```
You want to import the data.type one
So you get the right Door one
Guys, how to get a correct IBlockState?
CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData());
Returns invalid data
I'm using 1_8_R3, BlockData apparently isnt a class and block.getData(); is deprecated
@young dawn iirc there is a config option you should enable
Might want to look that up on the wiki
Macho maybe it’s MaterialData
I disabled online mode in both of my spigot servers and enabled bungeecord.
yes that exists, I'll try it
And I enabled IP forwarding in my bungeecord server
okay found the error but when i try to execute the command it says it doesnt exist lol
found it all gooood, thanks for all the help
Maybe you need to enable in spigot.yml long time since I worked at that stuff
@pliant tiger Block#getState() ?
block.getData() returns a byte and it wants a MaterialData and is still deprecated
@pliant tiger Block#getState() ?
@naive goblet its not a NMS
Block#getBlockData @left plover
Not a method
Yes but wants a string?
What?
yeah
Wym
Yes that works, block.getState().getData()
Ok 👌
So do I convert that to a door? With (Door) block.getState().getData()
Yes
And be sure it’s the right Door import
It might be called DoorMeta or DoorData or smtng
Ok, ill try it now, only Door and TrapDoor are classes
Okay use Door
I'm looking to create some custom mob behaviors (attack a single entity, don't change targets, maybe move a little faster/slower, not be affected as much by running water). Is this old bukkit tutorial from 8 years ago still the way to do it?
https://bukkit.org/threads/tutorial-how-to-customize-the-behaviour-of-a-mob-or-entity.54547/
One of the pieces of data I need is the typeId, but I see that EntityType.getTypeId is deprecated.
@tiny dagger oh shoot- how do I know if its not a virus? or is there a way to get rid of it altoegther before it does too much damage?
i dunno
oh
okay its still not working,
error: https://paste.md-5.net/bohutiriqi.css
Main: https://paste.md-5.net/egofozuciz.java
command: https://paste.md-5.net/opeliwezit.java
Are there any people with a little bit of experience in Illustrator?
okay its still not working,
error: https://paste.md-5.net/bohutiriqi.css
Main: https://paste.md-5.net/egofozuciz.java
command: https://paste.md-5.net/opeliwezit.java
wtf is wrong
Guys, how to get a correct IBlockState?
CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData());Returns invalid data
@oak stump has to be an issue with the plugin.yml
Kk
Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf Wtf
version: 2.7.0
name: SpectrumEnchants
author: TheDdosDevil
commands:
book:
description: to lazy to do one```
@oak stump has to be an issue with the plugin.yml
@dry shuttle can’t be because there is no issue xD look
All the enchants work it’s just this command, the command opens a gui, do you think it could be something to do with the gui being wrong?
No way
xD
I have had the conversation
plugin.getCommand("") returns null if the command is not found, It can only be this that is causing the npe
BookCommand.21 plugin.getCommand(“book”).setExecutor(this);
And main 21 is new BookCommand(this);
plugin.getCommand("") returns null if the command is not found, It can only be this that is causing the npe
@dry shuttle how can it not find the command, it is everywhere lol
I broke spigot
Btw spigot 1.8.8
Try to register the command in the mainclass
@proud furnace annoyingly tried that FIRST before in the class and it didn’t work
No it’s not
Definitely not
But it’s not my code, I remade it for a guy who said he needs help on my discord
Seriously...
???
That’s not mistake
lol
xD
Its the getCommand thats returning null right?
Ye
Try to print plugin
plugin can't be null
Yes it can
not in his case
It can’t rn
Oh he's just passing this
yea
Ye
I when I thought I’d finally got the hang of it and could be considered “intermediate” xD
Need help
i use wildstacker to stack my drops
my cactus farm isnot efficient
sometimes drops stack on first drop, sometimes on second
i know this is probably a basic java concept but how do I get the messages from the string List to send to the player so it reads of the list like
Line 1
Line 2
instead of Line 1, Line 2
\n
but string lists are not compatable with p.sendMessage() for some reason
okay ill figure out how to draw config values from an array list
This guy is just trashing everyone on SpigotMC lol
Can something be done?
He just says all plugins are lagging
Thing is my plugin is about Exploit protection and i can't make it paid because it would be excluding people that really needs it
How can i get an Inventorys name? event.getClickedInventory().getTitle() doesn't exists anymore
e.getView().getTitle()
Thanks 😄
You have to get the InventoryView from the event with getView(), and then you can call getTitle().
Can somebody help me?
I made like a command called /sign <text> and I need to have a variable text from args.lenght == 1
how do I cast that
I'm sorry? are you mentioning you want to check if they have a argument for position 0 of the string array in the onCommand?
voter suppression you're all reported
/sign args[0] args[1] args[2]
String message = "";
for (int i = 0; i < args.length;i++) {
message = String.valueOf(message) + args[i] + " ";
}
}else if(args.length >= 1) {
String message = "";
for (int i = 0; i < args.length;i++) {
message = String.valueOf(message) + args[i] + " ";
}
}
okay its still not working,
error: https://paste.md-5.net/bohutiriqi.css
Main: https://paste.md-5.net/egofozuciz.java
command: https://paste.md-5.net/opeliwezit.java
wtf is wrong
Oh yeah plugin.yml
version: 2.7.0
name: SpectrumEnchants
author: TheDdosDevil
commands:
book:
description: to lazy to do one```
I've developed a plugin that opens a gui with an item in it which is named after a money balance stored in files named after the players uuid. but if two people open the menu at the same time, they got the same value...
Create a new inventory for each player and keep track of them per UUID
I have a custom command made.. how can I make it so this custom command pops up as a suggested command?
you need to asign a tabexecutor as well to it
selection
it works however not sure at what performance cost
yeah it's a weird logic
i use kind of a weight system
i would've made a ticable interface
If anyone can help plz do ^^ , if anything friend me
basically each second i pass the list of players inside that region,do the checkings
then clear it and so on..
@wraith thicket Every time someone enters the command it creates a new inventory. when it opens it checks if it has the title "Horseshop". If yes, then he changes the 8th slot items name.
ItemStack is = event.getView().getItem(8);
you know inventory slots start from 0 right?
Don't check the name - keep track of the Inventory objects
@vernal spruce yes
hmm i think you would have better luck looking into abstract inventory holders
its alot easyer once you get the base done
Hey guys i have a little problème,
How to have the player execute a command when he right clicks on a PNJ
My code :
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class CommandCustomNPC implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args) {
if(sender instanceof Player) {
//variables
Player joueur = (Player) sender;
Location loc = joueur.getLocation();
Villager npc = (Villager) loc.getWorld().spawnEntity(loc, EntityType.VILLAGER);
net.minecraft.server.v1_7_R4.Entity nmsVillager = ((CraftEntity) npc).getHandle();
npc.setCustomName("§2Onlydays §cl'inactif");
npc.setCustomNameVisible(true);
nmsVillager.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
}
return false;
}
why not name things in english in the code..
doesnt the api teleport rotate his body?
you don't go implementing random bukkit interfaces
by md_5
Custom InventoryHolder implementations are a misuses of the API
why can we do it rather than lock it behind something?
It's an oversight.
damn then why it got so popular
is removed and kept on a package basis
You could hide the method that takes it as an argument
mhmm guess i gotta change some plugins gui management
why is it exposed?
An oversight most likely
for so many versions though?
I have iron farm on my server and after updating to paper-283 it broke, villagers teleported out of their cages and died, can anyone help?
well people missuses it
https://www.spigotmc.org/threads/using-to-compare-inventories.374324/ - that's where I found out
so we are using a bug
@wraith thicket but i dont get it, why it changes all inventorys named "Horseshop"? I only change that one that is open...
wich somehow works?
well good to know,guess gonna stick to good ol uuid/inventory
https://pastebin.com/iHM5SZLb : Command
https://pastebin.com/fy0gCMNz : Event
thanks
oh boy
bro idk from this
if the items will always be the same wouldnt it be better to already have them created in a inventory
then simply make a copy of that inventory?
hm @subtle blade it's been 2 days and my name haven't get sync with SpigotMC name yet. It's suppose to auto sync right? or did I missed something
dont think names are synced
tbh just go with a manager class
what does this mean? 20.05 15:42:43 [Server] WARN jontyMS was kicked due to keepalive timeout!
wich keeps track of opened inventories
and from there do the work like opening a new inventory and so on
cant i just give that inventory an id to track it later?
On my server, when I type /send it says that I dont have permission. I have the * permission, so how can I fix this?
thats where the manager comes in,you hold a hashmap with inventory/uuid (or w/e order)
so a simple method should be called from the command
oh boy.. they arent rly complicated
you can think of it like a pair,name-value they will always be connected
HashMap<UUID,Inventory> openedInventories = new HashMap<UUID,Inventory>();
but this goes into java basics wich i think you have a easyer time
looking at a tutorial..
rather than me explaining a specific example
Map<UUID,Inventory> openedInventories = new HashMap<>(); this looks better imo
yeah dont think there is much difference
well
first of all you're using the map
instead of the hashmap
which means it won't break stuff as bad
when you want to use something else than hashmap
😂
nah
not rly its just discussion about the map types
okay, so i now use Map or Hashmap?
well both
well he is right bout it,you make it risk proof
but pass it around as map
You declare it as a Map but initalize it as a HashMap I’d say
I mean you could define it as a HashMap in the start if you want but not really necessary
Having it just as a Map makes you can redeclare that Map field as another Map type if you want later
And afaik most map types doesn’t provide any additional methods
You can also stack maps
Map<Object, Object> map, map2, map3;```
Okay guys, there are thousands of methods to do what i want. but if we say id use this:
HashMap<UUID,Inventory> openedInventories = new HashMap<UUID,Inventory>();
How do i dann an entry to it?
i guess if you want to define them later.. but usually you have a specific map you want