#help-development
1 messages ยท Page 2049 of 1
I will have 1 block in middle of a radio of x (any amount of blocks) blocks
And i need to use do it with cuboid
I have been trying this since 1pm of my city, and its 7 pm
Vector bp = ...; /* block position */
int r = ...; /* radius */
Cuboid cuboid = new Cuboid(
new Vector(bp.x - r, bp.y - r, bp.z - r),
new Vector(bp.x + r, bp.y + r, bp.z + r)
);
``` like this?
this will make a cuboid of radius r around block bp
like
Oh rlly thanks :D im happy i would prob end up with this
----- -----
----- -###-
--#-- with radius 1 -> -###-
----- -###-
----- -----
advanced diagram
orby
Orby so the code will works in every "dimension"? Bottom, top, right and left?
yes
Allright
but in 3d
And would it lag?
no it calculates 2 points
Because i ill use it on PlayerMoveEvent too
nah shouldnt lag
How can I insert objects into the gui using length, height?
Really thanks
np
using x and y positon
i assume you mean doing like setButton(x, y, item)
yeah
you need to convert it do an index into the list
Orby do u have any problems if dm you
nah
Allright really thanks :D
Nice to meet you
you too
public final int width = ...;
public int getIndex(int x, int y) {
return width * y + x;
}
use that
Thanks
and then do inventory.setItem(getIndex(x, y), item)
nah like for chests its 9, for hoppers its 5, for droppers its 3
Okay, thanks
Take in count slot counts from 0
I rember one way i was so idiot that i didnt rember that slot counts from 0
orby, so final code is:
public class Cuboid {
private final Vector cornerA;
private final Vector cornerB;
private final Integer radious;
public Cuboid(Vector cornerA, Vector cornerB, Integer radious) {
this.cornerA = cornerA;
this.cornerB = cornerB;
this.radious = radious;
}
}
And then im stuck
Forget what i said
Why does a cuboid have a radius ๐
^
Because i wont use coner a and b. I woudl do it based a center block
That why using radious
But there is no radius that properly describes a cuboid
cuboid = circle
Youd just create a sphere at the centre of a cuboid
Ah yes ๐
doesnt spigot has already a object for that
yeah
Hello, I saved my default config.yml in UTF-8, but when I save the default config, the "รฉ" is converted into "\xc3\xa9"
https://prnt.sc/YoKKsliP1vk0
My problem is that it will be multi platform starting from 1.8x and lastest
So under 1.13 you dont have that class
i see
maybe your server does not support utf8
yeah
Dont use the "รฉ" so
will this still work fine ?
Yes, but I do recommend using non-deprecated methods
i want to be able to cancel the task
Runnable doesnt allow me to
runTaskTimer(plugin, (task)->{
task.cancel()
});
what
you may not need the () idk
wrote it from my mobile device
ups forgot the delay and period
?scheduling
iirc spigot have a method that takes consumer?
ohhh it worked
I finally end up with this class. What do you think?
public class Cuboid {
private final Vector a;
private final Vector b;
public Cuboid(Location location, Integer radiuos) {
this.a = new Vector(location.getX() - radiuos, location.getY() - radiuos, location.getZ() - radiuos);
this.b = new Vector(location.getX() + radiuos, location.getY() + radiuos, location.getZ() + radiuos);
}
public boolean contains(Location location) { return location.toVector().equals(a) && location.toVector().equals(b); }
public Vector getVectorA() { return this.a; }
public Vector getVectorB() { return this.b; }
}```
Personally using an x y z | x y z is easier to do contains checks.
Where?
Within the class. Rather than using vectors
That's just a BoundingBox
I know i do it because 1.13 lower doesnt have the class
I just store 2 vectors to dont have many variables
Yeah but less isn't necessarily better
do anvils have a pdc?
Vector math is more efficient java 16+ if you use the native math, below probably not so much
In conclusion my class isnt wrong?
Seems alright for just storing a cube, and its movable
My idea is to use it to save many regions
alright so i have this code right here. not to special right? except when someone does close the gui it outputs a giant stacktrace thats so long its longer than my consoles scroll limit
@EventHandler
public void inventoryCloseEvent(org.bukkit.event.inventory.InventoryCloseEvent e) {
if (plugin.isFrozen.contains(e.getPlayer().getUniqueId())) {
//normal gui stuff here except its part of a semi private library
}
}```
me when the log file doesnt show up anywhere
The logs folder
your logs folder is empty
no
it has logs in it
and logs from today
but not the logs from the time the error happened
Then you've got a bigger issue on your hands
and without the code we can't exactly help
@EventHandler
public void inventoryCloseEvent(org.bukkit.event.inventory.InventoryCloseEvent e) {
if (plugin.isFrozen.contains(e.getPlayer().getUniqueId())) {
Gui gui = new Gui("Frozen", 3, plugin);
//creating item and item meta
ItemStack barrier = new ItemStack(Material.BARRIER);
ItemMeta barrierMeta = barrier.getItemMeta();
barrierMeta.setDisplayName(ChatColor.RED + "ยงlYOU HAVE BEEN FROZEN!");
ArrayList<String> barrierLore = new ArrayList<>();
barrierLore.add(ChatColor.RED + "DO NOT LEAVE UNTIL YOU ARE UNFROZEN!");
barrierLore.add(ChatColor.RED + "LEAVING NOW WILL RESULT IS PUNISHMENT!");
barrierMeta.setLore(barrierLore);
barrierMeta.addEnchant(Enchantment.RIPTIDE, 1, false);
barrierMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
barrier.setItemMeta(barrierMeta);
gui.setItem(barrier, 12);
gui.setItem(barrier, 13);
gui.setItem(barrier, 14);
gui.setNoPermError("");
gui.setSoundOnNoPerm(false);
gui.openGui((Player) e.getPlayer());
}
}
}```
there isnt much you can tell from this code
the gui stuff is from a library that isnt widely known
is that causing the issue?
i cant tell
IE when a frozen player closes their inventory the error shows up?
the error happens once when the player tries to close their menu
but it doesnt happen again cause my panel says its throttled the amount of data outputted
You're not running it locally?
Try clearing the logs folder running it again. Once the error occurs do /stop and then check for the log
!paste
?paste
?paste
thanks
found mike a log file

