#help-development
1 messages ยท Page 1717 of 1
well, enums are compared by identity regardless so it doesn't actually matter
I prefer less code, personally
Location loc = p.getLocation();
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity();
int entityId = (int) (Math.random() * Integer.MAX_VALUE);
packet.setEntityID(entityId);
packet.setType(EntityType.ARMOR_STAND);
packet.setUniqueId(UUID.randomUUID());
Location itemLoc = loc.add(loc.getDirection().multiply(new Vector(3, 1, 3)));
packet.setX(itemLoc.getX());
packet.setY(itemLoc.getY());
packet.setZ(itemLoc.getZ());
packet.sendPacket(p);
WrapperPlayServerEntityMetadata metadata = new WrapperPlayServerEntityMetadata();
metadata.setEntityID(entityId);
WrappedDataWatcher dataWatcher = new WrappedDataWatcher(metadata.getMetadata());
dataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
dataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(String.class)), answer);
dataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(boolean.class)), true);
metadata.setMetadata(dataWatcher.getWatchableObjects());
metadata.sendPacket(p);
error: java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "objects" is null
at com.comphenix.protocol.wrappers.WrappedDataWatcher.<init>(WrappedDataWatcher.java:106) ~[?:?]
why
What's the point of that entityid
Why multiply int max and then force it back down
it's from protocollib
i dont get it
close to none
bruh
smh
how to get the nearest block of a specified type (e.g. glowstone) from a player?
you should limit this to a certain range since you would probably need to check every block near the player for the type you want
ok so is there a way to check if in a range of e.g. 15 blocks to the player a this block is?
get every block within that range in a list or array and then check every single one for the type. I cant think of any other ways
array would probably be better since for every range there is an exact amount of blocks there can be
not sure about that tho
meh why bother storing them
just make a loop to loop over all the blocks in the radius and check if the type is day glow stone
is it possible to do the iterating over every block async?
for (int x = -15; x <= 15; x++) {
for (int z = -15; z <= 15; z++) {
for (int z = -15; z <= 15; z++) {
player.getLocation().add(new Vector(x,y,z)).getBlock()
}
}
}
use World#getBlockAt(x, y, z) instead
i think you can in newer versions, but i think the getBlock call is not allowed async on older versions
World world = player.getWorld();
for x
for y
for z
Block block = world.getBlockAt(x, y, z);```
Faster and less object allocation
lol true - phone coding bad
grab a chunk snapshot,will allow you to go through it async
if a player is kicked, can i still get its name?
you listening to an event?
but if you ... kick a specific player ... you have the player, so what is the problem?
u can use OfflinePlayer
take a look at my EasyMetadataPacket class
https://gist.github.com/IllusionTheDev/883eb3aa8b7c6d4b849f9a9eed145dc1
Should help
this will create an int between 0 and somewhere around 10000 right?
(int) (new Random().nextInt(100000) / 9.9
Just use nextInt(10001)
I usually do something like this
public static int nextIntBetween(final int min, final int max)
{
return min + nextInt(max - min + 1);
}
public static int nextInt(final int bound)
{
return random.nextInt(bound);
}
That wouldnโt return between max and min
Yeah with both bounds being inclusive
my brain wasnt working for a second ๐
๐ฅฒ
it is possible playerkickevent is called when the player is lagging too much or something.
How can I add hex color support in my plugin?
You will have to make the lagging thing yourself and then kick
It should be added already
Simply letting the user use
&x&H&E&X&H&E&X
oh
Though if you want a more precise format youโd have to add something yourself
Most people use regex and parse a string with the format &#FFFFFF
how can I make it so you just use &#FFFFFF TEXT HERE
Since the default one is somewhat verbose
oh oki
Maybe take a look at something like that
Oh thatโs actually not the format you want
Uh let me find another one
That one maybe
Can someone send a me a tutorial for setup a databes for plugins? Im using Ubuntu (Last Version) and Flamecord
my hub server and my survival server are on 2 different machines btw
u mean a Mysql database?
yes
last version
take a look at this
Is there a way to save extra data when a chunk is saved (so, something like the capability system in Forge for Chunks)?
Chunks have a PersistentDataContainer
Ah, nice. Thanks
How can I efficiently block swear words from chat?
i did it, but now how can I create a database for Luckperms ?
for example
mysqladmin -u root -p create database_luckperms and then in the luckperms config for the password I use the same of the mysql user?
ok
if not exists
and what will the password of the base be ?
ok
do i need to do something else if I want to access to the database from remote ?
i opened the port 3306
as far as i know no, but im not that knowledgeble in mysql either
you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATABSE db_luckperms' at line 1
ah i got it
nvm
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yh thats the api
not nms server
nms server isn't spigot
is there not a maven repo for it
idk if you can use a plugin of IntelliJ Idea, i dont remember
If you want to use craftbukkit and nms then just change the artifactID from spigot-api to spigot.
Just make sure that you ran BuildTools once with this version so that its installed in your local maven repository.
cheers working
i cant find it but how can i save a hashset to the config yml so it looks like
key:
- ...
- ...
i tried set("key", new ArrayList<>(set)) but that doesnt work
Caused by: java.sql.SQLException: Access denied for user 'filippo'@'vmixxxxx.contaboserver.net' (using password: YES)
at me.lucko.luckperms.lib.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[?:?]
at me.lucko.luckperms.lib.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[?:?]
at me.lucko.luckperms.lib.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833) ~[?:?]
at me.lucko.luckperms.lib.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453) ~[?:?]
at me.lucko.luckperms.lib.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) ~[?:?]
at me.lucko.luckperms.lib.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[?:?]
at me.lucko.luckperms.lib.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[?:?]
at me.lucko.luckperms.lib.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[?:?]
at me.lucko.luckperms.lib.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[?:?]
at me.lucko.luckperms.lib.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[?:?]
at me.lucko.luckperms.lib.hikari.pool.HikariPool.access$100(HikariPool.java:71) ~[?:?]
at me.lucko.luckperms.lib.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:726) ~[?:?]
at me.lucko.luckperms.lib.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:712) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
... 1 more
This error appears when i try to connect from remote
Luckperms Config.yml
data:
# Define the address and port for the database.
# - The standard DB engine port is used by default
# (MySQL: 3306, PostgreSQL: 5432, MongoDB: 27017)
# - Specify as "host:port" if differs
address: 93.xx.xx.xx:3306
# The name of the database to store LuckPerms data in.
# - This must be created already. Don't worry about this setting if you're using MongoDB.
database: db_luckperms@93.xx.xx.xx
# Credentials for the database.
username: 'filippo'
password: 'x'
pretty sure the database should just be the name, without the ip
mothing changed
bad. install mariadb instead
database should still be without the IP, unless you actually named it that on your SQL server
Hey, i have this event:
https://paste.md-5.net/ponuqivopi.java
and i registered it in the main class
but when i open the menu
i can move all
could anyone help me?
why are you checking the inventory via the title
So this is something like Map<String, List<String>> then?
(you could use https://github.com/Incendo/interfaces, which saves a lot of time, however its not released yet so you have to publishToMavenLocal)
why not?
two seperate inventories could have the same title?
but
just compare the two inventories themselves
or use interfaces, as i reccomended earlier
ok? there will still often be incompatibilites with other plugins or even commands/datapacks?
just store the inventory instance and compare that
It's not released yet
But... it shows Maven installation steps, there's a snapshot repo.
But this code, i had it in other pl and it worked
to not move items in your inventory
yea i guess
but here doesn't work
this is why you try to stick with good practices so you dont have those kind of issues
What kind of map do you want to save?
wait, doesn't Minecraft have a dependency on Guava?
Guava has a multimap implementation
however, i don't even know how to use the "publishToMavenLocal
Multimap<String, String> or smthn
gradlew publishToMavenLocal but you don't need to do that
@lavish hemlock pointed out that you dont have to
just use the snapshot repo
a Hashmap<UUID>
UUID and what?
uhh excuse me hashset i mean
Aaah.
I think you can just throw it in the YamlConfiguration
Like this:
private static final String ID_KEY = "values.ids";
public void saveIDs(final Collection<UUID> ids, final FileConfiguration configuration) {
configuration.set(ID_KEY, ids);
}
public Set<UUID> loadIDs(final FileConfiguration configuration) {
return new HashSet<>((List<UUID>) configuration.getList(ID_KEY));
}
Does a chunk override the hashCode method in Spigot? (So, can I safely use the chunk interface as a key in a hash map)
Quick question: What is the best way to query whether a player has walked to a certain coordinate?
In my case, I would like to check whether a player has walked to a certain z coordinate. If this is the case, the player is teleported to another position. I have already tried the following:
@EventHandler
public void playerMoveListener(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(player.getLocation().getZ() >= Main.instance.getConfig().getDouble("destination.z")) {
player.teleport(Main.instance.getConfig().getLocation("start.location"));
}
}
destination.z and start.location are values that I have inserted in the config of the plugin as follows:
Main.instance.getConfig().set("start.location", player.getLocation().toString());
Main.instance.getConfig().set("destination.z", player.getLocation().add(0, -1, 24).getBlock().getLocation().getZ());
start.location is the location to which the player should be teleported if he crosses the z coordinate, which is stored in direction.z. The player will be teleported to this location if he crosses the z coordinate.
Can anyone help me with this?
yea but then it looks like vanished-players: !!set
!!java.util.UUID '9558961c-bc19-4820-9f75-5d486448c2d5': null
Yes but this is kind of dangerous as it keeps the chunk loaded.
You should reference a Chunk by a long. Chunks have only x and z coordinates that are each 32 bit integers.
So you can reference a Chunk indirectly by just using a 64 bit long.
Ah alright thanks.
do you just long id = chunk.x + chunk.z? (pseudo-code)
asking out of curiosity
(I imagine that's not how it works since you can't separate them afterwards)
@lavish hemlock No this would not work because of the sign bit
https://gist.github.com/Flo0/1d53773ae3678856f4d9cf36e32de370
I have no idea what I'm looking at here
also id's would duplicate
Yeah that's why it wouldn't work
x = 1
z = 2
and
x = 2
z = 1
are duplicates, but different chunks
Its just some bit shifting. I take 2 32 bit integer and put them in a 64 bit long by shifting and masking.
record ChunkCoordinate(x, z) :)
I see. Then you need to convert it to a List of Strings first.
less efficient
records aren't magic, they're just classes that are handled differently by the compiler and VM
Also valid
that allocates more than 8 bytes, while 7smile7's method allocates just 8 bytes (since long's size in memory is 8, according to Long.BYTES)
I've actually never done anything with bit shifting...
I've done a bit of masking... I think?
This would be the streamed approach:
private static final String ID_KEY = "values.ids";
public void addIDs(final Collection<UUID> ids, final FileConfiguration configuration) {
configuration.set(ID_KEY, ids.stream().map(UUID::toString).toList());
}
public Set<UUID> loadIDs(final FileConfiguration configuration) {
return configuration.getStringList(ID_KEY).stream().map(UUID::fromString).collect(Collectors.toSet());
}
ah I thought valhalla was already getting somewhere and they had that planned for it
Do you have any resources where I can learn more about bitwise ops, I've been wanting to but I have no idea where to find guides/projects for something so specific.
Well, OpenJDK hasn't been making many moves on Valhalla.
The last update to inline classes was in 2019.
phew i'll test mine first and then this : )
They're mainly focusing on Panama (memory incubator APIs) and Amber (language features).
Although, the JVM has "value-based classes," but those are only available for standard library classes and aren't a source language feature, so much as a VM feature.
can you stop all running scheduled tasks in a class from another class?
Certain classes, like Long, Integer, ProcessHandle, Optional, etc. are value-based.
Yeah should be possible?
Is it with the BukkitScheduler?
yea
@lost matrix ?
The oracle docs do have a bit of information about it
I mainly want some problems to work on.
Ah no sry. I just kinda learned it when i did embedded C
As well as examples/use-cases as opposed to Oracle's shitty documentation.
They do provide examples tho
Not real-world ones afaik
andddd the example is limited too btw
This beginner Java tutorial describes fundamentals of programming in the Java programming language
it only shows masking ^
Oh yeah their docs on that is somewhat limited
isnt that just Bukkit.getScheduler().cancelTask(int pid)?
okay, how do you define the task ID?
everything returns the taskid
uhh
I think I'll just toy around with 7smile7's whole chunk ID thing to see what each operator does in the context of the method.
those methods returns the taskID's so you can save them somewhere and then cancel them in another class with scheduler.canceltask(id)
idk which method you use for the scheduling
does getting config take resource ?
everytime i want to do a thing i get the config
it is customizable thing that it requires getKeys and stuff
so i can just get the value
im thinking of storing stuff on hashmap onEnable
what is this
that is causing that much lag
my guess you are spamming packets
Should send packets Async anyways
when i do "" + obj is the toString() method of obj called?
yes
any one has solution how to handel placeholder in item lore
for example first time placeholder will be changed to value
but if placeholder updates on player action or timer
and u don't want to recreate
whole inventory again
just grabing content is not working
because
item lore is now has value
and not placeholder %bananas%
if you get my point
@wary harness nbtapi
store placeholder value to nbt tag
if you want to retrieve it
so
every time then I just delete
current lores
and load original
one from nbt
and update placeholder then
Fetch the outgoing item packets and change the lore before it reaches the player.
will that be efficient
Should be fine. Its not the cheapest approach but its also not horrible.
For me its about 1% of the servers tick for every 100 users.
how to view nms mappings
there was a website for it
i dont remember
oh i found it nvm
[] is for "any character from these". so []+ is at least one or more characters from these. you want to use a group (test)+
oh
thanks
in fact i want to change the string permission.permission.admin to permission.admin
and it can also just be the last
why don't you just substring starting from the first . ?
yea but imagine there are even more permission.
you could just split on .
and just make a loop
or
And use "permission" for an argumemnt
btw do permissions work lowercase or doesnt matter?
they should always be lower case.
ok
public static String truncateDuplicates(String input) {
return Arrays.stream(input.split("\\.")).distinct().collect(Collectors.joining("."));
}
Result:
"perm.perm.val"
>>
"perm.val"
@lost matrix
PacketPlayOutSetSlot slot = new PacketPlayOutSetSlot(0,1, CraftItemStack.asNMSCopy(new ItemStack(Material.ANVIL)));
((CraftPlayer) p).getHandle().playerConnection.sendPacket(slot);
}```
I tried this
but not effect
am I doing something wrong
You need a packet listener that intercepts outgoing packets of real ItemStacks.
Not that i know of...
does anyone know about a plugin that uses the conversations api?
ow thanks
๐
But you can have the class from my lib:
https://gist.github.com/Flo0/cd0c6e7fec1dd9315a565474e4c4d73b
You can also use TinyProtocol too, but I just created me own too https://github.com/MinecraftMediaLibrary/EzMediaCore/blob/2a07903f8b5ec681592bea7312da4eba06af0d61/v1_17_R1/src/main/java/io/github/pulsebeat02/ezmediacore/nms/impl/v1_17_R1/NMSMapPacketIntercepter.java#L315
its not as good probably tho as 7smile7's tho
lol
I will try to use it thanks
But you dont need ProtocolLib which is a plus...
meh
with which method can i get the inventory contents without armor?
?
true
How can I save the server console output to a txt?
it already is, latest.log
my plugin not read latest.log
lastest.log is saved on onDisable() no?
no
I'm working on a web console, what I want to do is to export the real-time console to a txt file and display it in my html page.
add a handler to the Bukkit logger
plz help
how ?
@eternal oxide plss addme friend
Bukkit.getLogger().addHandler
can you help me on anydesk?
whats wrong?
look at the image
wrong import?
there's no where to import on there
every class has imports
no i mean like it does not give me an option to import
its the net.md5.bungee.api.chat.content.hover.Text
can you help me on anydesk?
no
Because that would be too much like a job, and you could not afford my salary
elgar rich : o
only log
o wait i already have that import
I wish, but I can say I've never ever worked at a job I didn't want to work at
it's hover.content, not content.hover
uhu
ok so what do i do
just type Text and you'll see the import
bro you
what do you doN
no i already have that import
i dunno how to setup that handler
and?
and.. what do i do now
does it work?
you were trying to send a textcomponent
yes
and whats not working?
it's in the image
btw use a ComponentBuilder
new ComponentBuilder()
.append(text)
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(hoverText /*this is a string*/)))
.create();
returns java BaseComponent[]
send it with java player.spigot().sendMessage(BaseComponent[] baseComponents)
it's a builder which combines TextComponents and events
what does .append(text) do
adds a string or a basecomponent
ok, and the .create();?
outputs a component
that creates the builder
so you put that at the end, ok
thats how a builder works yea
and what do i do if i want to have multiple text lines, or two texts in one line with different events
this is an example
ignore Utils.colorize, that just adds color
and keep in mind that .event adds an event before at the textcomponent therefore
btw is ChatColor.translateAlternateColorCodes good or should i just use the weird S sign
use ChatColor....
wdym
bungee ChatColor
ChatColor.translateAlternateColorCodes('&', your text here)
yes i know how to use it, i'm saying which one should i use
the one above
ok that's 2 for chatcolor and 1 for weird s sign
wait so how do i send the base component in one line?
No clue, I've never looked. I know it got HEX color support first, but I've been told to use teh Bungee one when using components
oh then i'm using the wrong one ๐ค
if you use the builder you cant
oh ok, then how do i do it
but use player.spigot().sendMessage(player, new COmponentBuilder(). bla blabla)
you just said i can't
Hey guys I have an error with my bungee plugin do you know where could I find some help ?
Here is my error : https://www.spigotmc.org/threads/error-when-loading-plugi.528282/
Your dev version doesnt match with your used bungee version
what do you mean ?
@lost matrix I have managed to change some items in player inventory and hot bar
You either program with an outdated bungee version or you run one
hi im trying to make a plugin that adds 1 to a scoreboard when u right click how can u do that?
Maybe there is a packet type missing
hi lions
oh hi ๐
if interval of a bukkitrunnable is 0
will it be 1 ticks ?
I have the same "waterfall.jar" on my server and in my plugin java build path
Does your bungee plugin have any dependencies?
please help
nope
Then the versions most likely dont match up
Listen to the PlayerInteractEvent and change your scoreboard accordingly.
If you want to support more than 20 cps then you need to listen for incoming packets.
help me pls
https://i.imgur.com/Jgtgkdf.png
ok thanks
can I call you ? so you can explain me better
remove the player, from your arguments
oh ok thx
- Install the latest Waterfall version.
- Use the same version for development
- Make sure that Waterfall is
notshaded into your plugin
AH SHIT
so that was why my plugin performance was worst than protocllib
?
what does shaded means (look on google found nothing convicing)
i set to 0 assuming it wont run
so that killed performance
Hey, so I'm trying to do a simple gui, it did created but in my EventHandler, when I check the inventory name, I get an error: https://pastebin.com/Ffhvv4VK
my EventHandler code : ```java
public class ClickEvent implements Listener {
@EventHandler
public void clickInvEvent(InventoryClickEvent e){
if (e.getClickedInventory().getTitle().equalsIgnoreCase("GUI")){
e.setCancelled(true);
}
}
}```
It means waterfall gets completely copied into your plugin.
This is the default behavior for dependencies unless you set the scope to provided
isnt it event.getView().getTitle()?
let me try
Clicked inventory can be null
It does not work
on what do you click if the inv is null :/
same error
Outside the inventory
oh that way
Hey, someone who could help me with adding hex colors, to scoreboard pl?
How big is your plugin jar?
I downloaded the same file
But it's wearied because it load's one
Help with scoreboard adding hex colors
[17:54:19] [Server thread/ERROR]: [LiteBans] Error: Failed to initialize pool: Public Key Retrieval is not allowed
[17:54:19] [Server thread/ERROR]: [LiteBans] Cause: Public Key Retrieval is not allowed
how can I correct this?
Ask the author of LiteBans i suppose
sql:
# H2, MySQL, MariaDB, and PostgreSQL are supported database drivers.
driver: MySQL
# Database server address.
address: 194.x.x.198:3306
# Database name, username and password.
database: 'db_litebans'
username: 'admin'
password: 'x'
pool:
min_connections: 1
max_connections: 10
keepalive: 0 seconds
timeout: 25 seconds
idle_timeout: 1 minute
max_lifetime: 30 minutes
# Database engine. Only applies to MySQL.
engine: InnoDB
options: 'useSSL=false&serverTimezone=UTC'
table_prefix: 'litebans_'
now I know your going to learnjava me but would this do anything? new Test(player);
if the class Test is ```java
package com.CJendantix.lifesteal.inventories.clickEvents;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.CJendantix.lifesteal.items.Heart;
public class Test {
ItemStack heart = new Heart().getHeart();
public Test (Player player) {
player.getInventory().addItem(heart);
}
}
like would that call the constructor and do that
Sure... it will give the player the 'heart' ItemStack. But a constructor is def not the way to go here.
what should I do?
Either use a singleton or make this static.
whats a singleton
I made it static, should I make it void or return the heart itemstack (and make it the type of itemstack)
private static final ItemStack HEART_ITEM = new Heart().getHeart();
public static void giveHeartItem(Player player) {
player.getInventory().addItem(HEART_ITEM);
}
Or you could use an Enum for that:
@AllArgsConstructor
public enum CustomItem {
HEART_ITEM(new Heart().getHeart());
private final ItemStack itemStack;
public ItemStack get() {
return this.itemStack.clone();
}
}
Player player = ...
player.getInventory().addItem(CustomItem.HEART_ITEM.get());
thanks
I used this to create a simple inventory, how would I open this with, say, a command? https://www.spigotmc.org/wiki/creating-a-gui-inventory/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Player.openInventory inside your command
and then this class is the inv it opens
would this work to open the inventory if the name of my inventory class is Shop? java player.openInventory((Inventory) new Shop());
why would you want to cast to Inventory?
โ
because it tells me to lol
That won't work. You will just get a castexception
ok
You need to instead pass the inventory instance from the class
For example, your ShopGui has an inventory right?
yeah
pass that in
private final Inventory inv;
Yes
so I create a static getter?
Hi. for some reason this doesnt work:
public static void OnRightClick(PlayerInteractEvent e){
Player player = e.getPlayer();
Block b = e.getClickedBlock();
Action a = e.getAction();
if (e.getHand().equals(EquipmentSlot.HAND)) {
if (a.equals(Action.RIGHT_CLICK_AIR)) {
player.sendMessage("helloooo");
}
}
}
}
when i try to use RIGHT_CLICK_BLOCK, LEFT_CLICK_BLOCK and LEFT_CLICK_AIR it works but when i use RIGHT_CLICK_AIR it doesnt why?
that isnt good. its called static abuse
you are using static the wrong way
ok
Just to prove some basic knowledge, can you show me a basic class
with some properties, getters
and write it
just write any class
k
just write a basic class
please help
Hey does anyone know a library to read/trim/write region files?
ive used this one https://github.com/PowerNukkit/Region-Manipulator but it does not work in 1.17 (it seems to cut out all the entities)
Hi. for some reason this doesnt work:
public static void OnRightClick(PlayerInteractEvent e){
Player player = e.getPlayer();
Block b = e.getClickedBlock();
Action a = e.getAction();
if (e.getHand().equals(EquipmentSlot.HAND)) {
if (a.equals(Action.RIGHT_CLICK_AIR)) {
player.sendMessage("helloooo");
}
}
}
}
when i try to use RIGHT_CLICK_BLOCK, LEFT_CLICK_BLOCK and LEFT_CLICK_AIR it works but when i use RIGHT_CLICK_AIR it doesnt why? PLEASE HELPPP
You need to be holding an item
Did you add the @EventHandler annotation?
Did you register the Listener class?
yes
Not sure about that. I think static should work,
It does?
yes
Are you holding an item
reading is hard
Check if the Block is null.
Clicks on a Block always get registered but clicks in the air without an ItemStack in your hand dont.
Or not Elgar actually, lynx
lol
i purposely posted bad code to see how helpers would react
lul
how can i do that?
Actually let me test that
Using java
@paper viper sorry I was taking my meds, here is a very simple class. ```java
package com.CJendantix.lifesteal.commands;
public class Test {
private int a;
public int getA() {
return a;
}
public int setA(int A) {
return a = A;
}
}
Just check == with null
Ok thats good, except name your variables better
ok one sec
notice how you didnt use static
I was taking your advise
Yep
advice*
god
Now do that for gui class
lol
Make a public getInventory method (getter method) to get your inventory
already did that
player.openInventory(new Shop().getInv());
Yes
yay
if (a == Action.RIGHT_CLICK_AIR) {
player.sendMessage("helloooo");
}
}
Like this? sorry if im doing dumb stuff i just started
hella spacing
seems fine
make sure to change e.getHand().equals(EquipmentSlot.HAND) too
if you have to say this
Like this? sorry if im doing dumb stuff i just started
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
huh
he said Like this? sorry if im doing dumb stuff i just started so, like, he should learn java if he is doing dumb stuff xd
oh
still doesnt work when im not holding an item
I still get learnjavad a lot but atleast I looked at a few and did some courses so i'm not like "How to do hellow worled"
bruh i just realized that i dont even need it to detect if a player is not holding an item. oh boi 2 hours wasted yayyyyyy i want to dieeeee
i feel u bro
Init plugin = new Init().getPlugin();
ItemStack item = plr.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
assert meta != null;
PersistentDataContainer container = meta.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(plugin, "modifier");
container.set(key, PersistentDataType.STRING, modifier);
why does it keep erroring that "plugin is already initialized!"
bruh
how would i use the plugin in the namespacedkey without putting it in the init file
because it is
but the function it's in is
Because you're doing new Init()
required for other functions
Assuming Init is your main class
well then how else am i supposed to get the plugin?
and yes it is
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
store it in an enum
And use JavaPlugin.getPlugin
DI or Singleton
for enum
ok
how can i add 1 to a scoreboard named rcd?
Someone help me with scoreboard adding hex colors?
Hello
Someone knows which should be the class for totem activator? I mean, if a Spider makes me activate a totem, I want to display Spider.
I tried with LivingEntity but doesnโt work
declaration: package: org.bukkit.event.entity, class: EntityResurrectEvent
Like this?
wait it doesnt say who deal damage to the entity tho
well you can do getLastDamageCause
and do that
is it worth it to implement trie data structure to custom command handler?
Yes
Definately
it will save you a lot of time
and make your code cleaner
You can use Brigad or some other framework to assist you with that
im already using node system for commands but im thinking if i could implement trie to make argument searching a lot faster
but there's a con that its highly memory inefficient
even with compression
no
Oh
a Trie data structure
i already have tree like node classes
trie data structure is a tree specifically design to insert and search strings
it searches strings in O(n)
Ah ic
by implementing it you could search the arguments in O(N) rather than using equals for string function which is from O(1) to O(N) by itself,
without it the search would take O(N^2) while with it it would take O(N), which is a lot faster, but takes more memory due the way you need to store every character as a separate node in multiple arrays
unless you do compression, but that still doesnt solve much inefficiency
basically its CPU vs Memory game
depends on how large of a data structure you are dealing with ig. Like how many commands you are going to use. But i still think its fine to do it
Okey thank you! This is what I wanted!
np
Any ideas as to why Spigot is just ignoring that I told it to add a enchantment to an item stack?
have you set the item meta back
ItemStack sv = new ItemStack(Material.GLASS_BOTTLE);
ItemMeta svMeta = sv.getItemMeta();
sv.setAmount(1);
sv.addUnsafeEnchantment(Enchantment.LUCK, 1);
svMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&5Soul Vial"));
svMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
sv.setItemMeta(svMeta);
Everything here but the enchantment works
how can i add 1 to a scoreboard that already exist?
this is my inventory class: https://paste.md-5.net/ivitudipeh.java
its almost completely copied from: https://www.spigotmc.org/wiki/creating-a-gui-inventory/
when I click an item it allows me to freely drag it around, I thought it wasn't supposed to do that. If it is supposed to do that, how do I make it not, and if its not, how do I fix it?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@someone lol
You need to cancel the click event if the clicked slot is incorrect
Or you could use the clicked item
I want them to be able to click it, but it to go back to its original location after
and then do something if they clicked it
right now its not doing either of those things
?
saw that somewhere above
meth
I want them to be able to click it, but it to go back to its original location after
and then do something if they clicked it
right now its not doing either of those things
ah i looked it up but it's something else than f(x)
itโs big O notation
uhu looking it up
describes how an algorithm performs as the number of inputs increases iirc
O(n) = linear
O(1) = constant
O(n^2) quadratic
yes
but not recommended
while (true) for (;;)
how would one algorithm be so slow
almost everything has a O(n) solution
O((n-1)!) is bogo sort iirc
sounds about right
on another note i know i asked this before but how do i check for a reload again?
How the hell did I insert an if
check the length of Bukkit.getWorlds()
anyway
in onLoad
^
thx
Not entirely sure, my shop project worked
oh no logarithms
All I did was check for the slot and an item and I can't take an item out
lol
?paste
@shadow tide this is all I did for one item and it works
https://paste.md-5.net/eqabevijox.cs
!this.getServer().getWorlds().isEmpty();```?
means it is reloading
no
if it is empty = reload
if its empty its a fresh start
lol
if it has worlds its a reload
smart
so it's reloading
oh he had a !, so correct
heheh
how do i run a command and then click on a block?
i am not sure how to "wait" inside a command event thing for a block click event
i.e, i run /destroy, and it breaks the block i right click on
you don;'t wait. You set a flag on that player you can look for in any upcoming break event
ohhh
hello i was wandering about how does this work player.setScoreboard();
question, what if I send a SetSlot packet to a player, with WindowId=-2 (player inventory) with a diamond chestplate on slot=6 (chestplate slot), will everyone be able to see he's wearing a diamond chestplate (even though technically he's not wearing it, just a packet to give the impression)
no
player will be able to see it at least i suppose
please
how can i send this packet to everyone?
alright, very interesting thank you
here you can see an example https://github.com/WizardlyBump17/WLib/blob/main/versions/v1_12_R1/src/main/java/com/wizardlybump17/wlib/adapter/v1_12_R1/PacketListener.java
i used protrocollib
ello?
now, what if I send a SetSlot packet to a player, with WindowId=-2 (player inventory) with a diamond sword on slot=the slot that player has in main hand, will everyone be able to see he's wearing a diamond sword
@golden turret
oh nvm i'm dumb its entityequipment too
@golden turret but one question though, if I want to give the player the full illusion he's wearing another armor, i'll have to send him SetSlot packets (so he sees the fake armor in his inventory/hotbar) AND EntityEquipment packets to himself and evryone else so he looks like he's wearing the fake armor,
right?
Anyone know why this takes two vials and gives two filled with one enderman? It's getting really annoying and makes no sense while the item stacks are set to one.
https://paste.md-5.net/hadaciyavo.cs
yes
This is in a PlayerInteractEntityEvent
O
The experience bottle is the filled version and the normal bottle is the empty version
two quick questions about the spigot forums, 1) would it be fine to track download counts hourly for my projects to map trends , 2) would it be fine to provide that site-wide as a free service on a third party platform
programmatically, of course
iirc playerinteractentityevent fires twice, one for each hand. you gotta check which hand the event is being triggered for
I thought interact was only right click from what the docs said
it is, but players have a main hand and an off hand
Probably not. I expect scraping the site would be frowned upon
Unless I'm remembering wrong
especially hourly
The only option is getRightClicked
I know getting the plugin version isn't so I was wondering if getting other data related to the plugin would be fine
Thats for getting YOUR plugin version. Scraping EVERY plugin version hourly?
that's why I broke it down into two questions
what version are you on
man think of the great name I could secure for this service
water-meter.com or smth
Hello i need help i want to make it so when u right click 1 is added to a scoreboard named rcd i have done the right click part but i dont know how to add 1 to rcd PLEASE HELP!
here is my code:
`@EventHandler
public static void OnRightClick(PlayerInteractEvent e){
Player player = e.getPlayer();
Block b = e.getClickedBlock();
Action a = e.getAction();
if (e.getHand().equals(EquipmentSlot.HAND)) {
if (a.equals(Action.RIGHT_CLICK_AIR)) {
player.sendMessage("rcd set to 1");
}
}
}`
rcd is an already made scoreboard
hello?
pls help
patience
Map
umm what is map?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
its a map its a map its a map its a map its a maaaaap
map is life, map is love
maps are so useful
i still dont know what is map
without maps we are nothing but naked cavemen counting through rocks until we find the sharpest one, only to then count them again
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
a map is a data structure that allows you to get a value from a value
e.g. a Map<String, Integer> maps an integer to a string, meaning you put in a string to get an integer
String is the "key," Integer is the value
unfortunately lions is illiterate which really doesn't help with on his dreams of becoming a programmer
can someone just explain me how to do this
oh dear
told you
ok comeing in a few years after i go thru the courses byeeeeeeeeeee
stuck in supoooooooort
good luck โค๏ธ
thank you
just sit down for like 30-60 minutes every day learning something new
eventually you'll get it done
dude i just wanted to add 1 to a scoreboard and now i have to do this
and if you sit down for 10-16 hours learning something new you might actually learn enough to do something practical with that knowledge
I can't sit down for 10 hours learning, I get distracted too easily for any more than 2 hours of learning
I can't get up until I am done
I just learn by doing
30-60 minutes everyday for me be like 6 hours a day minimum
i just wanted to make a single plugin and now i have to do this.i already learned c# and it was pain in the donkey. why am i doing this to myself
if you learned C#, how are you having problems with Java?
it's different if I'm doing something I enjoy, I will sit and work on it for hours until I'm in pain from hunger/thirst, but learning something I don't enjoy is kekW man
also stop trying to get us to pity you and just do shit maaaan
if you learn programming for 30 minutes a day I can't help but wonder how many years it would take before you can do anything vaguely complex with it
I mean eventually you'll get somewhere kek
but 10 hours every day is a bit unrealistic for most people
Java is literally just C# but ironically less complicated lol.
C# has a different syntax, they do have namespaces or whatever they call classes in there
Java is c# without microsoft
If it helps:
C# - Dictionary
Java - Map
c# is java without oracle
OHHHHHHHH
tru
holy shit he learned something I am a genius
u mean dictionaryyyy
we mean maps yeah
they're called maps in java.
no, we mean map, it's called a map
i still dont get it lollll
aaaaaaaand blocked /j
turns out you're a moron
sorry
next time have less faith
stop
bullying you narcisistic human being
@lavish hemlock ?learnjava
why it doesnt work
bruh just help me i dont have the timeeee. i am going to die if i start watching a course
dovidas coming in with the hot takes without knowing what's going on
it doesn't work bc you pinged me before executing the command lmao
very cool
there's no way you're gonna learn writing plugins without knowing how to write in a first place
that's like trying to swim without knowing how to swim
because he thinks you're the one who doesn't know what maps are because he also does not read
this is the blind leading the blind taken to a whole new level
lmaaao
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
superior
dude i just need to make a single plugin thats the only plugin im making
๐ช
dumb bot, but ok
wweeeelllll
it's included so you can reference command names
without executing the command
like in this situation: ?learnjava
ok
you know in the last 27 minutes you could've just taken 5 seconds to google what a map is but instead you're asking people here to hold your hand so they can guide you through the very basics of java until they create something for you that works
also allowing you to put ?learnjava anywhere in the message to execute it causes multiple complications
e.g. "how do you locate the start of the command?"
this is like me saying I want to make a simple game without knowing c#/c++/c/anything related to game making
why are you trying to do the ?" command?
? is a good prefix but if you substring by first occurence of ? you'll run into the problem of people using ? as punctuation
can someone thanos snap me before i start thinking about watching the course PLS
just google it "what is a map java"
dude i dont get it
So basically map is a data structure that could access things very quickly, using hash function.
Key: Value
you set the key for the value, via .put() method
fast like sanic?
put
you get the value by supplying the key that you've provided
lol
.put
i need a scoreboard not a google map
i give up
stop bullying him
karma is a bitch for me i guess
u give up on helping but im thinking on giving up on life
have you managed to create a simple plugin
that even loads in the server
yes
declaration: package: org.bukkit.scoreboard, interface: Scoreboard
here's the API for the scoreboard (1.9+ only)
This makes so much sense
omfg YESSSSSSSSSSSSSS
are you on 1.8?
no
these edits are hilarious
i read 1.9 only
then you can use this API
but its 1.9+
1.9*+*
sooooo its ok
meaning 1.9 or higher
thanks
Anyone know wtf is wrong with my recipe?
ItemStacks:
https://paste.md-5.net/eberihayip.cpp
Recipes:
https://paste.md-5.net/jofulopemi.cpp
Issue:
https://cdn.discordapp.com/attachments/776188908257148949/894290726010126468/2021-10-03_12-31-39.mp4
if you're not on 1.8 then you should have no problems
i wanted to die for the last 46mins but now its ok
1 tip: learn to google, if anything
wait, i mismatched the bossbar with scoreboard, this should probably work with 1.8 too
imagine useing google
๐ฏ
uwu VanillaTweaks dark mode
UwU
I use Google lmao
that's why you're doing the googling and he's asking you, his secretary, what to google
oh
yeah
i use opera gx ๐ณ
its the best
i speak enchanting table language
oh
โแท๊๊๐น แฒ|| โธโโธแทแญ
โแท๊๊๐น แญโโท
Tโแท แตโโทโธ ฬฃ แโใช โท๐นแญแท แใชโธ โธ ฬฃ โแท แญโ๐นโด โดแแญ ๐นใช. Iโธ ฬฃ โดแแญ โโโธโธแทใช โโท๐นแฒ แญโโฃโโธ ฬฃ ส|| แ แฒแแญแญ ๐นโ ๊แทแโแทแญ แใชโธ แญโโทโสแญ.
for anyone wondering, this translates to "your mom"
oh
keeping it classy when asking for support, I like it
english only pls
vodka
that's the standard galactic alphabet
and russian
at least learn the names of the things you're pretending to do
english please
he says he thinks we're very dumb and that it's bulgarian
can you just kick him at this point
you do know there is a ban hammer in here
I somehow don't buy it that you are sorry
I doubt you ever will
if you wanted support maybe you shouldn't call the people you're asking support from idiots
i havent called anyone an idiot
if you're thinking you're clever because you deleted the messages then you are in for a rough ride buddy
?kick @outer steeple
Done. That felt good.
i think i just popped my jaw
i was biting down on my teeth and the right side popped
come over to my place I'll pop it the other way
I meant punching you deviant
medical procedures like punching someone in the jaw usually aren't
we are men of culture in here
maybe not a discussion for spigotmc discord
indeed
dms or ๐ split
spigotmcafterdark
taps are my fetish
and here we go
now this is appropriate
i love it when they are wet
very #help-development oriented
cursed words
#general for non-help discussion perhaps ๐
well.. in a way is a form of personal development as we are learning things
begging for a cursed response
I'm just putting off debugging
it'll be the end of me
I don't know what I'm supposed to do for my current project so I'm procrastinating
I know what I am supposed to do for my current project and that's why I'm procrastinating
im alrdy finished with my project im just too lazy to set it up on the server
the plurality of man
yoinking arenas off google is hard man..
look at these cursed issues I have to fix https://paste.gg/p/anonymous/ccdf996ad4354187ac3c9a106407006f
brah
I can't tell people to uninstall regional protections and I don't even know what's causing it in the first place
I ask people if they're using world protection plugins and they say no
then I ask if they use wg and they say yes
๐คฆ
hook to it then
then I ask for a list of plugins and they have 5 overlapping regional protection plugins
I do have wg taken into account, just not the other ones
What is wrong with Spigot rn lol
https://paste.md-5.net/gutizilupe.sql
what's worse is that this system is already built to bypass this issue but clearly not correctly
It only errors the first time the item it's looking for goes into the table
if (inventory.containsAtLeast(Items.Soularium(), 1)) {
if (!inventory.getResult().isSimilar(Items.SoulVial())) {
inventory.setResult(new ItemStack(Material.AIR));
}
}
at me.nathan.soulbound.listeners.PrepareWorkstations.prepareCrafting(PrepareWorkstations.java:32) ~[?:?]
are you looking for something that isn't there yet
I know, but it makes absolutely no sense
Seeing as it still works and only happens the first time you put the item in
if only paste md5 was working for me
Line 32 is the Items.SoulVial() part
windows yells unsecured everytime i open it
why are paste websites so cursed in 2021
Yes
But anyway, anyone have any idea why tf Spigot is doing crack and giving me an error like that then proceeding to work as intended?
why is every map i search with the tag "schematics" a fkn world map
already shared my idea
Seeing as it still works and only happens the first time you put the item in
yeah
that's what makes me think that's the issue
you're checking it when it's about to be there but not there yet
and subsequent attempts it's already there
It errors the first time I put the item in
well it's null so figure out which part of it is null
Item goes in > error > take item out > put item back in > no error
None of it should be null
It saying null makes no sense
debugging time
Not sure how I would even do that with this
fuck
debugging 10-1
when I debug I just spam sout's everywhere
I have a class for that
you guys debug stuff wut?
facts
until smth pumps positives