#help-development
1 messages ยท Page 1677 of 1
move it to the left
it shoudl be centered without the +
- 80 is not relative
The client is fine, it still have FPS and can move. The server doesn't respond while the many particles are spawned.
ok, but don;t use + 80, use a calculation from scaledWidth
then you are spawning too many in a tick
The action isn't showing up in the timings, and it says after on I would have 20 TPS.
so would sr.getScaledWidth() - (this.width / 2), sr.getScaledHeight() - (this.height / 2) get the exact center?
So I assume some internal component is overloaded? But which one?
Yes because you are spawning them ALL in one tick
you are refusing the let the server do anything else
These are particles, spawn them async
It "should" work
But it's not the server thread which is doing the work. So what is actually going on?
You know what I mean here?
no
What do you mean?
How are you spawning them?
something like if the client width is 800 you would divide by 10 to get 80
so if you want it to alwasy be in the correct relative position, no matter the client size you use + (clientWidth/10)
but what if you don't want it centered?
It measn if the client is 800 you will add 80, if its 1500 you would be adding 150
you are adding an offset of center
I'm lost
without any + you shoudl be drawing it in the exact center
The server was freezed here for 3 seconds. But timings show a load of 6% only and 20 TPS.
You never answered my question
While the system cpu rises by 10%. So something must happen internally.
you never add nor subtract hard coded numbers
player.spawnParticle(Particle.VILLAGER_HAPPY, vec1.getX(), vec1.getY(), vec1.getZ(), 5);
you calculate teh value you need
I use this line.
so I shouldn't do this.width / 10 + 150
Do everything in proportion to the screen width/height
everything should have some relativeness to the size
yeah I'm sorry I'm still confused
There is nothing in those timing lagging your server
Yes. But the server is still freezing. Thats the question actually.
what is this.width?
Think about a scenario where you drag the window so small its less than 150 pixels
the thing you are trying to display would fly off the screen
because its + 150
you have to make sure that it accounts for those cases too
so you cant use + CONSTANT
or - CONSTANT
in other words, the location has to be dynamic
so always divide or multiply?
Always divide, multiply or whatever
You calculate it based upon the client width
so never do addition or subtraction
as I said, + (clientWidth/10), would add your 80 if the width was 800, and 150 if it was 1500
You can add and subtract, but not CONSTANTS
you have to calculate the offset
so how is 150 a constant?
so I would have to do something like + (clientWidth/10 * 2),
why *2?
ya
..
you should know this
you know when building responsive sites
you have to make everything relative
That is literally (clientWidth / 5)
lol
I've only done it like twice
it doesn;t really matter how you calculate it. You showed you wanted it 80 off-center, so I showed you if the width was 800 then dividing by 10 gave you the offset you wanted
just to mess around
is simply calculating the location based upon the client width so, if the width changes the offset moves too.
Example, you see in your code how it calculates the centre by dividing by 2?
yea
it doesn;t say teh center is 400, 300
400,300 is using constants
it calculates the center
no
maybe we should show him a swing example
dividing by 2 is calculating the center
hard coding the centre to be 400,300 is setting CONSTANTs
so if I did sr.getScaledWidth() - (this.width / 2 + 30) 30 is a constant
No, + 30!!!
ok
can i repaste a question
so if I wanted a + 30 do I divide by 3?
Examples:
width/2 + 30 -> not good
width/5 + width/2 -> good
width/3 + 60 -> not good
width/5 - width/7 -> good
No
you have to think relative here
dont think absolute
what kind of sql url do i need to pass into DriverManager.getConnection()
No suitable driver found for mysql://localhost:3306/logReader
so you are saying sr.getScaledWidth() - (this.width / 2 + this.width / 5) is fine?
it's a division now?
no context lol
it would be 1920 - windowSize / 2 + windowSize / 5
yes
what if I needed it like 1 pixel up?
you don;t move by pixels
well you can
but it will be different for every resolution
Okay actually the particles are lagging my connection. Not the server.
Are there any limits a single connection can process?
line 21 onLogin
This is a really simple question that can be answered via google
if (e.getWhoClicked().getInventory().getItem(e.getHotbarButton()) != null && e.getWhoClicked().getInventory().getItem(e.getHotbarButton()).hasItemMeta() && e.getWhoClicked().getInventory().getItem(e.getHotbarButton()).getItemMeta().hasDisplayName() && e.getWhoClicked().getInventory().getItem(e.getHotbarButton()).getItemMeta().getDisplayName().contains("Bonemerang") && e.getWhoClicked().getInventory().getItem(e.getHotbarButton()).getType().equals(Material.GHAST_TEAR)) {
e.setCancelled(true);
}
messy line, but why does this
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at net.minecraft.server.v1_8_R3.PlayerInventory.getItem(PlayerInventory.java:433) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory.getItem(CraftInventory.java:47) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at dev.karar.alc.gui.GUIManager.onInventoryClick(GUIManager.java:94) ~[?:?]
MainEngines.stats.put(player, stats);
I'm not even going to look through that god line of code.
stats is null
If I did 1920 - (580 / 2)
you don;t use the 1920
well shit how the fuck do i clean up that line of code if i need a null check for every method
no?
its not that...
You only care about teh window width
so then I don't use ScaledRes
alr
?dry
Think of the window as a piece of paper. Its on the screen but it doesn;t care what size your screen is
damn it
The only thing your drawing program cares about is teh size of the paper
so say the window is full screen
so 1920 x1080
and I did this.width / 2
what does the 960 do?
As far as your drawign code, the paper is its whole world. It doesn;t matter where it is on the screen
is that the position?
960 would be the center
but
don't think of it as 960
ignore its value, only think that its the centre
its teh width / 2
right
0 is left, width is right, centre is width / 2
so lets say I had this window the arrow is where I want something drawn in the center
so any other positions you want on that paper you calculate. Values have no meaning here.
I would want to multiply too?
Depends
so I can achieve that?
multiplying is fine, but what are you multiplying?
width?
Well, if you want to draw that box, you would need the box width and height.
right
so you want it in the centre, you need to start drawing the box left of centre by half of the box width.
are you having fun with drawing images on mc client?
then you get half of the box on each side of centre
you said it was left?
teh value zero is left of the page
yeah
forget numbers... the values you need to wipe from your mind.
isn't that want I want or?
Here, another way to think of it is:
Suppose you are working with absolute right. So you have a 1920 x 1080 moniter and you want to place a dot at (224, 540).
So if you were to use division, it would be equivalent to (width / 15 + width/20, height/2). Because 1920/15 + 1920/20 is equal to 224, and 1080/2 is 540. Now what I said above is going to be what you will have to put in. Notice that how I never include any constant values. All values are dynamic within that coordinate.
when you want to place things on teh screen you have to decide where they go relative to teh paper itself.
quik maffs
they can be relative to centre, relative to left or right
elgar, are you leo?
ok ok
leo?
wait
you speak like him lol
Not me.
LeoCab, the spammer guy, was banned here few days ago, long story.
maybe treat it like a graph
1920 is the width of the graph
lets say you wanted something drawn up against the left, you'd set 0 as x
And also another way to think about it is math. Suppose I had a cubic 3x^3 + 2x^2 + 6x + 5.
3 is the leading coefficient
2 is the quadratic term coefficient
6 is the linear term coefficient
5 is the constant term.
When we refer to constant we refer to that specific last element. Notice that 5 has no relation to x. 3x^3 has x cubed. 2x^2 as x squared. But 5 has nothing to do with x.
what kind of sql url do i need to pass into DriverManager.getConnection()
No suitable driver found for mysql://localhost:3306/logReader
lol
make a thread about this
xD
i asked my question 3 times in 30 minutes ๐ฆ
Yours was teh sql connection line? Yes I told you to google it. Its a really simple answer you can find in under 2 minutes
yea
ah i see it now my bad
i didn't get notified
Sorry
ur good
ok, now lets say you wanted something drawn far right.
You would set x to width - widthOfItem
wait what
Now you know how we said don;t use constants.
yea
you can, if adding things like border spacing
so it's not right up against the border?
yes
hm ok
ah you changed it
which is line 21?
That screenshot says it can;t find stats so possibly MainEngines isn't the correct class name?
I would set x to 0 then add something
yes, but be careful
is the name of class
why?
because as teh resolution increases you will want teh space to grow with it
and I don't want that right
what this command for post my code?
?paste
thx
Your UI shoudl scale
wait wym space
PlayerManager: https://paste.md-5.net/okujuwosak.java
OnJoinPlayer: https://paste.md-5.net/ibajopakob.java
like the empty space?
oh you are using teh name stats as both a static and local variable
Erro
stats in your main class is null
This is defined but not initialized. Its null
stats = new HashMap<>();
Is it the same if I wanted to do the height
yes
Every time the player enters the server will it be put back into the hashmap or will it overwrite?
the reason everything is relative. a 5 pixel gap on the left is going to look ok on a 1080 monitor. That same gap on a 4k monitor is going to be invisible.
It will overwrite the old entry, BUT don;t store Players. store their UUID.
so if I wanted to achieve that image before
I'd do
0 + 120, 0 + 80, this.width - 100, this.height - 80
IF you only ever ran at that resolution
hm
all are constants
so I would do 0 + this.width / 4
so my code is getting the job done, but it feels extremely sloppy, any tips?
What is this.width?
then no
you told me not to use Res size
you divide by 2 to get centre
then subtract half of the width of the box you are drawing
no
an example of my slop is that for my gui im creating a new instance of the class that has the inventory variable, and then storing the instance of the class in a hashmap so if the player opens it they get a custom generated inventory based on their permissions
what are you using to specify the width of the rect?
wym
teh rectangle you are going to draw
are you talking about this.width
ok so this. width is the size of the rectangle you are wanting to draw?
no
what is
this.width is the application window size
you tell me
I mean I didn't make the variable
part of forge
so
this.width is the screen object
meaning the rect right?
if you say so ๐
so width is teh size of the rectangle
I guess so
to draw in the centre java centre = pageWidth / 2; x = centre - (width / 2);
if you want to move it right of centre x += (pageWidth / 10)
try sysout the value and see
I guess
what the hell
every time I try to print sr.getScaledWidth()
it changes it to ```java
System.out.println(this.width "/" + sr.getScaledWidth());
The IDE's are learning. When they start talking to each other we need to be worried
IDE spittin shade ;o
what should I do
like im not even joking
run for the hills and get some weapons
Its alive
if I add a + to it
it removes it
how do I clear my cache
found it
okay yea
looks like im not printing
how else can I check Elgar?
sysout always
Yeah, I don;t use IDEs that don;t do what I tell them to do.
BRUH
I can't change anything in my ide
it just adds the sysout thing
and removes what iadded
start with ""+
huh?
then the field
oh my god its because I had the class opened twice
so this.width is 427 and sr.getScaledWith is 427
so I guess they are the same thing?
seems so
no
2
alwasy find centre
but you need to width of the thing you are going to draw too
so I should do width first then x?
uh?
are this.width and width different objects?
no
then no
oh
so then what's this?
pageWidth is the page you are drawing on
width is the width of the item you are going to draw
are you guys really still talking about this
as I said, you need the width of the item you are going to draw
so I need to some how get the width of what im drawing
you should have the width. you can;t draw it without knowing
again no, thats the page you are drawing on
How am i drawing it then
if I don't know it
wait
is what im drawing
because somewhere you already have the width
is the width the this.width / 2
I can tell you how to calculate positions and do the math but its your code. You need to understand what variables are what.
I'm sticking with this.width / 2 is my item width
its not
well sr is def not it
do you have a texture width?
what is it?
If YOU are drawing a rectangle you MUST have its dimensions
you can;t draw a rectangle without them. Its impossible
if (player.hasPermission(mainClass.getConfig().getString("permissions.discord"))) {
would this work?
config:
permissions:
discord: "slashtools.discord"
media: "slashtools.media"
youtube: "slashtools.youtube"
instagram: "slashtools.instagram"
twitter: "slashtools.twitter"
website: "slashtools.website"
store: "slashtools.store"
forums: "slashtools.forums"
?
uh mc.displayWidth is different then this.width so now I'm legit confused
how much different?
then this.width is correct. its yoru rectangle
ok
and displayWidth is the page
so that's my item width then
yes
yes
mc.displayWidth / 2 - (this.width / 2)
ok
yes
so at this point im allowed to add a constant right
no
you are relative to centre
so to move it left or right x += mc.displayWidth / 10
or whatever you need to get it in teh correct place
scaledResolution is probably to do with Minecraft UI scaling
idk
anyway I'm off to bed
umm now none of my cmds work
im stupid
lol
I didnt put it in the plugin.yml
wait how much spaces do I do for a command in the plugin.yml
wait fixed it
permissions:
discord: "groups.default"
It still says I have no perms?
yes
debug it
print the perm that you get from the config
print if the command the registered
mabey I remove the "" or add ''
ok
System.out.println(mainClass.getConfig().getString("permissions.discord"));
nothing printed
what
no error and no null?
oh wait
then you are not registering the command in the main class
wp
wait is there a perm for the Default Group
What do i do with setLockโ() so that i can lock a chest
Doesn't everyone have the default group?
Why do you need a separate perm for it?
declaration: package: org.bukkit.block, interface: Lockable
permissions:
discord: "slashtools.discord"
media: "slashtools.media"
youtube: "slashtools.youtube"
instagram: "slashtools.instagram"
twitter: "slashtools.twitter"
website: "slashtools.website"
store: "slashtools.store"
forums: "slashtools.forums"
I need it so people can set whatever perm they want
but how will they set it to default group
btw it prints group.default
because in my config I set it to group.default
well i dont really see the point of having customizable permissions in the first place
oh
^
but ik luckperms gives players group.<id> permissions
not sure about other permission plugins
Why is this so confusing ugh
Ok thanks ill have a look
that's doesn't really help me but ok
What are you looking for exaclty
I want to be able to lock a chest
and only have the person who placed it down be able to access it
im not sure if setLock would be useful in your case
ok
iirc Lockable makes it so that you have to open the chest with an item that has the name of whatever you set the key as
ok
Yeah, When a lock is active an item with a name corresponding to the key will be required to open this block.
i dont think you can do that like that, you could save the location of the chest and the player that placed it
other than that idk
I'll try that
how would i have 2 arguments or what ever it is?
public void onPlace(BlockPlaceEvent e event) { the event is red
@EventHandler
public void onPlace(BlockPlaceEvent e event) {
final Block b = e.getBlock();
if (b.getType() != Material.CHEST) {
return;
}
final Player p = e.getPlayer();
System.out.println(p + "Placed down chest");
}```
this
Use either e or event, not sure why youre putting both
event.getBlock().getLocation() i havent added this yet
which is what needs the event
ok
You probably want to look into using CompletableFutures
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.chrissquartz</groupId>
<artifactId>nocheststeal</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>NoChestSteal</name>
<description>Players can't steal items in chests</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>chrissquartz.cf</url>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>```
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</build>
</project>
What's wrong with it agian`
public static void getMoney(OfflinePlayer player) {
Bukkit.getServer().getScheduler().runTaskAsynchronously(MainEngines.getPlugin(), new Runnable() {
@Override
public void run() {
double i = 0.0;
PreparedStatement stm = null;
try {
stm = connection.prepareStatement("SELECT * FROM `players` WHERE `uuid` = ?");
stm.setString(1, player.getUniqueId().toString());
ResultSet rs = stm.executeQuery();
while (rs.next()) {
i = rs.getDouble("money");
}
} catch (SQLException e) {
console.sendMessage("ยงcLBEngines: Ocorreu um erro ao ver o dinheiro de " + player.getName() + ".");
}
}
return i;
});
}```
How to return double in async?
help
.
public static CompletableFuture<Double> getMoney(OfflinePlayer player) {
return CompletableFuture.supplyAsync(() -> {
// Do your SQL stuff
return money;
});
}
I'm trying to remake skript code in java but
wait im gonna google it first
wait i rememebred nvm
Need help
Why isn't this working ?
@EventHandler(priority=EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent event)
{
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
String name = event.getName();
String regex = "\\d+";
if(name.matches(regex)b || name.toLowerCase().contains("mcdown") )
{
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "STOP SPAMMING OUR SERVER!!!!!");
}
}
}
getEnvironment() was working before for me but now it isnt working at all and i cant figure out why, Ive tried using it in different classes and all kinds stuff but it wont work again, how do i resolve this? for example player.getWorld().getEnvironment(); works up to getEnvironment()
ok nvm i guess? i added spigot as a dependency but i already had purpur so im unsure of why it wouldnt work
I have a Survival world and a custom world named as lobby but I want to teleport the player from survival world to custom world as he joins the game. How to teleport player? and pls ping me
World lobby = Bukkit.getWorld("lobby");
@EventHandler
public void onPlayJoin(PlayerJoinEvent event){
Player player = event.getPlayer();
player.teleport(lobby.getSpawnLocation());
player.playSound(player.getLocation() , Sound.ENTITY_EXPERIENCE_ORB_PICKUP , 10,1);
player.setGameMode(GameMode.ADVENTURE);
if(player.getWorld().getName().equalsIgnoreCase(MainLobby.lobby)){
event.setJoinMessage("ยงcSG [+] " + "ยงa" + player.getName());
}
}
I am using this event
AccountManager.getMoney(player).join() or AccountManager.getMoney(player).thenAcceptAsync(money -> stats.setMoney(money))
You can use just thenAccept(Consumer)
It will run on the same thread
But yeah also make sure the money variable is volatile since it looks like it got state
How can I despawn a Wolf temporary and spawn when a action is preformed exactly the same wolf?
I saw something about NBT data setting it invisible but how would I do that, and does the wolf then really attack nothing?
I would use nms to save the NBT
How can I remove a permission to a vanilla command (e.g. "minecraft.command.msg" from a player?
Are you making your own permission plugin?
If you use LuckPerms (like you should) then use its api to remove a permission else you could go with the vault api.
No it's not a dedicated permission plugin, it's just a plugin that needs to manage some permissions :P
Oh
ah so an API is the best option?
Well Iโd argue that yeah
I would recommend hooking Vault or LuckPerms like Conclure said
is it worth it just to disable a few vanilla commands?
Though making your own permission management system can be a good way to learn (3
yes yes I want to learn :)
You could alternatively block those commands with the pre command event
I'd just use LuckPerms without an api hook then
that's what I have setup rn, but tbh it doesn't seem like a very elegant solution... it's basically just blocking a command that equals "/msg"
also ideally (not necessary though) it would be nice to have the command not even show up (turn red) in chat
Can't I also use effects?
.setAI ?
It can't attack stuff
It can also take damage
Ok link?
Google it
Either
Shading is enough?
You can shade or use as plugin
Ok I will shade it then
Will the wolf then also be attacked or moving?
Ok and what do I need to set to make him invisible?
((CraftEntity) wolf).getHandle().setInvisible(true);
((CraftEntity) wolf).getHandle().isInvisible();
@chrome beacon will do this the same?
try it and see
Ok
What do you need?
The crafting matrix is simply an array
to make a non existent crafting table to test out recipes for my existent crafting gui
Bukkit.craftItem actually makes an item with no interface or input from the player
?paste
ok ill do that
ty
Asking whats wrong with it is unlikely to garner any response. you don;t tell us anything. like an error/warning, what its not doing that you think it should
If i want to make a server selector will i need to use bungeecord or can it work with just spigot?
multiple servers require a proxy like Bungee
You can;t create any server selector UI
You create a lobby server, where all players join and pick a server from there
i know ๐ but right now i made a cheap version by using command panels and permormCommand to that selected command panel
lol
i want to make a full on server selector without command panel ;3
Explain what you mean by "server selector"
so, a item spawns in inventroy, right click a gui opens then bunch of servers go into that gui... you select one and it sends you to a certain server that you have selected
You need to learn custom GUI and plugin messaging channels
Seriously? You ask questions, I give answers and you back chat!
If you don;t have an actual question stop wasing time.
do i need to place bungeecord in jre system libery or just spigot
Opening a craftign menu is not that easy. Its not as simple as an inventory due to the crafting logic behind it.
https://paste.md-5.net/niruvumuxu.xml this is the error i've gotten Unrecognised tag: 'resources' (position: START_TAG seen ...</url>\n <resources>... @15:20) @ line 15, column 20
no i'm making a custom one
ok fuck it, bukkit discord server is more smarter than this
You need to move xml <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources>Inside your <build> tag
Javadocs
where do u think i got dis from
prouddesk do you think what you're doing is helping
Yes
I'm not sure what you are attempting to do there. You are reading specific slots from an inventory
I am giving advice
oh ok :/
i do not want any of your "help" or "advice"
To look at the docs and googling, if you haven't already.
as i've said, im making a custom crafting gui
Recipe recipe = Bukkit.getCraftingRecipe(craftingMatrix, e2.getWhoClicked().getWorld());
if recipe == null then thats not a valid recipe
already tried doing just craftingMatrix, doesn't work
it says the required type is ItemStack[]
You are trying to get an ItemStack not a recipe
getCraftingRecipe returns a Recipe not an ItemStack
you use that Recipe to get the result
i was told to use this
Yes you can use that
but you first get teh recipe, then check its not null, then get the result
am confusion
Thanks it works now
Recipe recipe = Bukkit.getCraftingRecipe(craftingMatrix, e2.getWhoClicked().getWorld());
if (recipe == null) return;
ItemStack result = recipe.getResult();```
return is when you want to exit without doing anything else.
, if its a registered recipe it will work
it has errror
what error?
-_-
oh you are using a List
^^^
convert to use an array or convert your list to an array
yes, arrayLIST not an array
ArrayList != Array
ok
So i have this
System.out.println("Chest was placed at" + loc1);,( and some coords here )```
and it print's out ```atLocation{world=CraftWorld{name=world}``` which i dont want how would i do that?
oh nvm it just thread perms
location is an object
why would it print out atLocation? i don't see that anywhere
This is what it prints
why cant i post a image?
not verified
oh ok
It prints ```Chest was placed atLocation{world=CraftWorld{name=world},x=636.0,y=64.0,z=493.0,pitch=0.0,yaw=0.0}
ill just do it in text then
oh xD
I mean it doesnt matter like im only gonna see that
Just would want it a bit cleaner
if you want for example
Chest was placed at X=123, Y=123, Z=123
you'd do
System.out.println("Chest was placed at X=" + loc1.getX() + ", Y=" + loc1.getY() + ", Z=" + loc1.getZ());```
ok
same as printing out a player's name
Player player;
System.out.println(player);
would print out smt like
{CraftPlayer=<playername>}
yeah i got that already
What was the code for sending built jar to another folder ( plugin folder )
I had seen it before but forgot what it was
in pom.xml?
yes
sorry probably should have said that
ok thanks, that's probably the last thing i annoy you with bc i gtg soon
asking stuff is what the channel is for lol
ยฏ_(ใ)_/ยฏ
i'm gonna play some bo3 tho, so i'm out too
cya
Im trying to hook vault economy api, when i do economy.getBalance(p) it prints error to console saying the return of Vault.getEconomy() is null. Any solution?
?paste the error
Im trying to think of a way to "eat" the world from the edges - ie every second certain x/z collumns will be removed. (better version of a world border) but i cant really think of the logic to do so?
i cant just generate a random number cause i would like to eat outside in
Can someone help me I just downloaded the build tools but I cannot find the Spigot-API folder
Cannot find Spigot-API folder
Hey! I'm trying to use one of my plugin as a dependency in another plugin, but when I try to build using maven i get the error:
package nl.naimverboom.aresessentials does not exist```
Which is the plugin I'm trying to extend from. How do i fix this?
maven needs to know about the plugin. Importing it in your IDE will nto work for maven
I've added it like this, would that be right?
So how should i do it?>
Add it in pom.xml
It compiled, thanks people
what am I doing wrong because when I go full screen my drawing is gone but if im in windowed it's not
DrawUtils.drawRoundedRect(mc.displayWidth / 2 - (width / 2) - mc.displayWidth / 9, mc.displayHeight / 2 - (height / 2) - mc.displayHeight / 13, mc.displayWidth / 2 - width / 4, mc.displayHeight / 2 - height / 3, 2, 0x90000000);
braces. You need to be sure what math is performed in what order
are you trying to render slightly left of center?
yea
what are teh second two values of yoru drawRoundedRect?
width and height
then you shoudl pass width and height, not modified
so just width
yes
DrawUtils.drawRoundedRect(mc.displayWidth / 2 - (width / 2) - mc.displayWidth / 9, mc.displayHeight / 2 - (height / 2) - mc.displayHeight / 13, width, height, 2, 0x90000000);
will give that a try
you need to loop the hashMap and count the items
then your logic is bad
ah using all it only finds slots that match both ItemStack and stack size
HashMap<Integer,โ? extends ItemStack> allโ(@Nullable
ItemStack item)
Finds all slots in the inventory containing any ItemStacks with the given ItemStack. This will only match slots if both the type and the amount of the stack match
The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given Material is found, an empty map is returned.
Parameters:
item - The ItemStack to match against
Returns:
A map from slot indexes to item at index ```
meaning if you provide an ItemStack of size 1 it will only return stacks matchign the item and are of size 1
do you need to find a perfect item match or can you search for a material?
then you can either search by material or forEach the inventory yourself and match
What is the best way to teleport named entity to player respawn point?
Entity.teleport(location) could work
Unless youre on an older version there should also be a method to get a players spawn location
so first i need to get player's spawn location and then teleport the named entity to player's respawn point
You ever worked with spigot or do you want heavy help?
Yes i am a beginner
Lets assume your player variable is called p. You should be able to get their respawn location with p.getBedLocation or some method like that. Just look through the ones that pop up
Am on phone so i cant look up stuff properly
yes i can do that tell me what to do next
i am using java version 16
For some reason im getting this error: Can not set int field net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam.g to java.util.Arrays$ArrayList
And i don't know any way to fix i tried googling i didn't find any, the packet is: PacketPlayOutScoreboardTeam
tList.setAccessible(true);
tList.set(plPacket, Arrays.asList(new String[] { playerName }));
tList.setAccessible(false);```
entity.teleport(p.getBedLocation) or aomething?
check bed location. They may not have a bed
if no bed they will goto the world spawn
p.getRespawnlocation?
You can not fit an arrayList into a int
Look through the available methods for p @violet depot
it works in 1.8.8 tho?
Can i use this method?
So?
If it exists you can use it
it does exist
Then use it ๐
Scrolling through the available methods is how i usually fix all my problems
Sadly that doesnt work well outside of coding
only if i use like this Player p = (Player) e.getRespawnLocation();
Why is this happening I have a plugin in it but still it's not showing it
You cant cast a location to player
Check console, it may not be working properly
checked not working
no plugin.yml in your jar
You have a problem in your pom i think
I have a plugin .yml
Not in your jar you don't
nope
then select teh plugin.yml when you export your jar
k
I just want to teleport named entity to player whenever he dies using PlayerRespawnEvent
Paste code
Location l = e.getRespawnLocation()
Just teleport the entity to the player. Dont need to tp it to the respawn loc
Egarl like this ?
You can;t do that in the respawn event
okay thanks
The player hasn;t respawned yet so has no location
Event.getLocation or something?
Then how can i do this
You read above
untick classpath and project, and yes
k thanks
it disabled the option to finish
just unticking those shoudl not disable it, unless you have not built your project
what is building a project was not included in tuto
In this video I show how to setup eclipse with spigot and how you start making your first plugin.
Links
โ Eclipse: https://www.eclipse.org/
โ Spigot BuildTools: https://www.spigotmc.org/wiki/buildtools/#running-buildtools
Code for this episode
โ GitHub: https://github.com/Kariaro/HCSpigotPluginTutorials/tree/master/tutorials/Episode1
I do c...
the tuto
Best tutorial https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
k thanks
I m not into this maven stuff
It makes life so much easier
especially when you start wanting to interact with other plugins and libraries
is it java or a diffrent language
don't use youtube tutorails to learn
neither, its a build tool
oh k
How does the base game blend biome noise together? Been trying to write a world gen plugin and I can't wrap my head around it.
i need help! i have a private void method calling a public void method that is in another class, the private one is in a implements listener class and the public one doesn't extend or implement anything and it says that i can't call a non static method from a static context
Exactly what it says. You cannot call a non static method from a static one.
neither of them are static, both are void
static void? or void? You can have both.
just void
private void doThing(Inventory inv, ItemStack[] items) {
CraftingRecipes.recipesCrafting(inv, items)
}```
public void recipesCrafting(Inventory inv, ItemStack[] list) {
on recipesCrafting it says the error
in the second one
sorry i mean in the first one
in doThing
You're calling recipesCrafting like it's a static method, but it's not.
how so?
k i fixed it
CraftingRecipes recipesThing = new CraftingRecipes();
recipesThing.recipesCrafting(inv, items)```
oops i forgot a semi colon
Is there a way to modify block drops in a blockbreakevent e.g.
ItemStack item = new ItemStack(Material.GOLD_INGOT);
block.getDrops().add(item);
anyone know why player.getItemOnCursor() == null says it's always gonna be false? (btw this is on a inventoryclickevent
Player player = (Player) e2.getWhoClicked();
if (e2.getCurrentItem() == null) {
if (player.getItemOnCursor() == null) {
e2.setCancelled(true);
}
}```
Use .equals(null) when comparing objects, they have their own method for comparisons.
any help?
ok it still says it's gonna be false, this time i did it in the right area
if(args[1].equalsIgnoreCase("2")){
ArrayList<String> lore = new ArrayList<>();
lore.remove("ยง7Snipe I");
lore.remove("ยง7(Snipe) > Shoot fast arrows!");
lore.add("ยง7Snipe II");
lore.add("ยง7(Snipe) > Shoot faster arrows!");
meta.setLore(lore);
item.setItemMeta(meta);
p.getInventory().getItemInMainHand().removeEnchantment(SnipeRegister.SNIPE);
p.getInventory().getItemInMainHand().addUnsafeEnchantment(SnipeIIRegister.SNIPEII, 1);
}``` so args[0] runs and cancels args[1] how can i make it so args[0] doesn't run but args[1] does?
Command: /enchantments snipe 2
btw i did this in another area instead of == null and now that thing says it's always gonna be false
iirc in more recent versions if a slot or smth is empty its not null but Material.AIR
no one?
this works fine btw if (e2.getCurrentItem() == null) {
Then use that.
well atleast i think, it just doesn't say it's always gonna be false
but it's not the item i want? i need the item on cursor not the clicked item
Then remove that and just check the item on the cursor??
but i need both???
material air
Also try that ^ haven't tried any item compares in the newer versions.
someone please help????
thank you!!
I get an error when trying to add an item. I require an Item instead of ItemStack
Item item = world.dropItem(location, itemstack);
You can;t add ```
getItems
@NotNull
public List<Item> getItems()
Gets list of the Item drops caused by the block break. This list is mutable - removing an item from it will cause it to not drop. It is not legal however to add new items to the list.
Returns:
The Item the block caused to drop
manually drop as Austin said
Likely easier to just use BlockBreakEvent then setCancelled(true), setDropItems(false), event.getBlock().setType(Material.AIR), spawn the item then return
halp plz i do this if (player.getItemOnCursor().equals(new ItemStack(Material.AIR))) { but it give this error
https://paste.md-5.net/ihufalidex.sql
lemme try to test the type to a material instead of the item to a new itemstack
ok so i did that and now it's more borken
someone pls help
I'd definitely compare the materials. Are you sure that's the line that's giving the error? Can you give more code and point out the line it's giving the error on?
Is it possible to disable collision for a entity, so that they can walk through certain kinds of blocks
If you want to know how to delay stuff, it's done using BukkitRunnable
bruh?
You literally should never do .equals(null) because that will throw an NPE if the object is null
Lmaooo
Spawning 3000 particles per tick seems to overwhelm and fully consume a whole Netty Thread.
How could I optimize sending particles, to increase throughput?
why are you spawning 3000 particles a tick
I am making a display with particles, to make it smooth, it would update once per tick.
pass the task throughout multiple threads
Why not just add -org.spigotmc.netty.disabled=true
3000
/ \
Thread Thread
1500/thread, not clogging the main
i still dont understand why you're even spawning so many particles
is what you're trying to accomplish worth the network/cpu usage?
you told him how to disable it
You see line 15 which sends the particles? How would I split that up?
To my understanding the player has only one connection to the server? Or can it have multiple?
what
@waxen plinth Yea that's on me. Early over here. ๐๐ just wish I wasn't so sure of myself.
i screenshotted that message cause its funny lmao
imaginedev, The problem is, as the netty thead is overwhelmed, it doesn't respond to the player while the action.
I guess the problem occurs even on lower rates like 1000/2000 particles. So can netty handle just 1000 packets per tick?
we just dont understand what you are trying to do
and why you are trying to spawn 3000 particles...
cause that seems dumb
thats what im saying
I make a display for a chunk-based town system. It displays the borders arround the player.
So a single line of a chunk would aready consume 20 particles. If you sum it up, you get some thousand.
you dont need 3000 of that...
Sadly I donโt think that method works for players
Maybe its not 3000 but 1000, if I lower the render distance. But that still lags netty.
use it in playerJoin and damage event
you really shouldnt be doing it all at once
think of using Workers or something to divide it up
per tick
instead of spawning 3000 per tick
like do 150 per tick, and do that with 20 workers
so that it occurs every second
and divides it up
I mean, there is some room for optimization in the operation itself, true.
this isnt optimization
what you are doing is simply just impossible
or not impossible, rather, like
But are like 1000 packets the limit? What's the bottleneck?
๐ฉ
there isnt a bottleneck... you are just sending way too many packets
do you know how heavy packets get too
the bandwitdth too from that
sheesh
How much bandwitdth consumes a single particle packet?
if you are spawning like 3k...
https://wiki.vg/index.php?title=Protocol&oldid=16918#Particle, even though it's not a lot, you are sending way too much at once
its basically the same thing as if you are eating 30 graham crackers at once
you should instead do it so you eat 3 graham crackers per second or something, to divide it
so you dont time out the client or lag them to hell
Thats the point. It doesn't seem too much actually. To what I profiled, it measured 2KB of bandwidth usage.
But I don't now about the internals of netty, if it might perform badly with many small particles.
That's what I want to find out. So I can calculate the limit and optimize divide my operation by that.
thats not the point tho...
bruh
It's a point. Or can you explain why the limit is 1k packets and not 100k? What's the bottleneck?
Without knowing what's actually going on, there is no room for optimization of any kind.
You'd need to listen for healing events as well
Honestly using a repeating task isn't that unreasonable
Plugins can also set a player's health without firing an event I believe
ye
its probably in chat
Oh yeah but you can use a scoreboard objective
but then this happens. https://imgur.com/ILyQlci
also if I go full screen windowed it's not there
info pls?
such as?
sender is CommandSender not Entity
cast it to Player
what is wrong?
is...is there a reason the scoreboard has decided to append the score + 1 to the end of each line and stop updating?
Cannot resolve method 'playSound' in 'CommandSender'
there are no errors whatsoever and I didn't change jackshit, this just started happening pretty much at random.
give me hints not spoonfeeding
its because CommandSender does not have that method
cast player to the sender or use the method in the world
commandsender doesn't have a PlaySound method
you need to cast CommandSender to comething that does
are you using an IDE?
oh nvm
just saw the screenshot, mb
CommandSender can also be the console, and you can't play a sound to console lmao
ahh