Does your gui library have it's own logger?
Its possible to set a value to block so them i can identfy from the blocks ?
yup
Answering to me?
no
Oh lol
mmmm paper
to my knowledge it shouldnt be overloading from just calling the inventory close event
line 48 seems to be mentioned
gui.openGui((Player) e.getPlayer());
hmm
Does gui.OpenGUI happen to close any currently open GUI's?
If you open a gui when there is an other already there, it close it automatically
That's not what I'm asking
if i put a closeinventory method before calling the inventory opening
maybe that would help
Stackoverflow errors are often caused by recursive functions.
you're in the inventoryclose event
it shouldnt be calling it multiple times
so if you open an inventory but that closes the inventory to open the new one
hmm
You're looking at a stackoverflow error
Could you actually send the lib? Cause that's the issue here
heres the src
gui part is in objects
?jd-s
for me btw
com.woolmc.hyperfreeze.Events.InventoryCloseEvent.inventoryCloseEvent(InventoryCloseEvent.java:48)
is the issue
thats gui.openGui((Player) e.getPlayer());
How can i check in BlockPlaceEvent if there is a block which contains a custom displayname and lore??
count probably
when someone tells you they can help code, but they really mean they can configure other plugins
pain
rekt
You need to check the item meta of the event players held item
So when did you last update that library?
Delay that opening
not my library
I bet you that the issue is that it's calling the close event over and over again
its my other devs
The problem is, that the lib open a new inventory
so it close the inventory actually here
before the game closed it
and so it goes on over and over
what
I mean according to those comments it was "fixed" 6 hrs ago
i put a delay in
I cannot find it on BlockBreakEvent...
lets see if that fixes anything
Find what?
since it's "InventoryCloseEvent" the event isn't completed yet
BlockBreakEvent doesnt contain that method
? Get it from the event player
So, the lib open a new inventory, but, there is already a gui, so the game close it, and throw an other close event, but, lib open a new one, so close, and so on
infinite loop delaying the opening, will just make the close event perform and then the opening from the lib will just open and not close
Wait the block will not get from player hand, because it will be placed
i see
Get the Player and compare the item meta of their hand
I need to check when player break blocks if near a block with custom displayname and lore, and then do stuff
That why
Oh my bad I thought you said on place
Oh that why
You need to store the blocks location somewhere
I already keep it on my claim object
tbh, if you open the same inventory, just cancel the close event, it will be better
invcloseevent doesnt have a setcancelled method
Just check if the block that is broken is the one stored
So on place store position and either put it in a list if it has the correct meta or store the meta and compare it that way
plus thats the first thing i tried doing when i made the inventorycloseevent
Oh, yeah, it doesn't implements cancellable ๐ฎ
well, my explanation doesn't holds then
yeah
or that's it, but without the cancellable assumption x)
I mean you can always check the name of the inventory being closed and check if it's not the same as the one currently being opened
but still, you don't need to remake the inventory, just use the inventory from the event and reopen it with the delay ^^
with InventoryCloseEvent#getInventoty()
At least you can give it a shot, not sure that it will not give you a NPE here
No NPE will ever happen in this case
depend if the event once performed doesn't clear out the current inventory, or if the even itself isn't nulled after it performed (since it's delayed)
Haven't tried
Interesting, doesnt really seem like closing is implemented yet for that library beyond a sound
it hasn't to implement it since it's an api feature
I guess, ... seems to open on access - I am bad with gui libraries anyway
@viral crag i found the problem with my code btw
its a mc bug that i've now submitted a spigot PR for
needing help with this?
What's the number? I am curious if I had the same issue or not
how do I send how "broken" a block is to a client?
how would I go about modifying the hardness of a block (ie stone mines faster with my hand opposed to an actual pick)?
afaik i can send packets to simulate how "broken" a block is, but yea!
oh, oke
oh. aw. ||forgot to suppress the mention||
would it be possible with nms?
iirc it's hard-coded into the block settings so probably not without recompiling the server, no
asm?
You could only use bytecode modification with an instrumentation agent, JVMTI agent, or custom classloader.
Problem is that the first requires an extra launch argument, the second is a JDK exclusive feature, and the last requires your code to load before the ones you're modifying.
is it possible to get instance of OfflineProxiedPlayer
I need to check there ip I got there uuid
but I get null point if I try to get ProxiedPlayer
and I am hooking to litebans to check if they are banned and LiteBans need there ip
๐ Trying to optimize https://github.com/Crazy-Crew/Crazy-Crates. I noticed that the main issue was from the stripColor() method when checking if the inventory is a crate inventory or not. What would be the best way to go about erasing the stripColor() method entirely?
using 4.35% of the overall cpu which is causing some problems.
Could use InventoryView to identify said inventories
yeah
@
if you are using the remapped version
it is the 6th
and you need to listen the PlayerInteractEvent
as there the player start to pull the bow
how can i hook into the minecraft command system?
i made my own command engine which takes an input string and;
- executes the command
- creates suggestions for the command
- sets error messages (like the ones in brigadier above the chatbox)
i just want to get everything past the /
as a string
and then have the above stated outputs be sent to the sender
console or player
also for feature 3, this is what i mean:
the thing above
i guess 5 am isnt the time for development help
its weekend so yeah
staying up till 5:30 am or so
but i still need help
on my problem
Can I play music only to specific player?
no no you are right
Yes. Player#playSound()
You can also send other things like particles and titles as well.
How would I make a cmd like this /pg on
this is the code i already have
package com.quartz.pearlGame.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class PearlCMDS implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
String symbol = ChatColor.DARK_AQUA + "[" + ChatColor.AQUA + "!" + ChatColor.DARK_AQUA + "] ";
// /pg on
if(args.length > 0) {
} else {
player.sendMessage(symbol + ChatColor.GOLD + "/pg on" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game on");
player.sendMessage(symbol + ChatColor.GOLD + "/pg off" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game off");
player.sendMessage(symbol + ChatColor.GOLD + "/pg add <player>" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Add player to game");
player.sendMessage(symbol + ChatColor.GOLD + "/pg remove <player>" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Remove player from game");
player.sendMessage(symbol + ChatColor.GOLD + "/pg list" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Get list of players currently playing");
}
return true;
} else {
System.out.println("Only players can use that command!");
}
return true;
}
}
basically im not entirely sure how to do it using the args, I am relatively new to plugin making
I've googled a bit but havent found anything that helps me
if (args[0].equalsIgnoreCase("on") {
then whatever ur code is
I mean like jukebox music.
You mean the default discs? You can still do that with playSound().
thanks
Oh, you're correct, thanks!
Does anyone know anticheat plugin for spigot?
Example?
I'm on phone right now so it's hard to check javadocs, do you know by any chance to get the duration of the Sound?
I'm not sure if that one is possible. There are parameters for sound radius, volume, and pitch, but I haven't seen or heard of something for duration. You may be able to get away with hard coding values for that since the default game sounds hardly ever change.
Anyone have any code snippets on how to use InventoryView?
inventoryview is what the player sees
it has a top and bottom inventory
like when you open a chest
the bottom inventory is the player's
and the top is the chest
So I declare it using what though, a regular inventory?
player object should have a method to get
it
give me a second
im not actually sure how to get the object
Yea that's why I was confused lol
ive never used it
I'm looking for an alternative for stripColor()
As it seems to be effecting performance pretty harshly
String#replace() ๐
Player#getOpenInventory() returns an inventory view
You can, but they way to do it isn't recommended as you need to use the section symbol.
What should I use instead then instead of stripColor?
I was recommended to use InventoryView to check if it's the right inventory type
Not sure if that's my best option
Well, I'm pretty sure that stripColor actually does call replace(), which was part of the joke I was trying to make. String comparisons are expensive calls. You should ideally compare the inventory instances as it would be far more efficient. You can also use the InventoryViews to do the comparison.
Was thinking the same thing and you're completely right, uses 4.35% of a 20gb server to run stripColor() haha
lol. How often is it being called?
A ton I guess, I don't have direct access to the server but I was given this in the spark report
Actually uses 9%
Yea. String comparisons should really be your last resort option. There are some cases where string comparisons can be really fast, but they are few and far between. However, any other type of comparison should be significantly faster.
For sure, probably going to recommend a change to the original developer aswell
Am I allowed to ask questions about protocollib here?
yea
private void sendDestroyPacket(){
PacketContainer container = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
container.getModifier().writeSafely(0, 1);
container.getModifier().writeSafely(1, new int[]{this.disguiseEntity.getEntityId()});
try{
Games.getInstance().getProtocolManager().sendServerPacket(this.player, container);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
hi
can soneone help please
List<Location> list = ( plugin.getConfig().getlocationlist("loc"));``` i want to get locationlist in config file but it don't have any code about `getlocationlist ` how to get someone help pls
you cant get a Location from config
you store 3 numbers
x,y,z
and then convert it into a location
how to do that
yo, does anyone know how/where to get the java.utils package to import? I'm trying to get a random number rolled and internet isnt giving me any options to download that i can find
its in java
using intellij
builtin
how to import it?
just use the location object
im noob to java no idea what that means
not u
comes out as this (something of the sort)
o my b
are u using an ide
hover over it
and press import
hover over the error
intellij has a thing to import anything ur using
when ur typing it in
if u select it in the autocomplete
it will import it automaticaly
yeah it doesn't show still
Ok this is stupid. I've solved it by using someone else's code found in this discord, but I still don't understand why mine gives errors when I fill in the modifiers. This code doesn't even align with wiki.vg/protocol
I must not understand something here
it can't
"no documentation found"
๐
alse do you have anymetmod to when place block have ItemMeta like name "cow" then when break it still drop ItemHaveMeta name "cow"?
i dont understand that
like when you create ItemStack is grass have name: "cow" then you place the block after that you break the block and it still have name: "cow"
ok
is there a way to wait for ticks to pass in spigot?
yeah
use a bukkit runnable
with runTaskLater
it'll run code after a certain amount of ticks is passed
what's the import for it
sir
intellij will automatically import bro
intellij has an auto import feature
u dont need to manually import
over what
the class
what class
if you are typing new BukkitRunnable
hover over bukkit runnable
and click import
you should learn the basics of an ide]
before coding
Thank you
Using the args of /pg, I would want it to have multiple options/args like /pg on or /pg off how would i do this?
thanks
it didnt work, I have it msg the player but when i do it, it doesnt work
send the code
if (cmd.getName().equalsIgnoreCase("pg")) {
if (args[0] == "on") {
player.sendMessage("You joined the game");
} else if (args[0] == "off") {
player.sendMessage("You left the game");
} else if (args[0] == "help") {
player.sendMessage(symbol + ChatColor.GOLD + "/pg on" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game on");
player.sendMessage(symbol + ChatColor.GOLD + "/pg off" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Turn game off");
player.sendMessage(symbol + ChatColor.GOLD + "/pg list" + ChatColor.GRAY + " -" + ChatColor.DARK_GREEN + " Get list of players currently playing");
}
}
was just about to do that
dont use ==
ok
ohhhh
use == for enums n stuff
ok thanks
you should realistically use .equalsIgnoreCase
because if they do /pg ON it wont run
I just did /pg help and it sends the msg twice
bonk
how to edit this to get delay?
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class command4 implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (sender instanceof Player) {
Player player = (Player) sender;
Plugin plugin;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
}, 40L);
}
return true;
}
}```
Like obvious it's Plugin plugin but im just not sure what to put there
im trying to get this to send a server message after 40 ticks
whats the name of your class which extends JavaPlugin
Ya, the thing is that I didn't want to use NMS at all, anyways I have tools that end up being more handy than that :p
ty Anyways tho <3
test
would I use that?
the type of the plugin variable is the class that extends JavaPlugin
whenever you require an instance of the plugin you have to get the singleton instance of that class
there cannot be more than 1 of that class
you can do this with dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
so what exactly would I put?
Test plugin
assuming that the name of your class that extends javaplugin is Test
then to get the instance
you can use dependency injection ^
or you can make a static method inside of the Test class
i personally prefer the static method
create a private static Test plugin; in Test
and then in the onEnable set plugin to this
then make a public static Test getInstance() method that just returns plugin
doing that just piles up errors for me, without an example it's no good
ill give u some snippets from my plugin
created a static instance
in the onEnable i set that instance to this
mk
i did test.instance
and what happened?
no errors
what is this for?
Bukkit.getScheduler().runTaskLater(test.getInstance(), () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
}, 40L);
other classes
thats the whole point of this
so you can get the instance of your plugin in other classes
lots of things require an instance of the plugin
BukkitRunnables, NamespacedKeys
you lost me xD
nono it's the way it's being explained
I literally just need 1 entire example shown
and then i got it
not snippets
public class Main extends JavaPlugin {
private static Main plugin;
public void onEnable(){
Main.plugin = this;
}
public static Main getInstance() { return Main.plugin }
}
Main.java ^^
public class OtherClass{
public OtherClass { // constructor
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
}, 40L);
}
}
point of the static method
is so when you require that plugin object
you can just call Main.getInstance()
or in your case
test.getInstance()
ok will try it
what's the difference between ItemMeta#setLocalizedName(String) and ItemMeta#setDisplayName(String)
It's to do with languages i'm pretty sure
how does it even allow setting of localized names
still having problems
going to undo it
maybe if i sent my main and the command for it
send the code that's related
to enchanting
is 49 the slot where you put the item to enchant?
import org.bukkit.plugin.java.JavaPlugin;
public class test extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
this.getCommand("kit").setExecutor(new command1());
this.getCommand("test").setExecutor(new command2());
this.getCommand("complex").setExecutor(new command3());
this.getCommand("wait").setExecutor(new command4());
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
}```
main ^
package com.lerfing;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class command4 implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (sender instanceof Player) {
Player player = (Player) sender;
test plugin;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
}, 40L);
}
return true;
}
}```
^ command4
What do I change in main and command4 to get it to work
public class test extends JavaPlugin {
private static test plugin;
@Override
public void onEnable() {
test.plugin = this;
getLogger().info("onEnable is called!");
this.getCommand("kit").setExecutor(new command1());
this.getCommand("test").setExecutor(new command2());
this.getCommand("complex").setExecutor(new command3());
this.getCommand("wait").setExecutor(new command4());
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
public static test getInstance(){
return test.plugin;
}
}
for your main class
and then in command4
set plugin to test.getInstance()
How can check the player's cause of death from PlayerDeathEvent?
All I need to know is if they were killed by another player or not
Including kill cred like "burned while trying to escape x"
use EntityDamageByEntityEvent
check if the damager and victim are both players
there ya go
using instanceof Player
ok done, says in main cannot resolve symbol plugin, and in command4 it says cannot resolve method getInstance
yeah
To see if they died
What about when they died to something like fall damage @earnest forum? because fall damage is not an entity
are you sure u added my changes
Do I need to use another event for that
give me a sec
ive done this before
@tropic idol PLEASE use pastebin because this spam of chat is horrible
fr
Ok thx
import org.bukkit.plugin.java.JavaPlugin;
public class test extends JavaPlugin {
@Override
public void onEnable() {
test.plugin = this;
getLogger().info("onEnable is called!");
this.getCommand("kit").setExecutor(new command1());
this.getCommand("test").setExecutor(new command2());
this.getCommand("complex").setExecutor(new command3());
this.getCommand("wait").setExecutor(new command4());
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
}```
```package com.lerfing;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class command4 implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (sender instanceof Player) {
Player player = (Player) sender;
Bukkit.getScheduler().runTaskLater(test.getInstance(), () -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say ran a delayed command");
}, 40L);
}
return true;
}
}```
you didnt add the private static test plugin at the top of test
read carefully
Ah
@short raptor
in PlayerDeathEvent
you can call
EntityDamageEvent c = e.getEntity().getLastDamageCause();
EntityDamageEvent allows you to check the damage cause
Ohh okay cool
if (e.getEntity().getKiller() instanceof Player)
keep in mind this one is using the PlayerDeathEvent object^
np
ok really weird thing
when I run the plugin with stuff you sent it gives error in console including java issue
or something
send the error
but when I undo everything it goes back to being fine
just because theres an error doesnt mean you have to get rid of everything
27.03 08:09:01 [Server] INFO java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.lerfing.test.getCommand(String)" is null
27.03 08:09:01 [Server] INFO at com.lerfing.test.onEnable(test.java:13) ~[?:?]
27.03 08:09:01 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:520) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:434) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1.jar:3284a-Spigot-3892929-0ab8487]
27.03 08:09:01 [Server] INFO at java.lang.Thread.run(Thread.java:831) [?:?]```
yeah I can redo it
send the class
which one
test
k
import org.bukkit.plugin.java.JavaPlugin;
public class test extends JavaPlugin {
private static test plugin;
@Override
public void onEnable() {
test.plugin = this;
getLogger().info("onEnable is called!");
this.getCommand("kit").setExecutor(new command1());
this.getCommand("test").setExecutor(new command2());
this.getCommand("complex").setExecutor(new command3());
this.getCommand("wait").setExecutor(new command4());
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
public static test getInstance(){
return test.plugin;
}
}
did you not do that?
did you put commands: before it
version: '1'
main: 'com.lerfing.test'
api-version: 1.17
commands:
kit:
description: kit command
usage: /kit
permission: lerfing.kit
shit:
description: shit command
usage: /shit
permission: lerfing.shit
complex:
description: complex command
usage: /complex
permission: lerfing.complex
wait:
description: wait command
usage: /wait
permission: lerfing.wait```
ignore shit lol
you havent put "test" as a command
it doesnt exist
this.getCommand("test").setExecutor(new command2()); this line is the error
yes
I didn't need to do that with every other command
you are registering a non-existant command
this.getCommand("test").setExecutor(new command2()); get rid of this
and you should really get into the practice of naming your classes correctly
never start a class with a lowercase
understood
its not like
ok question
yea
so this part
return test.plugin;``` at the end of the code, what does that do
wdym?
for every other command I made
I didn't have to do private static anything
so why this one?
you need to do that because theres only 1 instance of the main class
What's wrong with this line? I don't understand why it "cannot be applied to" registerEvents
2nd argument is the main class
so just this
Is it possible to let a player execute a command and ignore if they have the permissions for that command?
Giving op before and removing it afterwards isn't an option since most permission plugins override the op feature completely
Oh ๐คฆโโ๏ธ
huh
you can make it
wait so getInstance could be named anything?
i assume not within your own plugin? if so no there isn't
ues
you can make it ILoveFortniteMethodAndMiencraftAndEmoting
literally whatever u want
alright I thought as much
too bad
its a method we make to retrieve the test object
as its required sometimes in other classes
ok 1 more question
go ahead
when you write test.plugin = this;
yea
what is this actually representing
Ideally you wouldn't be statically instancing your plugin's main class and instead you'd use proper dependency injection
thats cringe tho
No it's good practice.
you have to create new object of everything
No... you have one instance you properly pass through dependency injection.
i prefer using a static method though
I don't throw static getters everywhere in my projects for all its core components and I don't have hundreds of instances of them.
more convenient
this refers to the instance of the class you're currently in.
ok so this actually means test
what we're trying to get is the Plugin class because you need that for a bukkit runnable
so you set that static variable to the Plugin class
and then create a method to get that
So say you had a method public String getSomething() { return "something"; }, from within that class' method you can do this.getSomething()
yea
since the class is named test
no
That wouldn't work as test would have to be a variable that is of your class.
woot
So for instance if you did;
private Test test = this;
you could then use test
this is used for instance context
ok but then that means
test is used for static context (unless you have a variable named test)
you should really change the class to Test
this is the instance of the class you're currently in, in that case, that instance of Test
ok so the test object
So if you did private Test test = this, you're assigning the variable test to the instance of that class you're currently in. test would therefore function the same as this within that class.
correct?
Yes
mk
its confusing because his class is the lowercased "test"
i dont wanna hold shift while pressing t
yh, never name your classes with lowercase. Always follow proper naming conventions.
well you're gonna have to
otherwise your coding experience gonna be a hell of a lot more confusing
u realistically start variables with lowercase, so when you type in class names you might confuse them for variables
lmao
So I am currently trying to spawn a armor stand manually using packets, but this causes the receiving player to immediatly be kicked after adding the equipment metadata packet to it
What am I missing here?
private static void sendSpawnPackets(Player p, ArmorStand stand) {
PacketUtils.send(p, stand.getAddEntityPacket());
PacketUtils.send(p, new ClientboundSetEntityDataPacket(stand.getId(), stand.getEntityData(), true));
List<Pair<EquipmentSlot, ItemStack>> items = Lists.newArrayList();
for(EquipmentSlot s : EquipmentSlot.values())
if(stand.hasItemInSlot(s))
items.add(new Pair<>(s, stand.getItemBySlot(s)));
PacketUtils.send(p, new ClientboundSetEquipmentPacket(stand.getId(), items));
}```
I just found a solution for the problem. I can just run as console /execute as <playername> run <command>
That seems to work just fine
For vanilla commands at least but thats exactly what I wanted
Hey, how can you put "new" worlds in a different folder?
how can i solve?
update java
change java version
Hey guys, I'm having a hard time understanding what's wrong.. I am trying to read my querries externaly but it throws an error..
The error:
11:48:23 [SEVERE] at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
11:48:23 [SEVERE] at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
11:48:23 [SEVERE] at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
11:48:23 [SEVERE] at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:371)
11:48:23 [SEVERE] at me.caujasutom.tcore.TCoreBungeeCord.initDb(TCoreBungeeCord.java:124)
11:48:23 [SEVERE] at me.caujasutom.tcore.TCoreBungeeCord.onEnable(TCoreBungeeCord.java:40)
11:48:23 [SEVERE] at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:265)
11:48:23 [SEVERE] at net.md_5.bungee.BungeeCord.start(BungeeCord.java:285)
11:48:23 [SEVERE] at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
11:48:23 [SEVERE] at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)```
The SQL code:
```CREATE TABLE IF NOT EXISTS `TCore.Player_data` (
`UUID` VARCHAR(36),
`USERNAME` VARCHAR(16),
`IP` VARCHAR(35),
PRIMARY KEY (`UUID`)
);```
Do you mind if I use server version 1.8.8 java 11?
ok i know 4 am wasnt the time to ask for help so can anyone help me with this?
you need to match java version to the version that you are compiling plugin to
The querry code:
String setup;
try (InputStream in = getClass().getClassLoader().getResourceAsStream("SQL/Create.sql")) {
setup = in.readAllBytes().toString();
} catch (IOException e) {
getLogger().log(Level.SEVERE, "Could not read db setup file.", e);
throw e;
}
String[] queries = setup.split(";");
for (String query : queries) {
try (Connection conn = ds.getConnection();
PreparedStatement stmt = conn.prepareStatement(query)) {
stmt.execute();
}
}
getLogger().info("ยง2Database setup complete.");
}```
did you try to debug what "setup" prints out ?
because in.readAllbytes().toString() is mostly an array which then .toString() will not make bytes to string but obj to string
thats why you get "[B@5488b5c5" which is the product of an array.toString()
@young nest your probably looking for new String(byte[]);
When a ground item is destroyed (e.g. cactus, lava, explosion, void, NOT despawn), it causes an EntityDeathEvent right?
?tryandsee
EntityDeathEvent
I have tried and see'd and it didn't seem to fire so I'm just checking
I didn't know where to check if a ground item was a LivingEntity
ยฏ_(ใ)_/ยฏ
i am sure that an item is not alive O.o
An item isn't a living entity. It does not have hp
so then it wouldn't cause EntityDeathEvent
But what event would it be? I looked through the events list on docs but there wasn't any event
You could try the entity damage event
Yeah I'll try that
Hi, how can i make an item able to break a block in adventure mode?
How to cancel task after it's been done once?
new BukkitRunnable() {
@Override
public void run() {
boosting.remove(event.getPlayer());
}
}.runTaskTimer(Main.instance, 5, 5);```
If you only want it to run once don't run it as a timer
I need the action to be delayed
@EventHandler
public void Boost(PlayerToggleSneakEvent event) {
Player p = event.getPlayer();
if (p.isSneaking()) {
return;
}
p.setVelocity(p.getLocation().getDirection().multiply(35));
p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH, 10, 1);
boosting.put(event.getPlayer(), true);
new BukkitRunnable() {
@Override
public void run() {
boosting.remove(event.getPlayer());
}
}.runTaskTimer(Main.instance, 5, 5);
}
}```
scheduleSyncDelayedTask
Didn't know about that, thanks!
hi
the getCustomName don't work for why i search to do
so, i need to understand how to use the getMetadata() please
just " .getMetadata("name"); " ?
i need to get the name of a modded entity of customNPC's mod
Spigot isn't designed to work with mods
I'm sure it's possible ! :c
Well yes, but you might have to use NMS instead of Spigot API
what is that ?
Even worse
We don't support 1.7 nor hybrid forks
You're on a dead version. No support will be given
nice =-="
wow so recent
what is the problem ? if i want to use this version and i don't disturb you ? =-=
I don't have any problem with that, it's just funny to see someone using a 9 year old version instead of, well, just not doing that lol
for exemple, paladium is on 1.7.10 version
i can underdstand using 1.8 but whts the point of 1.7.10
i don't see any problem x)
1.7.10 is so different now I doubt anyone knows how to do what you want anymore
in 1.8 you don't have cauldron if my memory is good
what O.o
i think ppl use 1.8 because they want to stupid pvp mechanic
but 1.7.10 is just old and has even less features then 1.8
yeah i know :/
what's cauldron again
1.7 came out when I finished high school lol
forge with spigot plugins?
i thought he talks about the block O.o
yes
magma is a more up-to-date version
on 1.8 version ?
that is the problem
updating = problem?
i have try to switch to 1.12.2 version
1.12.2 is so old, why would anyone consider this an "update"? even 1.16 is already outdated lol
1.12 is like the 1.8 of 1.9 pvp
and i have found a lot of problem like : need to restart all my work
i mean... if you update to 1.16.5 ... why not update to 1.18.2 directly ?
magma isn't out for 1.18
Lmao my discord broken
forge with spigot plugins is a pretty bad setup in the first place though
in the future there will be awesome world api changes (if md_5 will someday implement the Enum-Change)
how dare you suggest we make breaking api changes
most things won't break
just, what the entity.getHandle() does exactly ?
it's clearly better that we support 1.8 developers rather than improving the API
almost nothing i can think of will break with the enum change
nothing. CraftEntity.getHandle however returns the NMS entity
and with the world-api-changes there is nothing to break too (if i cant implement it in the way i can think off)
wdym by enum change
except EnumSets
I thought we were planning to get rid of enums
NMS is ?
I don't have access to stash
internal MC code
hmm... than create acc xD
๐ค
nah
okay thank
don't want to sign my life away to md_5
it will change many enums to be not enum anymore which then allows custom variables
yeah exactly
how is that not gonna break old plugins
cause those enums they're referencing won't exist anymore, right?
the fields will have the same names
like mfnalex said... everything should work (maybe EnumSets not)
same names and an interface? or abstract class which contains enum-functionality
hm
also someday its time to say goodbye to ancient version support ๐
abstract ^^
I have found a solution for my problem ! ๐
This worked, thanks โค๏ธ
is there a way to make all interactable blocks non-interactable? (like a chest you can't open, door you can't open/close, button you can't press, etc...)
im working in 1.8
and yes ik 1.8 is not the best version to work with but im doing it anyways
thanc in advanc
Cancel the PlayerInteractEvent
oh ok
does the PlayerInteractEvent have a special property like if it's a block being interacted with?
thx
D:
Don't even say that
1.16 will be never outdated
because I will always remember it
๐
public class Prison {
private final TakaoMines plugin = TakaoMines.getInstance();
private String name;
private UUID uuid;
Location prisonLocation;
int x;
int y;
int z;
public Prison(Player p) {
this.name = p.getName();
this.uuid = p.getUniqueId();
if(!prisons.contains(name)){
createPrison();
}
x = Files.prisons.getInt("Prisons." + name + ".x");
y = Files.prisons.getInt("Prisons." + name + ".y");
z = Files.prisons.getInt("Prisons." + name + ".z");
}
private void createPrison(){
int x = prisons.size() + 3;
int z = prisons.size() + 3;
int y = 100;
prisonLocation = new Location(Bukkit.getWorld("prisons"), x, y, z);
Files.prisons.set("Prisons." + name + ".x", x);
Files.prisons.set("Prisons." + name + ".y", y);
Files.prisons.set("Prisons." + name + ".z", z);
try {
Files.prisons.save(prisonsFile);
} catch (IOException e) {
e.printStackTrace();
}
Bukkit.getWorld("prisons").getBlockAt(x, y-1, z).setType(Material.BEDROCK);
}
public Location getPrisonLocation(){
return prisonLocation;
}
}```Does anyone know why getPrisonLocation() returns null?
Do you have a world named prisions
yeah
the createPrison() method works fine but then when i want to access the location from another class it returns null
Are you sure that's the method returning null and not something else
how to check if message is json?
What message
doing new EffectDiagrammRunnable(effectRepeats,this).runTaskTimer(echo, effectTickDelay, effectRepeatTime); with values of 1, 0, 1 called on this class
import org.bukkit.scheduler.BukkitRunnable;
public class EffectDiagrammRunnable extends BukkitRunnable {
int Repeats;
EffectDiagramm ed;
public EffectDiagrammRunnable(int Repeats, EffectDiagramm d){
this.Repeats = Repeats;
ed = d;
}
@Override
public void run(){
if(Repeats>0){
Repeats--;
ed.activate();}
else this.cancel();
}
}
causes me to time out & become unable to join the server. However, calling activate() on the parsed class works just fine and as intended. Does anyone know why? (Logs only say 'Running 5000 ms behind; Moterius timed out)
chat message
Why do you want to check for json in chat?
Or do you want to check for ChatComponents
oops
nevermind
its an infinite loop creating infinite bukkitRunnables
ffs my machine is posessed
thats supposed to be 0 1 0 bruh
so message is a string, but when i try to send a json message, it looks like this https://i.imgur.com/GeF0DZp.png
is there a way to make it a normal json message?
How are you sending it
dont you need a textcomponent to send json messages?
Yeah you should use that
also where is that message coming from?
Hi how are you?
I have been thinking allright about my claim system
And i finally decided to keep a list or set inside my player profile. What do you think?
thats what i do
@sterile token
saving everything in the user class
Yes I do the same
complicated
lol tell me
i store all messages except one and resend them
If you want to send json messages use the ChatComponent API
mhm
in a list
as string format? as textcomponents?
take a drink
how to store message from PlayerChatEvent to a chatcomponent
Because im keeping a claim object, which contains name, location. And them I thinking and thinking how to get each player claim on MoveEvent
wdym gets each player? are you trying to find the claim where the player is in when he starts moving?
will it be any problem if I use 1.18.2 API and add 1.13 in plugin.yml?
Yeah that. But my problem is that the claim doesnt have corners. Its just contains a location of the protection block and a radius
What do you think?
@sterile token
@sterile token
why are you tagging yourself?
so a claim has a Collection<Location>?
Its a Collection<Claim>
Where claim contains, owner name, location, radious and flags
a claim has a collection<claim>?
Yeah
what
I didnt understand
I just keeping in my user profile a Collectiom<Claim>
So first I get player profile based on event and them im looping through Claim colection
I cannot because its based on a center block
Wait I will send code and you let me know
Because prob im no expรฑainimg
Anyone has a library idea
I'm thinking of making a software like
Plugin Finder
scans through spigot to find plugins with your keywords and lists them in a order by stars (rating)
A communicatio lib without fucked redis or plugin message or sockets. Something uskng the current netty instance
I dont think you would like it
Hahaha
lol
and u can choose how to sort
By downlods / by rating / by author fame
Isnt called spiget?
that only searches with title
cant search keywords for the description
Yeah im doing that fourten
public class Cuboid {
private final Location a;
private final Location b;
public Cuboid(Location location, Integer radius) {
this.a = new Location(location.getWorld(), location.getX() - radius, location.getY() - radius, location.getZ() - radius);
this.b = new Location(location.getWorld(), location.getX() + radius, location.getY() + radius, location.getZ() + radius);
}
public boolean contains(Location location) {
}
public Location getLocationA() { return this.a; }
public Location getLocationB() { return this.b; }
}
@tardy delta there you have. And thanks for helping
Integer -> int?
Yeah
lol i didnt do anything
?
Because it will be based on center block with radious
The radious can change depending of protection type
And chunk could be lagging
For having lot of protections with x amounts of radius
i guess a and b are the corner locations?
Yeah
and the location you pass in the constructor is the center
Yes the location i pass is the one of the protection block
I have just created this method, what do you think?
public boolean contains(Location location) { return location.toVector().equals(this.a.toVector()) && location.toVector().equals(this.b.toVector()); }```
Wait i dont think it will work
In my cuboid class
i would check if the x of that location is between the minimum and maximum x
same for z
i dunno if thats efficient, vectors might be more efficient
๐คท
Allright i wil continues searching on github
Someone told me that vectors are more efficient if you are on java +16
ah
And this class is though to be used from 1.8x to lastest spigot
That why im not using a public api
1.8 brr
I know
I dont use 1.8
Fourten could you test it?
Im coding to test it in another plugin
Yeah no matter it should be working on every version
The cuboid i have seen it should work on every version
What?
you asked me to test?
or do i need to put it in my plugin is that what you said?
Yeah just put the cuboid class on one of your
And if you can check if the cuboid works in that version
Oh nice
it shoots vertically ;-;
The cannon?