#help-development
1 messages · Page 1947 of 1
Clock isn't block but isn't damageable
hey smile, I've tried using Player#getVelocity instead of updating a HashMap on PlayerMoveEvent and the values were too different to be considered usable, I just made the calculation in the event async and am updating the map with it just when needed
I reckon that this is a better and more lightweight solution since I can't use the new method
?xy
Asking about your attempted solution rather than your actual problem
What is the goal here
I've already explained it before, I'm too lazy to repeat myself haha let me find the messages
Using the velocity has to work. Doing all of that async makes no sense as its potentially happening every tick.
Doing it async might lead to false results being read from the map.
explanation starts from here
any plugs that completly remove beds from the server?
the problem is that the difference is really high
new: -0.04258525346874389 0.0030162615090425808 -0.14383933002623553```
Could you show your code? Also as smile said this shouldn't be done async
I've never done anything async so please tell me if this is useless and/or bad:
@EventHandler
public void onMove(PlayerMoveEvent event) {
Location start = event.getFrom(), end = event.getTo();
Bukkit.getScheduler().runTaskAsynchronously(this.manager.getPlugin(), () -> {
start.subtract(end);
start.setY(start.getY() / 2.0);
this.finalSpeed = start.length();
});
}
the calculation takes place async, map gets updated in the EntityDamageByEntityEvent
can anyone provide a worledt plugin for 1.8.9 which can load a heavy schematic
i don't think it needs to be async
Use a non ancient version and the latest version of fawe
i am unable to find can you pls provide
the only reason why I made it async is because it's used a lot
*A non ancient version of Spigot that is
This is useless and also dangerous. Your finalSpeed is not synchronized.
i didnt understand
should I remove the scheduler then and just update the map there or return a double and update the map using the double only when needed?
thank you for letting me know
How to event.setCancelled(true); but with a small delay so you can not spam?
You dont even need to calculate the length on every event.
Just maintain the last 2 or 3 Locations. Then when you need it you can calculate the vectors length between them.
A good collection type for this is the Deque
thank you, I will get onto it
Might not work 100% but you get the idea. getLastMoveVector could also be nicer if you use ArrayDeqeue in the Map because then you would have index access and dont need that re-insertion.
private final Map<UUID, Deque<Location>> lastLocations = new HashMap<>();
@EventHandler
public void onQuit(final PlayerQuitEvent event) {
this.lastLocations.remove(event.getPlayer().getUniqueId());
}
@EventHandler
public void onMove(final PlayerMoveEvent event) {
final UUID playerID = event.getPlayer().getUniqueId();
final Deque<Location> locations = this.lastLocations.computeIfAbsent(playerID, key -> new ArrayDeque<>());
if (locations.size() == 2) {
locations.poll();
}
locations.add(event.getTo());
}
public Vector getLastMoveVector(final UUID playerID) {
final Deque<Location> locations = this.lastLocations.get(playerID);
if (locations == null) {
return null;
}
final Location last = locations.poll();
final Location secondLast = locations.poll();
final Vector vector = last.toVector().subtract(secondLast.toVector());
locations.add(last);
locations.add(secondLast);
return vector;
}
holy, thank you for providing this
also arent u interacting with bukkit here
which shouldnt be done async?
or am i missing something
You can do some stuff async
But if you need to ask what, you probably aren’t ready :p
"SELECT * FROM {table} WHERE player_uuid = '" + uuid.toString() + "'"
java.sql.SQLException: Invalid utf8mb4 character string: 'ACED00' ?? How is a UUID not utf8?
use prepared statements
please use ?'s
Prepared statements plz
Doesn't work either
can anyone provide a worledt plugin for 1.8.9 which can load a heavy schematic
McEdit
Can someone pls help me? I know that the solution is very easy but I forgot how to do it.
1.8.9 😳
what are you trying to do more specific?
You cant delay cancelling an event
you can use cooldowns maybe depending on what you're doin
Yeah I would use a simple map with a time stamp (long)
here:
` @EventHandler
public void onBlockBreak (BlockBreakEvent event) {
Player player = event.getPlayer();
if(player.getGameMode() == GameMode.CREATIVE) {
return;
}
else {
event.setCancelled(true);
}
}`
👀
its fine btw
yeah, I agree
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if(event.getPlayer().getGameMode() == GameMode.CREATIVE)) return;
event.setCancelled(true);
}``` @grand venture
u cant delay cancelling an event
if(event.getPlayer().getGameMode() != GameMode.CREATIVE)) event.setCancelled(true) 🤡
as the event wouldve already happened
i guess its opinions
i died
if(event.getPlayer().getGameMode() == GameMode.CREATIVE)) {
return;
}
pls 😄
I don’t really like using {} just for a return
if you are going to indent it, at least indent it with 4 spaces \j
Think of the lines you can save
2 spaces master race
i always use {} except for returns
I mean, if I have a rule I'd (in theory) apply to everywhere and not have nigh-useless exceptions
Google style guide uses 2 space indents 👀
I use new lines
Meanwhile intelliJ-decompiler uses 3 spaces by default
Yeah, wish there actually were some sort of convention for this
Apart from obviously not having 0
I guess tabs could be it?
Myeah, to some extent that’s probably as good as it gets
having 0 spaces as indent 🤡
/* this is an indent */
/* this is a ||cow 🐮|| */

