#help-archived
1 messages · Page 58 of 1
is if(!getConnection().isClosed()) { what is actually at line 66?
Also don't run your sql queries on the main thread. You're going to experience issues very soon if you haven't yet.
Is WorldServer the same as MinecraftServer?
Remember to always run your SQL queries in the Main Thread and definitely not Async!
WorldServer isn't a server
a more fitting name for it is ServerWorld, as it's a subclass of the World class in the MC code, specifically for server-related worlds
Anyone mind givin me a hand, I'm having an issue with GSON
https://hastebin.com/ohofeqayox.cs is the error log.
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
Yeah I got it
so know the give command /give <player name> <object> <number>, well I am trying to make the part were it searches for the players and uses them for the command does anyone know how I should do that?
args[0]
What do you mean? Like run the give command to give every single player something?
Or the Player object from the string?
Whats the difference between EnumProtocolDirection.CLIENTBOUND and EnumProtocolDirection.SERVERBOUND? I'm having trouble spawning an npc and I don't know which one to use
If you just want to give everyone something use @a instead of a player name lmao
Or make the command /giveall
@frigid ember no I'm not giving I'm making a command that when I type in the arg it will set a variable to that arg that arg will get player names tho
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "jim");
WorldServer world = ((CraftWorld) p.getWorld()).getHandle();
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer pl = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
DummyPlayerConnection con = new DummyPlayerConnection(server, new DummyNetworkManager(EnumProtocolDirection.CLIENTBOUND), pl);
pl.spawnIn(world);
pl.playerInteractManager.a((WorldServer) pl.world);
pl.playerInteractManager.b(world.getWorldData().getGameType());
pl.setPosition(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
world.addEntity(pl);
}
Hey guys, when I spawn in a player I have to rejoin to see it, how do I fix it so it spawns when I type the command instead?
Bukkit.getPlayer(args[0]) will get the Player Object and you can use that to give them the item @kind berry
If you just want it to get all player names just run through a for loop and stick them in an arraylist?
You should probably learn the basics first
^
He just said hes new and is trying to learn, how do those comments help him at all?
Telling someone to learn the basics is helpful.
This isn't a place for us to spoon feed the basics for people, if someone wants to do that then that's on them, but we're not teachers
Gotta walk before you can run.
He's asking for help on the basics
There's hundreds of guides and free learning material out there
Yes there is, and he choose this place to come for help
You can sit here and explain it if you want
or just do a simple google search 😅
My advice is to go away and use the available meterial to learn the basics. A for loop is used in almost every language, and is pretty much day one
No, thats a while
I have tried google and youtube searches none have showed what I need
that is a while too
although my reply was supposed to be right to the point
@wooden harness sorry I mean not for the for loop
A for loop is meant to be used if you have a set amount of times you wish to run. A while should be used if you intend to loop for an unknown amount of times
yes
I rarely use while loops tbh
while(user entered something dumb) {
askIdiotAgain();
}
While loops are also great for never ending loops lmao
I've never ONCE used do while
I could never even really understand why they're a thing
ok thanks I get what a for loop is but idk how to do the thing @frigid ember sed to do with the arraylist
I find the most common use for a while-loop is generally when using a Queue or some Iterator implementation.
yea
Oh yeah Iterator.next()
for (Player target : Bukkit.getOnlinePlayers()) {
if (args[0].equalsIgnoreCase(target.getDisplayName())) {
I forgot that existed
would that work?
thats an enhanced for loop
labels have their usage
yea
nested for-loops
Java docs are your best friend
are a batch though
Wait hold up, why are you using a for loop to check if an argument is a players name?
oh thats display name
okay whew
Just use Bukkit.getPlayer(args[0]) @kind berry, no reason to loop through the players
eliminate the loop @kind berry
Player target = Bukkit.getOnlinePlayers().stream().filter(o -> o.getDisplayName().equals(args[0])).findAny().orElseThrow(IllegalStateException::new);
Seems a bit complicated for what he's trying to do lmao
dont think so
so there u go
He shouldn't be using getDisplayName anyways, the argument is the player name
lmao
XD
i could never figure out how lambdas work
what confuses u young one
o is a reference to the object in the stream
yea
-> indicates the usage of a functional interface
It's kinda like for each I think
yeah
I mainly use them because IntelliJ yells at me if I don't :(
aint nobody got time for that
intellij autocompletion is OP
Tis
Although if I try doing List<String> strings = new ArrayList<>(); without importing ArrayList it will autocomplete to ArrayListOutOfBoundsException... So I end up typing List<String> strings = new ArrayListOutOfBoundsException() all the time
Rip
rip wut
Dess and his autocomplete
poor lad
It's sad yes
regardling lambdas though, they're pretty helpful day to day
especially since the collection api is so broadly used and inherity supports them
definitely worth learning
anyone else have a slime spawner? does it spawn slimes?
Hey guys, when I try spawning an entity it crashes my server
https://hastebin.com/jabugohove.shell
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle();
GameProfile gameprofile = new GameProfile(UUID.randomUUID(), "hithere");
WorldServer world = ((CraftWorld) p.getLocation().getWorld()).getHandle();
EntityPlayer entity = new NPCEntity(playerList.getServer(), world, gameprofile, new PlayerInteractManager(world));
world.addEntity(entity);
world.players.remove(entity);
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, entity);
for (Player online : Bukkit.getOnlinePlayers()) {
((CraftPlayer) online).getHandle().playerConnection.sendPacket(packet);
}
entity.getBukkitEntity().setMetadata("NPC", new FixedMetadataValue(main, true));
msg(p, "Entity spawned");
Hello,
I'm having trouble understanding how exactly to make my MySQL calls asynchronous. Could someone help me out?
https://hastebin.com/hugagubama.java
I need a plugin that can disble gravity, is anyone aware of one that does that?
I only found one that costs money which I rather keep for myself right now because of corona
I created a coinflip plugin and whenever someone does a coinflip, the tps drops
Any reasons on why this is happening?
It seems that whenever a coinflip game is active, the server tps drops a little
We can't tell without some code 😛
@frigid ember world.addEntity(entity); world.players.remove(entity);
Delete those
I don't know NPCEntity class so I cannot say exactly what problem is causing
NPC.getBukkitEntity().setRemoveWhenFarAway(false);
NPC.setLocation(this.location.getX(), this.location.getY(), this.location.getZ(), this.location.getYaw(), this.location.getPitch());``` for creating nms player
@frigid ember which java version do you use? I guess it's 1.8 if so try to use new java method to get and set datas
You can use it in thread for doing on background
hello i need some help
try (ResultSet result = statement.executeQuery("SELECT * FROM x WHERE y = '" + cc + "'")) {
//code
}
}).start();```
so basically i have essentials plugin downloaded and i have kits but when i put my sign down everything works fine and i can get the kits but the people without op cant get the kits its says " you dont have access to this kit" anyone plz help
@cobalt folio it's not essentials plugin help discord. You've to ask to owner of essentials or its community.
this is help section ?
This is help section not about the spigot plugins...
yes it is
...
....
@cobalt folio This is not the essentials support discord
ok fine thanks for the help
yeah cya
how to check if their last block was ice so that the anticheat knows that they are not speed hacking
@frigid ember For anti cheats I usually use PacketPlayInFlying packet for checking their movement. You may save their last location that is acceptable for return and if the anti cheat detect something teleport them to the location.
Minecraft getBlock method is broken
If you stay on edge of block it gives you air or other blocks instead of you staying on
You can check under block with basic math.
i have tried most of those things and for some reason just cant get it
for (double z = -0.3; z <= 0.3; z += 0.3) {
if (location.clone().add(x, -0.5001, z).getBlock().getType() != Material.AIR) {
return location.clone().add(x, -0.5001, z).getBlock();
}
}
}```
try to use it and feedback to me
yeah you can change as player location
but it's just example of what I meant to say. After try it, make your own method based on this method.
where should i put this?
just make a method for getting block
like public static Block getUnderBlock(Location location)
hmm weird it wants me to change it to void even tho its returning a block
oh wait
i the big dumb
put return null end of the code
yea
-_-
lmfao
https://gyazo.com/06446565c598a19c3f6892858ed0ccdf returns the block under yes
Okay. Try to understand what you did then make your own method for getting block. You may also make another method based on it.
Good luck
i am still confused i get on the method works but i dont get what i do next to see if it is Ice, or Packed ice so i cant false flag
if (getUnderBlock(location)).getType() == Material.ICE)
Why don't you know that?....
cause i am new to checking blocks and stuff i did more of the designing wanted to get into making plugins and ik a bit of java but searching thru docs i cant find anything
I have two servers:
Main dedi server for spigot (1.1.1.1)
Vps for bungeecord (2.2.2.2)
I have got dns records:
A hub.example.net to 2.2.2.2
A pvp.example.net to 2.2.2.2
Bungeecord config:
1st listener:
host: hub.example.net:25565
forced_hosts:
unconfiguredhost: unconfiguredserver
force_default_server: true
2nd listener:
host: pvp.example.com:25565
forced_hosts:
pvp.example.net: pvp
force_default_server: false
Connecting to hub.example.net brings to hub and is all good. Connecting to pvp.example.net brings to the hub as well though? If I change 2nd listener port to 25566 and use pvp.example.net:25566 to connect then it brings to pvp. Is it not possible to make it with default port to bring it to pvp server?
If you make an iptunnel for connection both server machine, it probably bridge together.
So after having a method that is a boolean to check if the player is on ice with the other method i would do what now to save it then remove after sometime i did a Map and it just errored alot earlier
I dont really get it tho how do i remove after sometime because last thing i did was runLater and it would error for it trying to remove stuff when it wasnt in it
@chrome edge do i need to use srv record to get rid of port numbers for ppl? Or that wouldnt work?
Firstly if you connect both server with iptunnel you should use 0.0.0.0:port
but if you want to get rid of port you can do it with srv record as you said
I'm not experienced with that. That's all I know.
on vps bungeecord i have:
servers:
hub:
address: 1.1.1.1:3001
And on dedi server spigot i have:
server-port=3001
server-ip=
empty ^^
is this wrong way?
Have you try use 0.0.0.0 both dedicated?
like hub:0.0.0.0:3001
and change it server.properties also
@gentle socket if you're using OVH or hetzner it'll be problem for you. There's DDOS protection that blocks iptunnel. You have to know how to setup up this things.
yeah im pretty new to this. I use OVH for bungeecord vps and local server center for spigot dedi
so if bungeecord vps gets ddosed, its only gonna reach that vps
thats the idea
I knew that was the idea well I've little experience what you talking about xD
If you under the dos attack it'll break the bridge and your players will fall.
due to ovh protection.
If I understood correctly, the ip address that you put into bungeecord to connect spigot server together goes through proxy and nobody can see spigot server's ip
only the ip bungeecord runs on
ooh
hmm
guess ill need to wait for someone to ddos us to see if its setup correctly xD
yep good luck xD
Hello. I just wanna ask a question. So my other owner might have my plugins, if he leak it, I worried I would get ban on Spigot. If that happens, will I get unban? I am just worried.
You are the responsible one. You may be banned from spigot.
Yes but I had no choice. I got betrayed by a friend I known for a long time. He just stole all of the server money. So I am worried if he is thinking to get me ban on Spigot. Does Spigot strict about this? :l
As I know unfortunately it makes you ban. When you buy/download the plugin, you accept to TOS.
My day can't get anymore worse surely. Thank you for answering my question. I really hope I am not getting ban anytime soon. I am sure this situation had happened before, just I don't know what will happen.
Can someone tell my why this always crashs when i go in creative Inventory?:
public void handleNavigatorGUIClick(InventoryClickEvent event) {
if(!(event.getWhoClicked() instanceof Player)) return;
Player player = (Player) event.getWhoClicked();
if(event.getClickedInventory().getTitle().equals(GUI_NAME)) {
FileConfiguration config = Main.getPlugin().getConfig();
String i = "0";
switch(event.getCurrentItem().getType()) {
case GOLDEN_APPLE:
i = "Spawn";
break;
case BED:
i = "1";
break;
default:
break;
}
World world = Bukkit.getWorld(config.getString(i + ".World"));
double x = config.getDouble(i + ".X");
double y = config.getDouble(i + ".Y");
double z = config.getDouble(i + ".Z");
float yaw = (float) config.getDouble(i + ".Yaw");
float pitch = (float) config.getDouble(i + ".Pitch");
Location loc = new Location(world, x, y, z, yaw, pitch);
player.teleport(loc);
}
}```
**[03:35:11 ERROR]: Could not pass event PlayerMoveEvent to AntiGamingPhone vHOT PATCH 1.01
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:296) ~[server.jar:git-GenericSpigot-5728a59]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[server.jar:git-GenericSpigot-5728a59]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-GenericSpigot-5728a59]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:497) [server.jar:git-GenericSpigot-5728a59]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:482) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:270) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.PacketPlayInFlying.a(SourceFile:137) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.PacketPlayInPosition.handle(PacketPlayInPosition.java:35) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:204) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:801) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:309) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:650) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:555) [server.jar:git-GenericSpigot-5728a59]
at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [server.jar:git-GenericSpigot-5728a59]
Caused by: java.lang.NullPointerException
at me.l3ilkojr.gamingphone.util.BlockUtils.onIce(BlockUtils.java:34) ~[?:?]
at me.l3ilkojr.gamingphone.checks.movement.SpeedA.onPlayerMove(SpeedA.java:38) ~[?:?]
at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
at org.bukkit.plugin.java.```
@frigid ember make sure chunk is loaded.
how would i do that?
Also, you should create an inventory and check if the inventory is an instance of it, better than checking for the name
is that a solution for me or for rbuh? 😅
thx i'll try
anyone know how to check if the chunk is loaded tho?
check what hawk does
So @steep acorn you should do that, as it might conflict with other plugins (inventories with the same name).
You should post the stack trace, because “it crashes” is pretty generic
FatalPacket was that to me?
yes
Well where do they do that because i not searching 20 files to find one thing
Block.getWorld().isChunkLoaded(Block.getX() >> 4, Block.getZ() >> 4)
but I dont think its because of chunk loaded
thats what i think too
what is line 34 in block utils
if (getUnderBlock(location).getType() == Material.PACKED_ICE || getUnderBlock(location).getType() == Material.ICE) {
return true;
}
public static Block getUnderBlock(Location location) {
for (double x = -0.3; x <= 0.3; x += 0.3) {
for (double z = -0.3; z <= 0.3; z += 0.3) {
if (location.clone().add(x, -0.5001, z).getBlock().getType() != Material.AIR) {
return location.clone().add(x, -0.5001, z).getBlock();
}
}
}
return null;
}```
@frigid ember there is no stack trace, it just stops working until i die and respawn
What stops working? The server?
no, the plugin.
its like its not on the server anymore
there are other cmds that stop working
Player player = (Player) event.getWhoClicked();
if(invent == null) return;
if(event.getClickedInventory() instanceof invent) {```
like that?
cause this isn't working
@frigid ember did you check if there're not an air block?
'cause if there's no blocks under the player it returns null
return true;
}```
and don't use method more...
Just save as data start of the code.
Block underBlock = getUnderBlock(location);
As I know, PlayerMoveEvent is controlling chunk before the its call. If you're using packets, make sure chunks are loaded.
One last time, is player.isFlying() meant to be updated when they stop flying without double tapping space?
If I am sure yes
@frigid ember if you're flying, it returns true
double space active and deactive
or player.setFlying(true)
but if they collide with ground rather than toggling it, isFlying() isnt updated?
yes
but thats.. kinda cringe
isFlying() would suggest the player is flying
That's correct. So what's wrong?
flying method in spigot means that player flying using default minecraft features.
double space
Hi all, I'm making a Plugin where Players can interact with NPC Players (EntityPlayers).
They are made visible to the Player via sending them a Packet to spawn an EntityPlayer. This all works well, but I now wish for Players to be able to interact with these NPC's by clicking on them.
I've also managed to get this working, by using the tradional way of injecting/removing Players and making use of the ChannelDuplexHandler and ChannelPipeline classes from a mix of different tutorials online.
For this simple task, I have chosen to not use ProtocolLib as a learning experience.
Now whilst the following works, I understand that it may not be thread safe or efficient.
For simplicities sake I've reduced everything down to one class, to what would be in a basic tutorial.
Could someone please let me know why the following wouldn't be thread safe / is inefficient?
And by extension how could I do something complicated like Packet Listening on another thread to make this more efficient?
public class PacketCancel extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
injectPlayer(event.getPlayer());
}
@EventHandler
public void onLeave(PlayerQuitEvent event) {
removePlayer(event.getPlayer());
}
private void removePlayer(Player player) {
Channel channel = ((CraftPlayer)player).getHandle().playerConnection.networkManager.channel;
channel.eventLoop().submit(()->{
channel.pipeline().remove(player.getName());
return null;
});
}
private void injectPlayer(Player player) {
ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
@Override
public void channelRead(ChannelHandlerContext channelHandlerContext, Object packet) throws Exception {
if (packet instanceof PacketPlayInUseEntity) {
// do stuff
}
super.channelRead(channelHandlerContext, packet);
}
@Override
public void write(ChannelHandlerContext channelHandlerContext, Object packet, ChannelPromise channelPromise) throws Exception {
super.write(channelHandlerContext, packet, channelPromise);
}
};
ChannelPipeline pipeline = ((CraftPlayer)player).getHandle().playerConnection.networkManager.channel.pipeline();
pipeline.addBefore("packet_handler", player.getName(), channelDuplexHandler);
}
whats the method to check if someone is jumping?
Can someone tell me what this part is for?
Ok so, i need to fix the problem with someone getting hit and them jumping making them go further then normal speed my AC Flags so anyway to fix this?
i have it stopping when taking Velocity but it just doesnt work after them getting hit and jumping
hey guys, not sure if this is the best place to ask, I'm looking for a good grappling hook plugin and a weapons plugin that lets you use crossbows as block-destroying weapons
how can i remove an entity safely without it crashing the server - ie http://paste.debian.net/1144497/
the search bar has worked only so-so for me so far, wondering if anyone has some recommendations
(open source would be great!)
Entity.remove() lol
@lament wolf There is an action value and it can range from 0-4 and it does differnte things
Make sure you dont call it async
i removed all entity.remove() and moved them to a single place where i wrap it in a scheduleSyncDelayedTask
that should have been fine right?
looks reasonable
and yes, idk about that crash specifically
could be a 1.14 bug
Would i just check if someone is Taking Velocity and there Y is changing should i then dont flag?
@lament wolf and for each action value you need to send different data, that is specified at the right of the action column
also, how much performance do you loose by running a server inside a docker container?
i've heard networking can take a hit
@sharp dew So where I should insert these value ?
you should use a dataWatcher
?
or you should use reflection to access the private fields of the packet
can i ask you what you need to do
@lament wolf you can also construct the packet by writing
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.(ACTION), playerAffected)
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.(3), playerAffected) should work ? @sharp dew
@lament wolf for the action you can chose between ADD_PLAYER, UPDATE_GAME_MODE, UPDATE_LATENCY, UPDATE_DISPLAY_NAME, REMOVE_PLAYER;
but yes it should work
you should change the gamemode of the EntityPlayer and set the action to update gamemode
Something like that:
EntityPlayer entity;
...
entity.setGamemode(2);
packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, entity);
aPlayerConnection.sendPacket(packet);```
?
yes
but
to set the gamemode you have to use player.playerInteractManager.setGameMode();
Yeah okay :relieved:
Ty
Another question:
If I want to move an entity, should I use Entity Position and Rotation or Entity Velocity ? I saw Entity Move but it doesn't do much good from what I understand
i know the the varius different packet are used to reduce data consumption and so if you don't move but only rotate you don't send the position data
but i think you should send Entity Position and Rotation
because normaly the client sends those packets
yes
Look at the parenthesis
Hi
What does that mean ? If I want to take 3 steps forward the X of the entity, I should do
hoo wana play minecraft
Such as (10* 32 - 7* 32) * 128
wat are you taking about
packet Entity Position and Rotation
i think the coordinates should be modulo 8 becuse that is the maximum ammount of blocks you can move with this packet. but i'm not really sure how to use it
maybe it's easier with the Entity Teleport packet
rather between 8 and -8 than module 8, no?
yes my bad
try to look into other mobs like zombies, there should be the correct implementation somewhere
now i get it if you do (curr * 32 - prev * 32) * 128 it should work with any coordinates
let us assume that my entity is located at (30, 40, 30), I want to move it up three
because the formula calculates the delta of the coordinates
you should do (43 * 32 - 40 * 32) * 128
@lament wolf be sure to use int for doing the calulation and the cast it back to short
cuz it might overflow
double/float, no ?
or double is good too
PacketPlayOutPosition is the corresponding parcket ?
gimme a sec
Yep =)
dosen't seem like it
🤔
cuz this is the constructor of the packet public PacketPlayOutPosition(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, int i) { this.a = d0; this.b = d1; this.c = d2; this.d = f; this.e = f1; this.f = set; this.g = i; }
too many fields
it's cuz the names are not the same sadly
seems right
Is using ProtocolLib thread safe?
eg. Just getting the ProtocolManager and adding a packet listener?
(Such as the tutorial on the bukkit page? https://dev.bukkit.org/projects/protocollib/pages/tutorial)
By thread safe I mean should I be putting this on a different thread because it's sending / receiving packets? Or does ProtocolLib do that for you?
Why would you register a packet listener async, lol
i'm tring to implement a TabCompleter class but i don't if and where i should register it like with an eventListener
Guys can sb help me with my SKYBLOCK, i want some for free, bcs i have 1.13 server, and i download skyblock, and its not working
@hoary parcel I'm new to this, could you explain why you wouldn't? 🙂 I assumed that (most)code that is sending / receiving packets should be async.
Your listeners will be executed on netty threads
No need to run the register code async
And RN i downlaod LuckyPerms, i reload server, and my server can t start
String playerName = command.getArguments()[0];
sendMessage(playerName, command.getChannel());
Player player1 = (Player) Bukkit.getPlayer(playerName);
Why is this not working? It gives this error: https://paste.md-5.net/ivapotenaf.css
The error is for Player thing
Player player1 = (Player) Bukkit.getPlayer(playerName);
The player is probably offline
How do I get offline player
Bukkit#getOfflinePlayer
Oh okay thank you
What is the best method to get which player killed an entity?
Did you check if the player name is correct?
And you probably should use the player's UUID instead
How can it be replaced with null check. Surely an arrow also counts as an entity etc
because I check for the argument
@cold wharf Use an UUID fetcher
How to do that? Sorry I am new
I bet getentity returns livingentity for you there @remote socket
It only return a player if there is one
// getKiller() returns a Player, so you don't have to check if it's a player.
yes it does
public static UUID getUUID(String playername) {
String output = callURL("https://api.mojang.com/users/profiles"
+ "/minecraft/" + playername);
StringBuilder result = new StringBuilder();
readData(output, result);
String u = result.toString();
String uuid = "";
for (int i = 0; i <= 31; i++) {
uuid = uuid + u.charAt(i);
if (i == 7 || i == 11 || i == 15 || i == 19) {
uuid = uuid + "-";
}
}
return UUID.fromString(uuid);
}
@red linden So I only need this right?
Yeah, but please cache the results as Mojang is rate-limiting their endpoints.
Huh?
So i have a plugin that summons a chest on LightningStrikeEvent but for some reason its not working, to figure out where the problem is i put a system outprint as first action after the event:
void Lighting(LightningStrikeEvent event){
System.out.println("syte");
But this wont even get printed out, any idea why?
@EventHandler?
yea i do have that
currently trying monitor
also not working
commands work
enabling goes normal
any ideas?
I'm in big need of help, so this happends to my server, same time every day it's always 10:40, server running smoothly other than that, i never have tps drops or issue with ram, no errors throughout the days either, it's just this thing that happends exact at 10:40 every day, and i can't seem to understand what it is. But maybe anyone here can?
@slim hemlock fat
@sharp dew wtf dude 😂
The packet that we talked about, it's teleportation
the first one?
thanks fanclub
The
@lament wolf or the one you sad
PacketPlayOutEntity.PacketPlayOutRelEntityMove
i'm looking in the code
How do I make plugins only available in like survival world and not in hub wolrd
A friend of mine seems to not be able to lose hearts but they can lose hunger
Could anyone probably help me?
What's the replaced version of ProxiedPlayer.getAddress()
Is it allowed to have a free resource and a premium version of it; lets say the premium one gets updates a day before the free one but its more considered the donation version of it
@frigid ember nothing against it, all of the guidelines for premium plugins can be found here: https://www.spigotmc.org/threads/premium-resource-guidelines.31667/
Does anyone have suggestions for a good VPS provider? I am looking to spend around $60-100. I am currently hosting on my own PC. We average around 15 players and we have a ton of plugins. I have never seen it use the max 16gb of ram, but I have seen it at 14, so ram is important. More important is CPU, which usually runs at around 30% utilization (i5-6600k @ 4.4Ghz) but it spikes sometimes to max which causes a good amount of server lag
@storm vessel Location?
I am worried that most VPS's, which use server chips, won't have the clockspeeds necessary for a game server
Currently near Pittsburgh, though anywhere in the US will do
Preferably Eastern US
Then dont use a VPS
get a Dedicated Server if you're looking to spend around $60-100
I can find any for that price that aren't shitty
I'm using reliablesite.net rn
I could buy/build my own, but I want the benefits that come from having my server in a datacenter
Thank you
OVH is good as well, I personally don't use them because I've had transaction issues with the,.
but if you're going to spend the money, there's no reason to be on a shared VPS host.
I wish I could find a good hosting company that has servers with desktop chips
The 3950x would be perfect for MC
I heard good things of reliablesite aswell. I personally cant use them because I'm from EUW
@dusky herald My issue is that if I were to spend $100 I would be getting the cheapest dedicated server available which is usually worse than a good VPS as far as specs are concerned
¯_(ツ)_/¯
You said you have 15 players, I dont see an issue with using a dedicated server.
The server only started 25 days ago, so I am counting on expansion
Then wouldn't a dedicated server be your best option then? That why you're not using a shared VPS host?
Now that we are getting votes we get 10 new players per day. 2-3 actually play for more than a few days
with 100$ you can get a good dedicated lmao
Yes, but for what I can afford, I can't find a dedicated server with good enough specs
you said 60-100$
Maybe you're looking at specs way more than what you need right now; lol.
Soyoustart might also be a good start.
https://www.soyoustart.com/us/game-servers/
You could just get a dedicated server for now
and upgrade later
to fit the needs for your server
It's not really a crazy concept for a server to upgrade multiple times early in it's life.
I'm currently running it on my PC which has 32gb of ram, NVMe storage and a a mid level CPU that OC'ed the shit out of and I'm still having occasional lag. Before I installed plugins to optimize villagers and entitytracking I was at 100% utilization for 15% of the uptime
Ok, I'll do some research into that
I mean, the only thing that's really going to bottleneck you would be your CPU
NVMe storage helps, but not a great difference
and also seems like you could be experiencing more lag because your server isnt dedicated to your "server" yet
This is off topic, but I wander if optane is fast enough to store loaded in chucks instead of memory
That is true. It is also doing regular Windows desktop things aswell (I run my server in an Ubuntu Server VM)
I think a dedicated could work fine for your needs, and if not you can always optimize performance and upgrade later.
I could be underestimating the performance toll that is taken by running it on the same PC that I use for other things
The crazy, high performance dedicated servers are meant to hold a crap ton of players; but I dont see why you wouldnt be able to hit 75+
Yeah you're right. I do have room to optimize as entities spawns are barely nerfed and view distance is at 8
I cant even give a good estimate nowadays anyways, back when I actually ran my own servers a dedicated server was more than adequate enough to hold over 700 people
My thing is that I have so many plugins
but, I hear 1.15 has some performance issues, so
We are now up to 60, and I go through them periodically and delete any that we don't need
I would cut down on plugins, mainly the ones you DONT need.
I have done that a whole bunch already. Getting rid of dynmap helped a ton
But, it still won't help optimization too much, not unless you get rid of plugins that aren't necessary, and if they are actually active during a lot of the server run time.
yeah Dynmap is bad for that.
Could you take a look and see if there are any that could be causing excessive lag as far as you know?
I would greatly appreciate it
I'm sure plugins like SkQuery/Skript dont help a lot; but I don't know.
I imagine you're using them so you can customize the server a little bit
They are dependencies for other plugins
say I have abstract class A that has sub classes B and C. I want to add a method to class A that returns itself again. However, I want B and C to have this same method but return themselves respectfully. How would I go about doing this?
And yes. Like "enhanced vanilla"
public <T extends A> T setTrue() {
setBoolean(true)
return this;
}``` is basically kinda what i want to accomplish
but i cant return this
Respectfully?
@wanton delta I don't know, cant you just return the abstract class?
i would want to return the class's instance
Okay I get you
well the problem is i wouldnt be bale to do B b = new B().setTrue()
try <? extends A>?
only other way i could think of doing it is making setTrue() abstract and add it to all subclasses
wildcard ? doesnt work... tried
? super A?
nope cant use wildcard in place of T
try t then
that method above is what i currently have, its just i cant return this
oh hmm
I haven't read this, but I looked up your issue and it said this blog post might have a resolution
only reason why i havent googled is because i have no clue how to word it lol
lol
On the PlayerChatTabCompleteEvent, is event.getLastToken() the string before?
e.g /about <TAB>, would about be the last token?
Would event.getChatMessage() get about then?
conventions usually imply that last is always the last in an array, whereas previous would return the one before
i think youre looking for PlayerCommandPreProcessEvent
if you're trying to limit the commands players can see when they tab, use PlayerCommandSendEvent
hmm i could do java public A setTrue() { setBoolean(true) return this; } but that requires me to cast java B b = (B) new B().setTrue();
is Minecraft's VarInt byte length maximum 5 inclusive or exclusive?
ok, it's kinda hurting my brain to work with packets
i would edge on the side of inclusive
oh wait what do you mean by inclusive or exclusive?
if you feel comfortable protocollib makes things 100x easier 😛
oh wait what do you mean by inclusive or exclusive?
@boreal tiger it should not be longer than 5 , so ( byteLength <= 5)
ah, I think its inclusive then
oh that one , thank you.
np :D
Can you edit event.getTabCompletions()?
what is the event
PlayerCommandSendEvent you can use event.getCommands() and add/remove what you please
PlayerChatTabCompleteEvent
I want to check if the command before they press tab is /about
PlayerChatTabCompleteEvent
I was going to check the getChatMessage() and then getTabCompletions().clear();
use TabCompleteEvent then
dont use ChatTabCompleteEvent
wont fire when using a command
I'm using 1.8
imo its not worth supporting 1.8
Oh, why?
its unsupported, any issues you have with viarewind or 1.8 wont be supported here
amount off ppl that play 1.15 is far greater than 1.8
found solution to my problem
i can do java public abstract class A<T extends A<T>> { protected abstract T getThis(); public T setTrue() { setBoolean(true); return getThis(); } }
Nice
Is there a Maven repo for BlocksHub?
When i try to compile my jar using github actions i get this error: Could not find artifact org.spigotmc:spigot:jar:1.15.2-R0.1-SNAPSHOT -> [Help 1]
What is a way to fix this?
Wow what is that monstrosity, Martoph? lol
The server jar is not available unless locally installed, 902
I'm not sure if GitHub has a way to build using BuildTools (going to imagine not) though most people do things through Jenkins afaik
Though ideally you'd depend against the API which is hosted on the repository
For some reason my saved itemstacks(in a configyaml) are all being set to air after an hour or so, anybody an idea why?
Yes, it works locally because the server jar is locally installed when running BuildTools
GitHub doesn't have that
mhm I was representing armor upgrades as follows:
private final ImmutableMap<ItemStack, Upgrade<ItemStack>> upgrades = ImmutableMap.of(
new ItemStack(Material.LEATHER_CHESTPLATE), new Upgrade<>(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 10),
new ItemStack(Material.CHAINMAIL_CHESTPLATE), new Upgrade<>(new ItemStack(Material.IRON_CHESTPLATE), 10),
new ItemStack(Material.IRON_CHESTPLATE), new Upgrade<>(new ItemStack(Material.DIAMOND_CHESTPLATE), 10)
);
However this approach does not allow me to check if the player is already in the last upgrade.
Any ideas how I could represent them?
I thought about implementing a directed weighted graph but was looking for other options before doing that
the reason why I was using a map is because It allowed me to easily look up the next upgrade
Would it not be easier to also then have a hashmap representing which armour upgrade they're on? (or just check what they're wearing?)
thats what I'm doing
I check what they're wearing
and use that to lookup the next update
np xD
mhm I think I can just change a bit what I was doing. if the key is not in the map I can just say its the latest upgrade 🤷♂️
they wont have access to other armor types so it should be fine
Guys is there any code to detect if player is on water, i mean, block.isLiquid() and block.getType() == Material.WATER is checking full block, not half blocks, you can stay on a kelp / seagrass / sea_pickle / coral being on water.
You would have to check for water as well as the waterlogged state
if (block.isLiquid() || (blockData instanceof Waterloggable && ((Waterloggable) blockData).isWaterlogged()))
(blockData being block.getData(), obviously)
choco do you have any idea how I could solve the problem I mentioned :S?
And in addition to what choco said, some blocks are waterlogged but don't have Waterloggable data
Any reason you're not using Materials here?
oops forgot about that yeah I can just switch to material I think
some blocks are waterlogged but don't have Waterloggable data
You're right. The fuck?
Why isn't kelp waterloggable?
Oh is kelp literally just always in water?
yeah
Well that's silly
from what i can tell the best you can do with the API is maintain your own list of 'always waterlogged' materials
for 1.15 block.getData() is deprecated 😒
.
getBlockData(), sorry
Ok so after some research I decided to go with a dedicated server. Right now it looks like reliablesite.net is my best option. Any advice on other good/better hosts, or any bad experiences with reliablesite.net?
and yea as far as I can tell, it's not even considered a liquid block in NMS, konsolas
@subtle blade would it be a bad idea to extend Upgrade and call it say NoFurtherUpgrades and point the last upgrade to that?
Now that's just silly
null is feeling a bit neglected rn
^
Point a diamond chestplate to null ;P
thanks hahaha lmao
Hi, does anyone know if I can somehow use the MineCraft selector tab completer for a command? I'm trying to use this method https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#selectEntities-org.bukkit.command.CommandSender-java.lang.String- to get the MineCraft selectors parsed. But can't seem to figure out how to tab complete it. Since I don't want to have to write it all my self. 🙂
hey, do someone knows why its not possible to connect to other servers on a bungeesystem?
i edit the spigot and paper.yml, entered online-mode to false at the server properties... but cant connect
Don't think there's tab completion available for that through Bukkit, Thom
Might be a way to expose it in the API though
To be completely honest, the tab completion API should be slightly improved. I'll have to look into that
I might have an idea for it tbh
Y'know what? I'm going to take a stab at a PR right now to try and expose that a bit better
Are you sure you entered the correct IP/Port in the config.yml in the bungee?
Can anyone tell me please why chest.getPersistentDataContainer(); not working?
What version are you using?
1.15.2
Importing the right Chest? There are three
You want org.bukkit.block.Chest, not org.bukkit.block.data.type.Chest or org.bukkit.material.Chest
o/ Happens a lot. Bukkit's got lots of duplicate classes from MaterialData, BlockState and BlockData
Just the nature of Bukkit's forwards compat
When creating a namespacedkey, it works like new NamespacedKey(plugin, plugin.getDescription().getName()); correct?
In my case, there is error in the first argument which is plugin.
What can I do about it?
The plugin.getDescription().getName() can just be whatever unique identifier you want. This is your key
I know, however, there is in the first argument
new NamespacedKey(plugin, "my_unique_key")
The first argument has to be an instance of your plugin's class. The one that extends JavaPlugin
import org.bukkit.plugin.java.JavaPlugin;
Yea, whatever class extends that, it should be an instance of it
If you're in your main class, you would pass this for instance
got it, thanks
so no one knows? 😄
Not familiar enough with Bungee to answer that question but if you're using a fork of Spigot, you're better off asking them for support as they may make changes we're unaware of
hm ok 😦
Can I use onBlockPlace with Chests from Bikkot?
private NamespacedKey owner_key = new NamespacedKey(plugin, "Lock Chest");
@subtle blade I moved it out of the main class to the one where I handle events, there're a listener
However, plugin has the error
@subtle blade guava's ImmutableMap doesn't support null values. should I add a static upgrade LAST_UPGRADE
and then I just compare if the value for a certain key is LAST_UPGRADE
Similar to how the conversation api handles the end of a conversation in a prompt
Hi guys,
I am making custom to plugin to teleport players to other servers after logging in on auth server.
I am correctly registering output/input channels in onEnable (bungeecord:main).
@EventHandler(ignoreCancelled = true)
public void onLogin(LoginEvent event) {
Player player = event.getPlayer();
User user = this.userService.getUser(player);
String server = Auth.getInstance().getConfig().getString("servers_for_areas." + user.getTeam().getId());
Bukkit.getScheduler().runTaskLater(Auth.getInstance(), () -> BungeeUtils.sendPlayerToServer(player, server), 20);
}```
public static void sendPlayerToServer(Player player, String server) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(server);
Log.info("Sending " + player.getName() + " to server: " + server + ".");
player.sendPluginMessage(Auth.getInstance(), "bungeecord:main", out.toByteArray());
}```
A player should be connected to server test-1, but nothing happens.
Does someone know what is wrong?
@humble widget Did you register your plugin? With for example: this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
As listed here. https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "bungeecord:main");```
I believe the channel should be BungeeCord not bungeecord:main
Channel names must be seperated with : on 1.13 or newer versions
Thus cannot use BungeeCord
Then Spigot did not update it's examples xD
That's true
And I found bungeecord:main here: https://wiki.vg/Plugin_channels#bungeecord:main
You're welcome to update them. You can contribute to wikis
It seems that whenever someone intiates a coinflip on my coinflipplugin, the servers tps drops a little
any ideas?
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle();
GameProfile gameprofile = new GameProfile(UUID.randomUUID(), "hithere");
WorldServer world = ((CraftWorld) p.getLocation().getWorld()).getHandle();
EntityPlayer entity = new NPCEntity(playerList.getServer(), world, gameprofile,
new PlayerInteractManager(world));
PlayerConnection playerConnection = new PlayerConnection(playerList.getServer(), new DummyNetworkManager(EnumProtocolDirection.SERVERBOUND), entity);
entity.setPosition(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
entity.playerConnection = playerConnection;
System.out.println("Spawning...");
world.addEntity(entity, SpawnReason.CUSTOM);
Can someone help me, my fake player isn't showing up
@humble widget It seems to work with BungeeCord when I'm trying on my PC. But not with bungeecord:main. 🤔
Running a 1.15.2 server with one of the newest BungeeCord versions.
🤷♀️
- spigot
It's weird though, because bungeecord:main should indeed work
Im really confused, i saved item stacks to my configyaml using
for (int x = 0; x < 27; x++) {
chestloot.set("loot." + args[0].toString() + "." + x , chestinv[x]);
}
saveChestLoot():
but after a few minutes it turns to air in the config file
iron:
'0':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
anyone an idea how this is possible?
You have to clone the item stack using .clone() I think
what do you mean exactly?
chestinv is a chestinventory
at first it is being set good to the config
hi!
is there way I can forbid interaction with player and impact with player avoiding events?
now I tried to register ALL player events and cancel those which are not chat command event, but I realized that I can't register ALL events except chatcommand event
If that's important - I'm trying to realize simple authorization plugin and I want to "freeze" player until he sign in\sign up
Why would you avoid events
Just use a
final Set<Player> unauthorized = Collections.newSetFromMap(new IdentityHashMap<>();```
Put them in the set if they're not registered and then check that on events
and as soon as they register/login remove them
@narrow crypt beacuse you are saving the ItemStack object into the file
Just only /balance
You need save the itemstack like this
Name:
type:
enchantments
-
-
etc
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
GameProfile profile = new GameProfile(UUID.randomUUID(), name);
PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld);
EntityPlayer entityPlayer = new NPCEntity(nmsServer, nmsWorld, profile, interactManager);
new PlayerConnection(nmsServer, new DummyNetworkManager(EnumProtocolDirection.CLIENTBOUND), entityPlayer);
entityPlayer.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(),
location.getPitch());
nmsWorld.addEntity(entityPlayer);
new BukkitRunnable() {
@Override
public void run() {
nmsWorld.players.remove(entityPlayer);
}
}.runTaskTimer(main, 20L, 20L);
PacketPlayOutPlayerInfo playerInfoAdd = new PacketPlayOutPlayerInfo(
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
PacketPlayOutNamedEntitySpawn namedEntitySpawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
PacketPlayOutEntityHeadRotation headRotation = new PacketPlayOutEntityHeadRotation(entityPlayer,
(byte) ((location.getYaw() * 256f) / 360f));
Bukkit.getOnlinePlayers().forEach(player -> {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(playerInfoAdd);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(namedEntitySpawn);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(headRotation);
});
Hey guys, so I have this to spawn my custom player, but how do I create it without packets? Because when the player rejoins the fake player dissapears and I don't want to have to store their locations
You can't create player without packets
also it's not a custom player
its a NPC packet
@brisk mango How would i save the items then
oh
Also i'd suggest using a bin @frigid ember
i got told to use this:
for (int x :... inventoryslots) { config.set("%uuid%.items." + x, inventorySlots[x])
That type of thing, basically
so that is itemstacks
Why are you storing it into a file anyway?
cause i need to save it
what exactly are you trying to accoplish
and it needs to be saved after a restart too
String headerT = "§7You\'re playing on §2§lMineTropical§7!";
String footerT = "§7§oCustom Coded Survival Experience";
IChatBaseComponent header = IChatBaseComponent.ChatSerializer.a("{text: '" + headerT + "'}");
IChatBaseComponent footer = IChatBaseComponent.ChatSerializer.a("{text: '" + footerT + "'}");
This seems throw an error as an issue with the JSON
Why not save it into a Map<Inventory, List<ItemStack>> and save it onDisable()
people look at a chest and can save the contents to the configyaml, then when lightning hits the ground a chest with those items spawn
i also tried serialization
Why serialization
cause someone told me to
Just save it into Map<Inventory, List<ItemStack>>
Don't follow noobie dev advice then
Does someone know how to block commands for specified plugins
I have 2 plugins with the same command, and i want that one plugin the command will be blocked
I dont want that the whole command will blocked, just only for one plugin
PlayerCommandPreprocessEvent
You can't just remove it from plugin.yml because if it's registered in the main class i'd throw a null pointer
@turbid vapor remove it in there plugin.yml
@narrow crypt where can i fnd that?
decompile the plugin
Don't remove it from the @turbid vapor
You can't just remove it from plugin.yml because if it's registered in the main class i'd throw a null pointer
@narrow crypt
I cant write java, so i cant make a plugin for it
oh
this is for all questions
i suggest looking at r/admincraft
not just dev
or their discord
~so feel free to ask away
learn java is the way to do it
Guys how do I make path finding goals on an EntityPlayer
NMS
I knew that, but how
Oh, for like NPCs?
Yeah
bruh
Ahaha
hello, where download version 1.12 4.4.4???
Or maybe this for the minimum https://www.spigotmc.org/resources/citizens.13811/ @frigid ember
@remote sluice use buildtools https://www.spigotmc.org/wiki/buildtools/
1.12(top)
Code (version112 (Unknown Language)):
java -jar BuildTools.jar --rev 1.12
Will build a CraftBukkit and Spigot jar for 1.12
Change Log: Mojang | Stash | Jenkins
no link download
@remote sluice you need to follow the process described on the page
There isn't a convenient link to download the spigot 1.12 jar
You have to build the jar on your computer
Perzan, can I use your help in something?
Sure, if I can help
private NamespacedKey owner_key = new NamespacedKey(plugin, "Lock chest");
why is the plugin argument marked as an error?
"plugin can't be resolved as a variable"
Is owner_key in your plugin's main class?
There is no variable called plugin on there I bet
Nope, but even modifying it to the main class doesn't make it work
You will need to have a variable of the type Plugin called plugin somewhere on the page
It also cannot be null
@spring sapphire I suggest you to learn java
also plugin will be null if you do it like this
What does the class's constructor look like?
Shouldn't it take the Plugin from library JavaPlugin of bukkit?
Wdym
For that argument, you need to reference your plugin's instance
We can static abuse if you want lol
public final class Main extends JavaPlugin {
@Override public void onEnable() { }
}
public class MyClass {
private final Main plugin;
public MyClass(Main plugin) { this.plugin = plugin; }
private NameSpacedKey owner_key;
void myMethod() {
owner_key = new NamespacedKey(plugin, "Lock Chest");
}
}
No never static abuse
Should always use dep inj for main instance
not singletons
Use that layout ^ @spring sapphire
Dep inj is more flexible/testable
I was thinking JavaPlugin.getInstance(<your plugin main class>.class)
No that is wrong lol
Lol quick n dirty, but not good practice
you also have JavaPlugin.getPlugin(class);
java -jar BuildTools.jar --rev 1.12 in start.bat no good 😦
didnt see any difference between that and injection yet
isnt buildtools used with gitbash?
last version from 1.12 spigot
Try putting @pause on the last line of your batch file
Run it again and see what it says
@brisk mango Do I have to use the namespacedkey on the Main Class?
no
i need the latest version 1.12! Thanks!
no understand...........
please give me comand for start.bat
Please do not run in a path with special characters!
C:\Users\Ionut\Desktop\Folder nou (2)>PAUSE
Press any key to continue . . .
it says it lol
I removed the inner class.
how to paste code here?
private final Events plugin;
public Events(Events plugin) { this.plugin = plugin; }
private NamespacedKey owner_key = new NamespacedKey(plugin, "Locking Chests");
Same error.
@brisk mango
but I should register all events and cancel events those are not a chat command event, ain't it?
that's too much work for many events
Did I understand you right?
If im logging into my mongodb whenever someone breaks a block, should I make that async ex: new Thread(() -> { databaseApi.incOresMined(databaseApi.getSimplePlayerByUUID(event.getPlayer().getUniqueId().toString())); }).start();
so im saving itemstacks to my yaml but after 20 minutes they are turned to air in the config, no events happened in the meantime with the plugin:
loot:
kist1:
'4':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
amount: 0
'10':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
amount: 0
'11':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
amount: 0
'16':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
amount: 0
'22':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
amount: 0
'24':
==: org.bukkit.inventory.ItemStack
v: 2230
type: AIR
amount: 0
PlayerInteractEvent
i have declared api-version: 1.15
at first they just are noted correctly
but they just change out of nowhere
anybody an idea how this is possible?
@spring sapphire assign the owner_key inside the constructor
@patent monolith no
You can't assign it inside the constructor
since it takes the plugin variable
while that's being initialised in the constructor
that's why there's a method for it
public class MyClass {
private final Events plugin;
public MyClass(Events plugin) { this.plugin = plugin; }
private NamespacedKey owner_key;
void myMethod() {
owner_key = new NamespacedKey(plugin, "Lock Chest");
}
}}
@narrow crypt I told you how to do it so stop asking again
yes, like this
What
why do you have inner class
im asking for another method to do it
``
public class Events implements Listener {
public class MyClass {
``
how do I use color codes in spigot.yml? When I try to use & it crashes my server with this message -https://hastebin.com/uwahogebep.sql (I changed unknows command)
@narrow crypt There's no other method if you're saving it into file
Should be like this?
private final Events plugin;
public Events(Events plugin) { this.plugin = plugin; }
private NamespacedKey owner_key;
void myMethod() {
owner_key = new NamespacedKey(plugin, "Lock Chest");
}
````
Well imma hop on my pc
I don't think that can be done Async but you can try it @agile rock
why doesnt anybody do it like that then .. :(
What is the error
Constructor NamespacedKey is not defined
@brisk mango I was told to make all database calls async so it dosent disturb the main thread or something like that
On my phone in bed rn lol
Well it's not defined then?
Ill hop on my pc
@brisk mango I was told to make all database calls async so it dosent disturd the main thread or something like that
@agile rock You should, yes.
Oh hello my old friend
Helloo.
are we going to take this discord over yes?
(:
Ok, is new Thread(() -> {// database call}).start(); a proper way to do it?
Creating threads is outdated but yes you can
Try bukkitrunnable async
D:
use BukkitScheduler/ExecutorService
Eclipse is suggesting changing plugin to String to fix it
lol
I personally like CompletableFuture.runAsync(...). Depending on what I'm doing, CompletableFuture.supplyAsync(...) could come in handy too.
However, Namespacedkey doesn't take a string in the first argument
It takes plugin
That means, dont use eclipse
Well, whatever you use, make sure you make it so it wont run if your plugin is disabled
private final Events plugin;
public Events(Events plugin) { this.plugin = plugin;
owner_key = new NamespacedKey(plugin, "Locking Chests");
}
Is there anything wrong with that?
Despite the last }
Temedy, he's using the one passed.
Not this.plugin so that's fine.
It would've been initialized anyways since he initializes it above the owner_key field initialization.
Where is owner_key
private final Main plugin;
public Events(Main plugin) {
this.plugin = plugin;
owner_key = new NamespacedKey(plugin, "Locking Chests");
}
But doing this can cause null pointers
If the plugin object passed is null, sure.
I'm not sure about the whole situation though. What is the actual error? I haven't seen it.
In that light, I suggest doing Objects.requireNonNull(plugin, "plugin")
For other params in the future as well
lol
k welp, im on my pc now
temedy, still same
private final Events plugin;
public Events(Events plugin) { this.plugin = plugin;
owner_key = new NamespacedKey(plugin, "Locking Chests");
}
private NamespacedKey owner_key;}```
What same?
One thing that comes with the spigot API is Guava and I absolutely love it.
gson and yaml are also nice
The constructor NamespacedKey is undefined
suggesting changing plugin to String which doesn't make sense
I just realized
You could be using the 1.15.2 dep and it tells you to use plugin, string but running it on for example 1.8.8 would be string iirc.
you are referencing Events as a plugin....
in the parameter
but its that own class
Lmao..
welp
public void onPlayerJoin(PlayerJoinEvent event) {
// Checks if player is new, if so it will create a new SimplePlayer and log the player into the database
if(!event.getPlayer().hasPlayedBefore() || (databaseApi.getSimplePlayerByUUID(event.getPlayer().getUniqueId().toString()) == null)) {
plugin.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
databaseApi.createSimplePlayer(event.getPlayer().getUniqueId().toString(), LocalDateTime.now().toString(), System.currentTimeMillis());
}
});
}
}``` Would this be the proper use of BukkitScheduler?
i had to paste this into my ide to notice that
private final ChestLock plugin;
public Events(ChestLock plugin) { this.plugin = plugin;
owner_key = new NamespacedKey(plugin, "Locking Chests");
}```
So it should be like this
considering ChestLock is the main
correct?
yeah
https://www.youtube.com/watch?v=QdV-3OtXcPY
omg is very hard for download a version.......
i finish, tahnks
I think I did :))
@rigid nacelle @brisk mango Could u guys take a look at how I used the bukkitscheduler above please?
new BukkitRunnable() {
@Override
public void run() {
// your code
}
}.runTaskAsynchronously(plugin);
oh, is that the same as plugin.getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { databaseApi.createSimplePlayer(event.getPlayer().getUniqueId().toString(), LocalDateTime.now().toString(), System.currentTimeMillis()); } });
yeah
gotcha
should work either way
@brisk mango Would you recommend that I use the one I put above^
?
to run the bukkit runnable task?
ah
Perzan, I can't my events handler the plugin folder?
Because after I added ```public class EventsChest implements Listener {
private final ChestLock plugin;
public EventsChest(ChestLock plugin) { this.plugin = plugin;
owner_key = new NamespacedKey(plugin, "Locking Chests");
}``` to my Events folder
the getServer().getPluginManager().registerEvents(new EventsChest(), this); gave an error in the main
new EventsChest(this)
if you look at the constructor definition in the EventsChest class, it takes an instance of your plugin
public void onEnable() { getServer().getPluginManager().registerEvents(new EventsChest(this), this); }
Now, it's working
using this is like a special variable in java that references the instance that your code is in
cool
So without removing this, the argument is getting all of the instances ?
Depending on the use case @brisk mango it is acceptable to use either one
using^
No it's not
How can you get which dealt damage?
It's not getting any
which entity*