/* this is a ||conclure
|| */
yeaa
If you can’t handle me at my OwO
Then you don’t deserve me at my UwU
Man I have some serious issues figuring out how I should structure data. In a SQL DB I could have 1 table per currency, or I could have 1 table with all the currencies. Same issue for banks. If anyone has any insight they want to supply I'd gladly appreciate it lol.
PS should be said, I will be implementing a similar flat file system, so the same data model goes for that as well.
There was an optional module in my uni for just that. I skipped it.
then it would be pretty much not possible
i would store a foreign key to the currency id for the user
so a table with user ids and currency ids in a table, amount might be there too
1v1 me
ah
I think one table per currency would be the most relational approach
yeah
You want my giant book called “SQL queries for mere mortals?”
i just had database design lesson in school 
Yes please 
You could also use an orm and dont worry about it
im just seeing a currency and an user as two different entities
Yes
thats alot of yea
How to disable /ver /version /bukkit:ver and /bukkit:version, because when i try to make it my own command it still works and shows the version.
thanks
commands.yml
PlayerCommandPreprocessEvent in combination with a blacklist/whitelist
Oh or you go traditional
public void setEqupiment(EnumWrappers.ItemSlot slot, ItemStack item) {
this.equipment.add(new Pair<>(slot, item));
}
public final List<Pair<EnumWrappers.ItemSlot, ItemStack>> equipment;
this.equipment = Lists.newArrayList();
if(this.equipment.size() > 0) {
PacketContainer packettt = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
packett.getIntegers().write(0, this.entityId);
packett.getSlotStackPairLists().write(0, equipment);
main.protocolManager.sendServerPacket(viewer, packettt);
}
This is what I'm doing
Im using playercommandpreprocess how to check what commadn they wrote ?
is PlayerTeleportEvent only for going through nether portals? Or will other plugins also cause that to fire when teleporting players
If anyone could help me out in the thread that would be great! 🙂
https://discord.com/channels/690411863766466590/941665462062829588
How do i remove spigot/bukkit commands from / <tab>
this is absolutely perfect, it works great! thank you
Im assuming teleportcause.Command is only when a vanilla command causes the teleport? is that true or not
is a weakreference to store something, but make it able to be gc'd when possible?
or something
I just want to hide all /minecraft: commands that show up and a certain plugin
you can modify the completions i guess
the command map is sent at login and other times. remove permissions for teh commands you don;t want players to see
its not an immutable list
He is talkign about commands not tab completion
he wants to hide it
to control what commands are seen is controled by permissions
^ that too
but on a / <tab>
bukkit shows up on / <tab>
How?
I want to be able to allow tab completion inside of commands but not on / <tab>
How do you cancel it
you cant
@neon minnow
I am talking about PlayerChatTabCompleteEvent using tab on / <Tab>
commands that are shown in / <TAB> are controled via permissions. Ones which are not YOU remove in the PlayerCommandSendEvent
update your Spigot
No
Ah 1.8
Then you are out of luck, unless you use reflection and modify the command map
No idea, I think the tab complete event fires for base commands back then
Doesn’t matter tho, we don’t support 1.8
fixed w/ PlayerChatTabCompleteEvent
I fixed it with PlayerChatTabCompleteEvent.
so....
What version of Java do I use? Is it java 8 for anything below 1.18 then java 17 for 1.18?
1.17 used 16
I keep getting this error Could not pass event PlayerJoinEvent to AltAlerter v1.15-SNAPSHOT org.bukkit.event.EventException: null
that is caused by java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @8506a43
Here is the code that uses Gson https://paste.md-5.net/nagoquyugi.java
Here is the error in full https://paste.md-5.net/ubeloxumok.cs
I use the Gson that comes with Minecraft, 2.8.8
if your plugin will be compatible with version 1.8x and up (except the last version) i would use java 8 base
Do not spam, be pacient
what spam?
I'm planning just to make something for latest version
for 1.18.1
For 1.18x i would use the last Java version, prob java 17
Your welcome, im not profesional but i try to do my best helping
Something in your PlayerInfo class cant be serialized. Show it pls.
InetAddress needs a custom serializer to be registered
Lmao i love networking i touched smth on my bedroom router and now the pages are not loaded
Hahaha i will have be entreteined today
Thanks, I'll use Base64 strings
Does GSON by now already ship an inbuild UUID adapter ?
iiirc yes
Isnt possible to do UUID#toString() and UUID#fromString() ?
gc will clear it when it's weakly reachable
wait thats an old message
it is but for gson to do that automatically you'd either need an adapter or gson has to do that out of the box
Eyyyy
and gson does that
very pog
?
Now you sent that, why you cannot save uuid? If it a simple string
🤔
Hi guys! i want to make armor stand pets (like the hypixel skyblock ones) but i don't know how to make it follow the player
track the location and let it follow by smooth teleports 
maybe an upcoming lib can help (cought @opal juniper)
Custom AI goals
PathFinderGoalFollowEntity?
yes that
for armorstands?
i dunno
is md5 the only spigot dev
@opal juniper you a good java programmer?
Im ok yes
yoo
i have a proposal
pls lemme call u on vc
lets just have a chill chat real quick
@opal juniper
omg you wanna marry him?? 😍
uhm why lol
It can’t
I cant seem to block the /version command, im trying to add a /version command but it does not override it
Just remove the perm?
how can i prevent the database call to load a player not being finished when the player joins?
If you call it in the APPLE it should block login until it’s done
ye but some people said to not load stuff in that event
and im also checking the player has played before
to either create a new profile or load it
How??
Negate it with a perm plugin
this isnt probably the right time to get an offlineplayer object
Probably not
When do you need to use OfflinePlayer object?
My loadPlayer is able to handle players that don’t exist
show me 👀
It just creates a new user and then attempts to apply the data from the database
If there is no data, it just won’t apply anything
ah wait i understand
so checking if the player has played isnt needed anymore
but you can end up with some unneccessary db calls?
That why i work over cache
I mean it’ll still do a database call and just return nothing
But meh, it’s async anyway
it takes time 💀
- OnPlayerJoin -> Check cache
- If player exists on database, load it to cache
- If data doesnt exists on database, create his cache
- OnPlayerQuit -> Save cache to db
This is how i work
shouldnt i load on login?
Only saving on quit, oof
i dont have any code yet for loading
And when plugin goes down i save the cache
If you have better way let me know
When server crashes should disable each plugin, so the cache save everything to db?
i was thinking about loading the player in login instead of join but the login event might be cancelled so i can end up with some unneccesary db calls i guess
idk if join is going to load it quickly enough
and idk if its blocking
it is
but the db call is async
but one unnecessary db call isn't too bad
A question?
no a statement
well
Do you agree with this?
i can use a CompletableFuture::join but ye
i save my data when it gets modified
^
That why cache exists...
usually you wanna save when a set of modifications have been applied verano
and flush to DB every ehhh 5 mins ?
else you're risking a data loss
if (command == "version") { e.isCancelled = true }
this doesnt block version command
that required some overcompliation so we did some sort of bulk saves system (aka editors)
string comparison with ==
command.equals on string
Why?
Depends a lot on the crash if your plugin still gets the onDisable
I have tried many to do a data loss and i couldnt do it
oh eyyy conclure
God do I hate spigot's config API. You can't expect it to work reliable. I hope they improved it in newer versions
diskord
someone for you @ivory sleet
Don't click on it! This is a scam
Configurate!
wew are you kidding
I was told on a thread that if spigot server crashes or goes down by stop command each plugin is disable, so onDisable method it called
It doesn't get called when it crashes
System.exit(0)
?
idk
👀
what message?
The scam nitro link
he was even verified lol
Yeah
I think that you can be banned from Website right? Or i am wrong¿?
im just thinking whyy
What this?
some of those bots or scams also hijack your dc account in some occasions :p
Mos ttimes its take your token
How do you guys feel about this method of delaying teleporting https://paste.md-5.net/hucowirife.cs
me imagining what happend wen the server crashes 😳
it's the same
Seems reasonable
I tried closing the server screen of the server and the plugin steal saved the last data
So i dont know
it gets handled when closing it
So if i have an API module that the users are able to depend on, and then i wanted to make the lib shadeable, how would i do that? atm i keep only the API available to the users to depend on but i wanted to try and have it shadeable rather than just a plugin lib
Ty Coll for the feedback
try ctrl + c
And something more dangerous, doing a vps reboot with the server screen opened, and server data steal saved
it forces to stop a program running on a console
You can simply add it like any other library / dependency
anyways, it's not possible for you to handle all of those exceptional cases (I say it by experience working on a similar system), sometimes you just have to deal with it
Imagine if the server somehow always ran onDisable
Pull the power cord? Nah it’s fine
saving every x time is what works the best, but make sure your db can handle that (and use batch statements)
If using maven you can shade the dependency using maven-shade-plugin
Thats not what i mean
So explain more please i didnt catch what trying to do get mixed
other people only have access to the API module, where i then have another module that impl's that which runs on the server. because of this i was wondering if it is possible to shade it
I just save on every change
Ohmn idk why its saved data when rebooted the vps
@opal juniper mvn install
idk 🐗
then import it
using mongo, and saving thousands of document Hmn != good performance
as a dependency
This is why we have sql
its for other people to use, not me. i wanted to know if i could make it so that it was shadeable without exposing the impl to the user
host it on github, make a release and use jitpck
jitpack
SQL = sucks me && relational tables == sucks
yes that is how you would host the API, but that isnt what i mean
🤨
🤔 what do you mean then
I use Mongo + ORM and best thing ever created
Yeah saving on every change on mongo should still be fine
It’s a database, it’s kinda designed for that
If you're having a problem with that you've just designed it wrong
There is a public API module that will be hosted online and users can depend and dev against. Currently, i then have a module that impl's the API and runs as a plugin dependency on the server. This is annoying tho and so i was wondering if there was a way for the users to shade the "main" without the impl being with the API
I have a connection pool and a dedicated thread pool for saving
I don’t think it will cause issues unless you try to run it on a server with thousands of players
public class Database implements Serializable {
@Serial
private static transient final long serialVersionUID = -1681012206529286330L;
public static final String filePath = "database.ser";
private ItemStack[] activeItems;
private ItemStack[] collectedItems;
private ItemStack[] disabledItems;
String name = "Test";
...
public boolean saveData(String filePath) {
Bukkit.getServer().getLogger().log(Level.INFO, "Trying to save...");
try {
FileOutputStream fileOut = new FileOutputStream(filePath);
BukkitObjectOutputStream out = new BukkitObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
Bukkit.getServer().getLogger().log(Level.INFO, "Data saved!");
return true;
} catch (Exception e) {
e.printStackTrace();
Bukkit.getServer().getLogger().log(Level.INFO, "!SAVING FAILED!");
return false;
}
}
...
}
Hey,
im trying to save the entire Database Class with the active,collected and disabledItems arrays into a file. Is this the right way to go about it? Its loosely based on this https://www.spigotmc.org/wiki/save-load-data-files/
If i save the data this way no file gets created :/ Does anyone see why ?
aa
Even tho, it should be done in the least possible queries/inserts to avoid problems. If you manage to send the data of all the players in a single insert then you're gucci
Im not an database structure/designer, so if it designed wrong that problem of the Buiness owner
How is it possible that config.get("data", null) always returns null, and config.get("data") only returns null when there's actually none. Ffs spigot
I really dont understand what you are trying to achieve. Why is the API hosted, if so you would have The api functionallity hosted on the server and then make an library to send http requests to that API hosted on the server, that library would have everything that the end user needs to interact with the api without having to send http requests themselves
so basically a wrapper for your api
that prople could use a dependency that just calls ur api
I didnt udnerstand too what he was trying to do
Sorry for interrupting this chat ^^
you scared me
Because the meaning of API keyword for spigot most of time its a jar dependency that allow you to get data.
And for other people its just to use it in paralel with a Rest API
It only updates the modified data, not all of it
Check you have created the actual config file. If the default value is not specified then is returned the value that's in the plugin's default YAML
My first work when started was to make an api based on Rest API. So basically i was connecting their custom rest api to a plugin on multi servers
Saving Data to File Problem
is the playerjoin event blocking for database stuff on a completablefuture?
well
the whole thing about a CF is that it isnt blocking
but playerjoinevent
is
blocking, but players can time out
yea im trying to block the player from joining until data is loaded
start the request on the pre login event
so starting on asyncprelogin?
players might be disallowed from joining later on
but ye
could end up with a unneccesary request but thats the least i have to worry about i think
also async and CompletableFuture::join might that give problems?
a single request to a database that selects a single record that is properly indexed on the key is not an issue
Ye
yes, np
lemme write some code
me and concurrency is asking for problems
well concurrency is a bitch and atomicity is just horrific
also, if you can avoid using join, do it, because joining I guess merges the threads (or something similar idk what's called) and it's kinda expensive operation. Try using the thenAccept, thenApply, thenCompose & whenComplete methods the CF class provides you
you said something earlier about the user and the snapshot remember?
yes that was just to avoid mutability as much as possible
to avoid concurrency update problems
so i would only load the snapshot as it holds the data?
and fields
you do it a bit differently
if you want the object just to be mutable when it's loaded you can try using a CountDownLatch btw (very useful class)
Are the fields in classes like EntityLiving explained somewhere?
mye cdl, semaphores, cyclicbarrier and phaser all amazing framework classes
in what way?
i could load the snapshot and apply it to the user
np
if its what i think it is its probably 10 or something
Depends on what default
Generally 0, players have a 60 tick spawn invulnerablility
Hm, So i have a prio queue of node objects. I want to check if it already contains a node at a certain position and if so, get that node. idk really how to "get" from a queue tho as i thought it wasnt possible
ok i liked it might be 20, or between 0 and 20
mayb u could traverse the queue
if thats even possible
might be able to use an iterator() method or something
well i dont think ur meant to have to traverse them
hi, in craftbukkit contributing is said that the changes need to be for java 7, is this actual? or i can make changes for java 17 already?
Sounds like that's outdated
java 8 iirc is what you wanna lean towards iirc Choco mentioned
that's why i asked
id imagine java 8 bc i think 1.8 needed it and thats the earliest? available spigot
not that any changes get made to 1.8 still but
why do you need to do this?
yeah idk i was now thinking it and i realised it wouldnt even work
well it would
just not the way you think it would
if you really need to know if something exists in a queue, you need to give your objects id's
and then as you insert into the queue you also keep a list or hashmap of said object id's
then when the queue gets to it you know if it needs to do something or just discard it
your only option for gettings objects in a queue is to iterate over the queue which probably isn't going to be ideal most times lol
unless you implement your own kind of queue to allow this of course
So I'm trying to cast TileEntitySkull, however I am getting a 'java.lang.IllegalArgumentException: object is not an instance of declaring class'
"l" being the location of the block and version being "v1_18_R1"
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + plugin.version.substring(plugin.version.lastIndexOf('.') + 1) + ".CraftWorld");
Class<?> anotherClazz = (Class<?>) clazz.cast(l.getWorld()).getClass().getMethod("getHandle").invoke(clazz);
TileEntitySkull skullTile = (TileEntitySkull) anotherClazz.getMethod("getTileEntity").invoke(new BlockPosition(l.getX(), l.getY(), l.getZ()));
It seems to cause an error on the second line within these 3 lines of code within console
you are casting the result of getHandle to a class ?
probably going to need to use blockstate
he's getting a world handle from a class too
hey guy's I've been trying to save data to a file but I can't do it it doesn't work the file isn't even showing up here is my code: ```
public class ReportsData {
private File _file;
private Gson _gson;
public ReportsData() {
_file = new File("data.cum");
try {
if (_file.createNewFile()) {
System.out.println("File created: " + _file.getName());
} else {
System.out.println("File already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
_gson = new Gson();
}
public void saveToFile(Object object) throws IOException {
FileWriter fileWriter = new FileWriter(_file);
String toJson = _gson.toJson(object);
_gson.toJson(object, fileWriter);
fileWriter.close();
}
public Object getFromFile() throws FileNotFoundException {
FileReader fileReader = new FileReader(_file);
Type type = new TypeToken<ArrayList<Report>>(){}.getType();
ArrayList<Report> clonedMap = _gson.fromJson(fileReader, type);
return clonedMap;
}
```
this isnt C#
trying to change a skull texture and place it as a block
spigot released a profile API
that can manage custom textures for you
it is available in 1.18
did anyone write a nice forum tutorial for it yet ?
that we could link
i figured out how to put it in an itemstack, but not for a block, for a block it was nms
declaration: package: org.bukkit.block, interface: Skull
so using using block.setData one would change a skull head to a texture?
what ?
something liek this?
?paste
smh
you can literally call the method I linked on the skull block state
and then update the block state
and it was that simple?
conclure you forgot a space
pain
🤡
Heyo
I'm new to Spigot plugin Development
Can someone help me figure out how to check if a player broke a certain block
blockbreakevent ?
Spigot is event driven.
You need to register a listener that contains an eventhandler method for the BlockBreakEvent
event.getBlock() no?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@tardy delta anyhow, both are doable, so I am not gonna tell you to do x or y
but the latter is a bit more scalable
package me.miney.starterobjectives.listeners;
import me.miney.starterobjectives.Main;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class BlockBreakListener implements Listener {
@SuppressWarnings("unused")
private Main plugin;
public BlockBreakListener() {
this.plugin = plugin;
}
private ItemStack dirt = new ItemStack(Material.DIRT,1);
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
World world = block.getWorld();
Player p = e.getPlayer();
if(Idk what to put here) {
}
}
}
so i should load the snapshot from the database if im working with snapshots instead of individual references?
Yessir
block.getType() == Material.DIRT
done
or something like that
cafe babe should just agressively throw every message into a paste that is longer than 5 lines

Ohh
yeah sorta, well point is, you are avoiding mutability across threads
thank you so much 💗
yeah
the hell
I can write an example with the cache and database fourteenbrush
Can someone help me figure out the code to check if a player broke a dirt block?
ah fair then, lets continue tmrw lol
Didn't work
ggood
send code
🥣
.
yes spoon feeding
?main
replace "> Idk what to put here" with the little code bit i sent u
Lmao wth is this
Ohhh
motivation why you shouldnt call your plugins class Main 🌝
doesnt really matter for smoll things but ye
'motivation' LMAO
Best bot on this planet
motivation idk how to say it
OMG @brave trellis TYSMM <3333333
love
Sorry it's been the hell of a day I really shouldn't be coding
Yes
Does it look like I care lmaooo
🤷
how do you save a file to the plugin's folder?
Plugin#getDataFolder for the directory
Then you can create a File instance with that
How can I update a plugin of bedrock?
thank you!
declaration: package: org.bukkit.event.block, class: BlockBreakEvent
This is spigot plugins, not bedrock support o.O
Is there a way to get the type of close in InventoryCloseEvent? I have players added to a HashMap to store the page of the GUI they're on when they open my GUI, then removed on InventoryClose. My only problems is when a new GUI is opened, the InventoryCloseEvent is called, removing the player from the HashMap prematurely
i didnt know there were plugins for bedrock
then why not have a method that adds them back?
Cause how would it know to add them back? Is the only way to check each inventory's name?
Can’t you just check which inventory was closed and go from there?
so it doesnt remove them from the map
well if a new GUI was opened, that is technically a new inventory
you can compare the inventory objects that are opened and see if its one of yours
But also as said above you can check which inventory was closed as well
Seems you just need to redesign how you are going about it
Ah okay, was hoping there was enum like InventoryCloseType.PLUGIN but I'll go with that. Thanks guys
Why cant i block the /version command from executing??
on PlayerCommandPreprocessEvent event
just remove the permission
how??
tf
I figured it out, thanks 😄
remove the permission of /version from the users you dont want to run /version
using luckperms or smth idk
No.. i just did if command.contains("ver") i cancelled it that way. for some reason =, ==, and === did not work
I dont use permissions anyway...
bukkit.commands.(commandname) is generally the permission nodes for such things
for some reason =, ==, and === did not work. contains did
ok not sure what that has to do with perms
well im not talking about perms so
We are
they're trying to cancel the version command and it is just far easier to use permissions
and that way you wont block some weird ass plugin from overriding it
Yes you can use the permissions to block it, not sure why you want to go the hard route on this
i aint downloading anything
so you dont have permissions on your server?
don't need to
No
Well I guess if you want to go a no permissions route, then just check if they are ops o.O
I just told you, even made a custom command /version and it did not overrrite the bukkit version command, so i had to use the PlayerCommandPreprocessEvent with "e.message.contains" to cancel it fully
it did work in the end so
and to answer this, commands are strings, thus you need to use .equals() or .contains() lol
but that would also prevent a command that contains "ver"
yea okay thanks
dont need that either
sure
if you say so, not arguing here. As I said going back to my game
Permissions and shit? wtf lol, i just use my own db with my own rank system
oo what are you playing
World of tanks at the moment
got this event going on so I need to ensure to get a few games in everyday
so yes the hard way
fair enough
Isn’t that what our world is going to be soon
doubt it? World of tanks is basically a FPS but with tanks
well im making a professional minigame network not some sort of essentials survival server.
even the most professional plugins still use permissions
because they are just easy to work with, and easy to use API wise for other things
don't necessarily need a permissions plugin to use it either
reinventing the wheel does not make a server professional
the API already has built in methods for permission usage
if you want to go about it differently and not make use of what the API provides so be it
1.8
professional
like even hypixel with its millions of dollars still uses citizens
which is kind of funny to me but makes sense
the major problem with everything custom, is maintaining it
yeah
the more things that are custom, the more there is to maintain and update yourself
1.18 w/ its high CPU and RAM usage is professsional? tried it out the other day have to give it so much ram
Yes
1.8 is 7 years old
if you are looking for enterprise software in terms of the server you are going to need to invest into such things yourself. Either make your own custom fork or pay someone to make you such things. Spigot nor paper are close to being enterprise level.
I will send this website every time: https://howoldisminecraft188.today/
Too old! (Click the link to get the exact time)
least of community plays 1.8
far too old
Well im not going to be paying for dedi just to waste ram on 1.18, 1.8 is perfectly fine for me, considering that many people still play it anyways so its not like i care
many people play 1.8
obviously you don't care otherwise you wouldn't use 1.8
Its fine
also isnt hypixel on 1.7? like serverwise
Anyways regardless of the version you are using, the version doesn't dictate anything other then what it is you want to provide
and implement 1.8 features
protocol hacks generally suck for the most part
Thats called loud minority; even 80k is very small for minecraft community
80k? nah hypixel hittin 200k
Also, modt of big servers use 1.8 moslty because of their legacy codebase. You have a great chance to use a supported version
unless you have millions to invest in it
Still small af comparing to 2 billions
yeah like they physically cant update without remaking everything
and that just takes a lot of time
so unless big servers invest a lot of time they are stuck at 1.8
Anyways how do icheck if the item that is placed on the BlockPlaceEvent is a Chest named "test" ?
getitem
well its no longer an item if its placed
itemInHand
hm it says
Expression 'CHEST' of type 'Material' cannot be invoked as a function. The function 'invoke()' is not found
if (e.itemInHand == Material.CHEST {
e.isCancelled = true
}
Well we could have years ago, but the playerbase remaining 1.8 majority meant that we ended up with 7 years of patches on top of 1.8
getBlockPlaced(), get chest inventory, get name
yeah
so basically 1.8 is going to be the version for big servers
not the go to for new servers tbh
Old big servers
I mean, not much preventing you from ViaBachwards 1.18
and the only reason its the version for old big servers is that they just cant update
without updating everything
I probably wouldn't recommend this for large servers either
like pretty sure hypixels owner said they were planning to update to 1.16 before but couldnt because they would need to update everything
Is there a way to heal a player and it to play the animation(?) of the hearts flashing?
i mean unless you're putting 200 people on the same server idt its much of a problem
maybe add a client side regeneration status effect
if we are talking about spigot sure might not be able to do that, but then again you are not a large server either
as I keep saying you can't expect to get enterprise software for free just because you want it
I want to do it at a custom rate
thats what i mean
the animation isnt based on packets i dont think
I know how to check item in hand
if (e.itemInHand == Material.CHEST) {
But how do i check the name of the item ?
packets would work i think
wait itemInHand was a variable before?
i think the speed of the animation is determined by the level of the active regen status effect
on the client side
How do you check the name of the item ?
so using packets to give someone regen but only on their side
will probably play it
idk getDisplayName
why packets
getItemMeta()#getDisplayName()
otherwise they will have regen for the server
if you dont want them to heal all the way or something
and it will only be visible for them
or well you can store their health in a custom value and send that every tick
but i think the client side regen effect might be glitchy
for players with high ping especially
I dont see the point of hiding healing process to others
val nameofHeld = e.itemInHand.itemMeta.displayName
Fixed
true
but thats not what he asked
just how to play animation
that animation sounds pretty client side
"heal player and play animation",no?
yeah
What's better to use isBlock or isSolid? I wanna make sure the block passed through a map is a valid block for going in a cuboid region
yeah but custom healing
isBlock just checks if it can exist as a block
so is it best to use isBlock then?
i guess
Ehats the point
I just wanna make sure no blocks like Grass go through, etc..
damn 1.8 api is weird
grass is a block tho
oh then use isSolid
^^
why is everything in variables
I use Kotlin.
Thats dumb kotlin
i swear intellij fucking hates me today
Taking getters and setters too much seriously
suddenly it's crashed like 3 times
probably the new updats
Does the ChannelPipeline for a player close when they disconnect? Or is my deregister for my ChannelDuplexHandler actually useful?
every update it gets worse tbh
i've had 0 issues with it for ages
like i use it daily and today it's like "ha gonna take a shit on you"
ive never had issues with intellij
I'm gonna print a logo off and rip it up
but every programmer has those days lol
that'll make me feel better
Okay dude 👍
sometimes intellij cant import settings after an update and you have to remake the project so it will make the new settings becuase if you dont you cant see anything in the project view
and blah blah blah
PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_HEALTH);
double healAmout = Math.min(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getDefaultValue(),player.getHealth() + 1);
packet.getFloat().write(0, (float)healAmout);
packet.getIntegers().write(0,20);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
} catch (Exception e) {
e.printStackTrace();
}
player.setHealth(healAmout);
let me know if something ridiculously wrong is here
why do you need to use packets for setting health
to play the animation
does it work?
yes
if so lemme just check it in intellij
just use the regeneration effect..
custom healing
Ehat custom healing
how does that packet trigger regeneration like animations ?
i cant imagine anything rather than just a regeneration effect
uh custom regeneration effect
that is the same packet used by the server if the health data is dirty
What animation are we talking about
the uh aniamtion that plays when the player heals
the tilty hearts
where the outline flashes white
if it works it works i say
I cannot for the life of me figure out why pis is null in this error https://paste.md-5.net/omacarajed.cs
This is the code where the error happens https://paste.md-5.net/politupoyo.java
gson shouldnt be returning null especially since I've added db.addToDatabase(new PlayerInfo(joiningPlayer)); so an array with at least 1 thing should be returning
true that
Does the client not just play that animation any time the players health goes up
with player.setHealth() the animation does not play
On a quick look, it looks like https://paste.md-5.net/politupoyo.java#L54 the Arrats.asList playerInfos is prob null,
you really should be naming your vars better, and following conventions for file naming
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
nope
is there an addHealth function?
prob not
It might be that you need to put refreshPis after the t = playerinfo, as the refresh method uses T
Are you resetting your file reader
no
besides that I would actively suggest to not store a file reader
open the file when required
instead of keeping a file reader alive the entire time
never nice when you run out of file descriptors
but its also paper
you can prob just copy that one method
How would i listen for any time a player is sent someone's equipment with protocollib?
instead of you know using paper
ah yes, copy licenced code 🙏
I mean hmm
True
GNU
wat
bunp
Literally listen to entity equipment packet
yea
so yes copy licensed code
just wondering if there was another packet that sent that
like one that sent all the entities data at once
just new to this generally so
or just use paper :>
Yea you are fine with just the equipment packet
How is paper painful
the packet will contain all equipment at the start
adventure api is painful
Better than legacy crap
We all hate those performance improvements smh
yes very much
performance? nah
idk i just dont see the point in using paper just to use 1-2 functions from it
Some functions may be well implemented on kernel side only
all equipment in a single packet?
you mean multiple right
no the packet holds a map
seriously?
yes
paper guaranties version compatibility, using packets not
or a list of pairs
one of them
one sec
pointless discussion I guess
if you want to stick to packets
the equipment packet contains a list of Pair<EquipmentSlot, ItemStack>
why do you need equipment packets?
Using a respected lib also guarantees version compatibility
?????
true invisible without armor
*with armor
Isn’t there api for that
sure?
i mean like
it'll refresh when the player is rerendered tho
this is just better
plus it doesn't matter im pretty much done
Efficiency
sendEntityChange when
pr it
With this kind of api so many packet-based code can be avoided
yeah that's amazing too
[23:28:53] [Server thread/ERROR]: Could not load 'plugins\Shop.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.ag4.shop.main.Main'
Caused by: java.lang.ClassNotFoundException: me.ag4.shop.main.Main
at java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:167) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:96) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:398) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[server.jar:2991-Spigot-018b9a0-f3f3094]
... 16 moreplugin.yml
name: Shop
version: ${project.version}
main: me.ag4.shop.main.Main
api-version: 1.16
authors: [ AG4 ]
description: Shop plugincommands:
shop:
what is the reason ?
2nd line
your main class isn't at me.ag4.shop.main.Main
and while we are on the topic of main classes
?main
Remove the blocks from event#blockList
That works too
well either you want a server spawned explosion to not break blocks -> use coll's method
or you spawn it and have control over it yourself
if i set the amplifier param to 0, is the potion effect lvl 1?
Yes
Loop through all the player's effects, and remove them https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/LivingEntity.html#removePotionEffect(org.bukkit.potion.PotionEffectType)
declaration: package: org.bukkit.entity, interface: LivingEntity
declaration: package: org.bukkit.entity, interface: LivingEntity
only loop needed is to remove from the list provided from the method 🙂
when PlayerAdvancementDoneEvent is triggered, i get both regular advancements (like "Hot Stuff") and recipes ("Fishy has completed the advancement Decorations/jungle Sign"). is there a way to filter it out to not recipes?
The exception java.lang.NoSuchMethodError: 'net.minecraft.world.level.block.entity.TileEntity net.minecraft.server.level.WorldServer.getTileEntity(net.minecraft.core.BlockPosition)'
occurs
"l" being the location, anyone know why this error is occurring?
Class<?> clazz = Class.forName("org.bukkit.craftbukkit." + plugin.version.substring(plugin.version.lastIndexOf('.') + 1) + ".CraftWorld");
Object testClazz = clazz.cast(l.getWorld());
WorldServer worldServer = (WorldServer) testClazz.getClass().getMethod("getHandle").invoke(testClazz);
TileEntitySkull skullTile = (TileEntitySkull) worldServer.getTileEntity(new BlockPosition(l.getX(), l.getY(), l.getZ()));
plugin.version.substring(plugin.version.lastIndexOf('.') + 1) | being the v1_18_R1
Are you remapping
just trying to place a skull block with a texture
You don't need nms for this
what do u mean
how so?
I feel like an idiot, i've been digging through the code of mc for days now trying to find a solution
That looks like mojmap, you need to remap using maven special source to convert it back to obfus
declaration: package: org.bukkit.block, interface: Skull
wait is that for 1.18 only, and not for 1.17?
Yes
Also I see a future in there
Which means the API acknowledges futures
Now we must make a future version of unloadWorld
I am using this (https://www.spigotmc.org/wiki/creating-a-gui-inventory/) to create my own inventory, is there an easy way to add onto it, on click? so it would do a certain action, such as "print hello", just like in skript w/ TuSke ?
Skript example:
format gui slot x with x named x to run:
(print player clicked this!)
Because right now i handle that with a fun onInventoryClick(e: InventoryClickEvent) { }
but i imagine it will be very big as items start to get more and more, as well as this it is a pain, say for example I want to loop players skulls into a inventory, id have to in the inventory click event specify the item name and check what it is to do the certain action
You should have a map with the key being the player and the value the current gui's state. Simply add the entry before (it's important that you do it before) you open the inventory and simply listen when the player closes the inventory so that you can close it. Whenever the player clicks on it, simply obtain the state from the map and do everything you want to do now
Just asking, why are you using script?
Skript*
When done properly you are ae to save lots of time and hussle creating the guis
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
are you drowning?
No one needs to...
No so basically I'm using essentials bukkit plugin
And it normally wormed
Worked
This has help in the name
For development
Nobody will be able to help you with that info, and #help-server
Like coding
I was not. I am just giving an example. as it can easier make me and you guys understand my problem I used to make a minecraft minigame server in skript when i was 15
I am really confused about your response, im still learning java. can you please give an example ?
I would just use an inventory framework
I don’t know what this talk about putting a player in a map is
Map<Player, MyGuiInfo> map = new HashMap();
void open(){
Player player = ...;
MyGuiInfo info = ...;
map.put(player, info);
}
@EventHandler
public void onClick(InventoryClickEvent event){
MyGuiInfo info = map.get(event.getWhoClicked());
if(info == null) return;
}
@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent event){
map.remove(event.getPlayer());
}
I wrote this quickly on my phone, but you should get the idea
You could add a list or an other map into your info object with all the gui itrms
