#help-development
1 messages ยท Page 1349 of 1
it might be better if you did the addition outside of the constructor so as for it to be less confusing and less things to go wrong.
yeah same
how to copy config.yml from resources/config.yml and paste it to config.yml in the plugins folder (bungee)
doesn't say anything
wym?
saveDefaultConfig()
this is bungee
ah
want to copy and paste file
what
so
basically
i have a premade config.yml
and i want to paste that to the folder of the plugin
what is the issue
yes
e.printStackTrace();
}``` 
Are you opped?
ye
Your plugin probably didnt load then
let me see your plugin.yml and latest.log
Does it shown in /pl?
or is it even there
show latest.log
Yeah it didnt load then
error in the console when it loads?
Most probably
?paste
SHH
me.ujiou.factoid.fact
vvvvvvvvvvvvvvvvvv
me.ujiou.factoid.Fact
๐ ๐ ๐
unfortunate
Ajajjajajja
xd
SHHHHHH
yea xd
How do I send players to a different world
Player#teleport
teleport
How
@carmine ivy Create a new location then teleport them to it
he just said
isnt there player.setLocation()?
Player#teleport(world, coords)
Entity#teleport technically more correct 
Ohhhhh thanks
@dusty herald
si senor
yes?
factual factoid
shhh
it's evil
My bad then lol
So would this work?
Location newLoc = p.getLocation().setWorld(World world_nether);
Uh no
setWorld is a void
fuck
Oh lmao
just p.getLocation()
How would i teleport a player while ignoring pitch and yaw?
pitch and yaw is just an rotation of head
but their view gets lagged back
I just checked, the p.setLocation() is part of the Factions Fork i have to work with 24/7, my bad didnt mean to confuse them XD
๐ค give it a shot
no cluie
doing that makes the pitch and yaw lag back, if the player's fps isnt exactly synchronised with the server's tps it will lag their view back
might just give you the same effect
lmfao
Joch even better
watch them disintegrate
player.setBedSpawnLocation(player.getEyeLocation(), true);
fr fr
damn
Lmaooo
you can straight make a pig run commands too
Wait
sick
kill the pig for the op
Pig with /ban
LMAOOO
Hey, at least a pig wont abuse :/
achievement unlock helped someone with code
I commissioned from that someone while back
That dog needs a bonk
i wanna be that dog
Entity pig = new Pig;
Entity villager = new Villager;
villager.setCustomName("Flo Rida");
villager.setCustomNameVisible(true);
pig.addPassenger(villager);
bruh
ez

Thats so jank lmaoo
poor dog if she farts
lmfao
XD
Puta
fr fr
๐
SP
oui madame
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
Entity pig = new Pig;
Location piggy = pig.getLocation();
player.setBedSpawnLocation(piggy);
// wait(0.5) be like
pig.eject();
}
}
why this no work ๐ฆ
lmfao ||its a joke JOCH||
you need to create the pig dummy
gimme your baguette @fathom timber
i'm staving spigot plugin isn't enough for me to live off
@dusty herald but fr tho how do I fix my issue?
xd
Like register my plugin?
no you sus
im sorry what
show me your plugin.yml
the entire thing
it was really factoid.factoid and i was embarressed so I changed it to factoid.factoid
name: Factoid
version: 1
main: me.ujiou.factoid.factoid
api-version: 1.16
authors: [ Ujiou ]
commands:
fact:
description: Display a fact.
ez
ok now show code
Also
so I replaced my Event with the a command to see if i could fix the error
so the commands class is Events 10/10
?paste
public class Fact
main: me.ujiou.factoid.factoid
๐it๐has๐to๐have๐the๐main๐class๐too
Classic mistake ๐
is there some kind of clock running on the background that i can call, add 30 seconds , save this new number and check every 1 second to allow a player to use a command for 30 seconds?
hashmap?
Exactly what the title says
but i was hoping i could do my thing
like in python that you have a background timer that you can check
HashMap<UUID, Integer> Player_Coolown = new HashMap<UUID, Integer>();
ExpiringMaps 
but would expiring map reset if i stop the server?
becuase i though since we have an sql, add to all players a flyTimeLeft in seconds so every 1 second i check if their time is up
but idk if that would make lag
yes
maybe every 1 minute?
@rotund ravine uh? did i mistake?
it would reset if you stop the server
the thing is, if the server resets and somehow they manage to keep the perm , i wouldnt know and the player would have unlimited fly
i really dont want that
I mean you could just remove it if they shouldn't have it onJoin
How can I spawn a random entity?
u can create an array with all of the entities and grab a random one
unless theres a method for that, which i dont think there is
how do I do that? ๐
EntityType[] entities = { EntityType.ZOMBIE, EntityType.SKELETON ... }
if i remember correctly thats how u make it
okay ty
np
The ExpiringMap would reset each time the server restarts so no I don't think it would be very good for that
do I have to put every entitytype there?
where?
in the {}
yea im gonna go with the sql option, im just gonna check every 1 minute
yes
okay
just don't typ every entity out that would be poor programming rather do a loop just saying
if you did thought to typ every entity then jikes xD
@sharp bough use a permission plugin. GroupManager has timed permissions (min of 1 minute) not sure about others.
what would that loop look like?
how can i check if an advancement is a recipe?
Hi, can we use model data (or tags) on mobs to change their models?
Sadly not
๐ข
Only using optifine or some trickery with armor stands and textured custom items
With optifine you could do that ?
Cause it's not a big problem to use optifine since 95% of the players use it anyway
is there some kind of player.removePermission or player.setPermission("test", false) or soemthing like that?
cant find it on google
Its way below 95% for sure. More in the range of 50
no wait nvm i can use LP
That's already something x) I'll look into OptiFine then :/
anybody know a way to get deobfuscated mc client code?
I would recommend Chime as well, for those who use sodium
it's like optifine
but it works with sodium
The mappings for the server are public now. For the client im not sure. But you will probably have a better chance asking the modding community.
if (sender instanceof Player) {
Player p = (Player) sender;
if (p.getWorld().getName().equalsIgnoreCase("spawn")) {
Location spawn = new Location(Bukkit.getWorld("spawn"), -1075d, 80d, 96d, 179.5f, -4.2f);
if (label.equalsIgnoreCase("kill"))
p.teleport(spawn);
p.setHealth(20);
p.setFoodLevel(20);
p.getInventory().clear();
p.removePotionEffect(PotionEffectType.SPEED);
}
} else {
sender.sendMessage(ChatColor.RED + "/spawn is only allowed in " + ChatColor.YELLOW + "Spawn" + ChatColor.RED + ".");
}
return false;}
}``` It doesn't send the message "/spawn is only allowed in spawn" if player is not in the world spawn... It just sends nothing...
Well, I looked into optifine and the only thing we can change are the textures based on the monster name
what did you want to do?
well
thats what this does
monster name is the name of the mob
im pretty sure
Doesn't it overwrite the original model ?
Ah you don't want that..
yeah ^^' that was the point of having something dynamically showing the model from the name or a tag on the mob
As for this apply the official proguard mappings and it should get a decent version of the source. Why do you need it anyway?
We can do it with items and custom model datas but not with monster unfortunately
how would i optimise this?
i spammed clicked the sign, anyway would i be able to make it more light weight?
apparently client is now public as well
trying to compile a plugin off github
Duplicated tag: 'resources' (position: START_TAG seen ...</plugins>\n\t\t<resources>... @83:14)
and need help with pom
https://pastebin.com/h0mPZnEt
Give code
i did
-. -
Sure.
- remove the
block != nullcondition. - Create an EnumSet<Material> that contains all sign materials. Then you call contains(...) on that instead of checking all the materials one by one
- Read the String from your config
oncein your onEnable or in the constructor of your class and call equals on that - Same goes for the command. Read it once from your config when the plugin loads and execute the saved String variable
oh thank you โค๏ธ
And maybe add a cooldown you might not want that to be fired many times in a row
Anyone have any experience using ACF? I'm mainly interested in things like efficiency as compared to using the usual CommandManager -> Subcommand format
The heaviest part of your code are the String operations and the command that is being executed.
So you could gain some more performance by not reading the first line of the sign but to use a tag that gets created when the sign is being written.
oh yeah, good idea i will
There is nothing really to gain in performance when using commands. And there is also not much difference here. Almost 1:1 execution time after a while.
Good to know
Thanks ๐
Would you prefer using it in simple cases or more just for bigger plugins?
@lost matrix the mappings that are released are for both the client and server however the mappings are not complete.
yes
i think this should of improved it ๐
yeah it definitely did, even while spamming it
Is Sound.Click the button sound?
yeah
[14:47:02 ERROR]: Error occurred while enabling BossSpawn v0.1.1 (Is it up to date?)
java.lang.IllegalArgumentException: The embedded resource 'config.yml' cannot be found in plugins\BossTest.jar
at org.bukkit.plugin.java.JavaPlugin.saveResource(JavaPlugin.java:195) ~[server.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.java.JavaPlugin.saveDefaultConfig(JavaPlugin.java:182) ~[server.jar:git-Spigot-79a30d7-acbc348]
at me.silentprogram.bossmob.Main.onEnable(Main.java:19) ~[?:?]
but
there is very muhc a config.yml
luzik
?paste
Oh ok
Get the full logs 0.o
Oki
else if(cmd.getName().equalsIgnoreCase("farmtime")) {
if (args.length >= 2) {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
player.getWorld().spawnEntity(player.getLocation(), entity);
}
} catch (IllegalArgumentException e) {
player.sendMessage(ChatColor.YELLOW + " (!) That is not valid entity");
}
}
else {
player.sendMessage(ChatColor.RED + "/farmtime <mob> <amount>");
}
}```
what's task 2
task 2?
ye
ยฏ_(ใ)_/ยฏ
I followed a turtorial on this and now it says out of date with using 1.16.5 paper and spigot
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
spawner.spawnCheck();
}
}, 0, 40/*600*/);
im using this
It's the thing causing the error
null pointer Main.java:25
spawner.spawncheck is line 25
then spawner is null
thats null
oh shit
you define it but never initialize it
else if(cmd.getName().equalsIgnoreCase("farmtime")) {
if (args.length >= 2) {
try {
EntityType entity = EntityType.valueOf(args[0].toUpperCase());
int amount = Integer.parseInt(args[1]);
for (int i = 0; i < amount; i++) {
player.getWorld().spawnEntity(player.getLocation(), entity);
}
} catch (IllegalArgumentException e) {
player.sendMessage(ChatColor.YELLOW + " (!) That is not valid entity");
}
}
else {
player.sendMessage(ChatColor.RED + "/farmtime <mob> <amount>");
}
}``` Can someone help me with this. It says out of date with version 1.16.5 spigot
public void spawnCheck() {
if(!plugin.data.getConfig().contains("lastbossspawn")) {
plugin.data.getConfig().set("lastbossspawn", 0);
plugin.data.saveConfig();
return;
}
if (plugin.data.getConfig().getInt("lastbossspawn") > System.currentTimeMillis() + (plugin.getConfig().getInt("secondsuntilspawn") * 1000)) {
SpawnBoss();
return;
}
}
this is being called every 30 seconds
but nothing happens
SpawnBoss just prints to the console rn
private void SpawnBoss() {
plugin.getLogger().log(Level.SEVERE, "Spawn!!");
}
And nothing happens..
in the console
Its doing something as it freezes the server evry time it runs
@quiet hearth there is nothing in that code to say out of date
@somber hull show your runnable
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
spawner.spawnCheck();
}
}, 0, 600);
guys, why this is not working:
Can someone help me? My / lobby command doesn't work. There is also no error in the console. The only thing that work is the message
https://paste.gg/p/anonymous/19ec3b9fc8404aec80236da878afc9e0
Error occurred while enabling Tutorial v1.0 (Is it up to date?) java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.chewie.Tutorial.Main.getCommand(String)" is null at me.chewie.Tutorial.Main.onEnable(Main.java:16) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-570] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-570] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-570] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-570] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-570] at
net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:580) ~[patched_1.16.5.jar:git-Paper-570] at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Paper-570] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1055) ~[patched_1.16.5.jar:git-Paper-570] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-570] at java.lang.Thread.run(Thread.java:832) [?:?]
@EventHandler
public void onPlayerJoin(PlayerJoinEvent evento){
evento.setJoinMessage(evento.getPlayer().getName() + " entrou no servidor!");
evento.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS));
}
Can someone help me? My / lobby command doesn't work. There is also no error in the console. The only thing that work is the message
https://paste.gg/p/anonymous/19ec3b9fc8404aec80236da878afc9e0
@somber hull you set teh lastbossspawn to zero. its never going to pass in teh next test. its always zero
(outdated-server:
outdated-client:)
what is the difference between
i set ti to 0 only if its null?
@quiet hearth Your command is not correctly added tro your plugin.yml
Yes. The first time you run it it sets to zero. the next time it runs its checking against current time. It will never be greater than current time
i still need help with this, if anyone can help
Outdated server: Client has higher version
Outdated client: Client has lower version
?paste
As you didn;t say what was the issue I'm going to assume its doing nothing.
Is it annotated @brave glenhandler
it it registered as a Listener and the class implements Listener
Okay yea i had a silly mistake and put the command under a different command (it was tabbed to far forward)
thank you
thank you
its like this and still not working
@faint snow you can;t have a class inside another class and have it work like that
how will i make a animated Title on a Custom Inventory?
packets? or mns?
i got no clue
now im getting this...
https://paste.md-5.net/tezipezose.sql
you tried to create a new instance of yoru main class. You can;t do that
How would I do the magic converter to like basic text like magic -> letter and unravels if that makes sense
you pass teh instance when you create your BossSpawn class
help?
- Does that class implement Listener?
- Did you register the listener?
how do i register the listener?
in your Main class when you create your bossSpawn you do new BossSpawn(this);
and store that in teh constructor of BossSpawn
I dont think it has a constructor?
Im still learning what constructors are lol
package me.silentprogram.bossmob.files;
import java.util.logging.Level;
import me.silentprogram.bossmob.Main;
public class BossSpawn {
Main plugin = new Main();
public void spawnCheck() {
if(!plugin.data.getConfig().contains("lastbossspawn")) {
plugin.data.getConfig().set("lastbossspawn", System.currentTimeMillis() + 1);
plugin.data.saveConfig();
return;
}
if (plugin.data.getConfig().getInt("lastbossspawn") > System.currentTimeMillis() + (plugin.getConfig().getInt("secondsuntilspawn") * 1000)) {
SpawnBoss();
return;
}
}
private void SpawnBoss() {
plugin.getLogger().log(Level.SEVERE, "Spawn!!");
}
}
what would the constructor be?
public BossSpawn(JavaPlugin plugin) {
this.plugin = plugin;
}```
and where is the class in the class?
do i add that?
How can I enable and disable events with a command?
Your MyPlugin is inside your PluginMessaginf class
yes Hyper
add that to your BossSpawn class
I figured it out thank you ๐
@wide galleon you can register and deregister Listeners, but its not really advised to do so if you can avoid it
?
how would I do that?
hmmm @eternal oxide it still just does nothing, and lags the server every few seconds...
it will lag due to you saving yoru config every 30 seconds
To register a listener class getServer().getPluginManager().registerEvents(listener, instance);
How would I overwrite the default join message?
if(!plugin.data.getConfig().contains("lastbossspawn")) {
plugin.data.getConfig().set("lastbossspawn", System.currentTimeMillis() + 1);
plugin.data.saveConfig();
return;
}
shouldnt that set it to the current time +1 and never run again?
do i need to do it onEnable() , right?
event.setJoinMessage(null);
yes in onenable
does getOfflinePlayer return a usable and proper uuid if the player is real/online?
Bukkit.getServer().getPluginManager().registerEvents(new onPlayerJoin(), this);
Hyper, yes that woudl set it to current time +1 and save teh config
like this?
so why isnt the config being saved...
is your Listener class called onPlayerJoin?
quick question
it is
Why the hell
so? public class Plugin extends JavaPlugin implements PluginMessageListener { ๐
can I do this java event.getPlayer().getPlayer().getPlayer();
_ _
@rugged topaz yes
if it's deprecated, what's the alternative?
its deprecated because it can perform a blocking lookup
meaning what exactly
if the player is online, why do you want an offline object?
my class is ```java
public class craftplugin extends JavaPlugin{...}
wouldn't know if the player is online or not
because it's a command run by a player
How can I enable and disable events with a command?
getPlayer returns a null object when the player goes offline
getOnlinePlayer only online
so
getOfflinePlayer seems to be the only one that looks favorable towards both
then you register (this, this)
Yes you can use the getOfflinePlayer, then check if getName() is null. If its null the player is unknown
so? public class Plugin extends JavaPlugin implements PluginMessageListener { ๐
im getting an error
you would also need to implement LIstener
so extends JavaPlugin implements Listener, PluginMessageListener
my onEnable event```java
@Override
public void onEnable() {
getLogger().info("Plugin iniciado com sucesso!");
Bukkit.getServer().getPluginManager().registerEvents(this, this);
}
so long as your event handler is in your main class, yes
'registerEvents(org.bukkit.event.Listener, org.bukkit.plugin.Plugin)' in 'org.bukkit.plugin.PluginManager' cannot be applied to '(me.f1nndev.my1stproj.craftplugin, me.f1nndev.my1stproj.craftplugin)'
then i get this error
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
spawner.spawnCheck();
}
}, 0, 600);
this is just completely lagging the server
you have to implement Listener
Even though the delay is 600
still getting the same error
you are not implementing Listener
do i need to write @brave glenHandler?
instead of @override or above
?paste your code
you are still not implementing Listener
oh right
.
no
so, where?
public class craftplugin extends JavaPlugin implements Listener{
Cannot resolve symbol 'Listener'
so? public class Plugin extends JavaPlugin implements PluginMessageListener { ๐
um, sec
Nothign wrong with that implements Listener is correct
so what isnt correct in my code?
If I want to run something every hour in the console do I use a BukkitRunnable, or a Scheduler?
Should I*
Fix your imports import org.bukkit.event.Listener;
?paste yoru current code
Either
Just remember its not going to be completely accurate due to tick rate
https://paste.md-5.net/xunocorori.cs is anyone able to help me optimize this function, super terrible on the tps and just causes a large amount of lag nonetheless
Is there a way to get selectors? like {"selector":"@e"}
working! tysm @eternal oxide
@rugged topaz Run all your searching code Async and compile a list of blocks you need to set to air. Then call a sync method to set them
you could also just for loop over teh BlockFace Enum
rather than getting individual blocks for each and adding to an array
for (BlockFace face : BlockFace.values()) {
Block relative = block.getRelative(face);```etc
How can I code a plugin that gives you a random status effect whenever you enter a new chunk
yes
well you need to check the getTo() and getFrom() in the PlayerMoveEvent and compare getBlockX and Z of each to see if they change. If not early return.
if they changed you need to check if they are different chunks using the formula (int) Math.floor(value) >> 4
Does anyone know how to use PlaceHolderAPI?
if x or z are different when passed through that, they moved chunks
How do i set an item to a specific slot and how do i rename it?
Is it laggy if I loop 5 offline players or something.
depends what you are doing and iff they are known to the server or not. but it can be if they are not known
if they are not the method performs a blocking web lookup with the Mojang servers
if I were you I'd use getOfflinePlayers() and pick the ones you want
that will only return known players with no web requests
no
if you call getOfflinePlayers() it returns an array of all players who have ever played on your server
How many players?
all. so depends on your server
I am blind
doesn't this come with
NORTH_EAST(NORTH, EAST), NORTH_WEST(NORTH, WEST), SOUTH_EAST(SOUTH, EAST), SOUTH_WEST(SOUTH, WEST), WEST_NORTH_WEST(WEST, NORTH_WEST), NORTH_NORTH_WEST(NORTH, NORTH_WEST), NORTH_NORTH_EAST(NORTH, NORTH_EAST), EAST_NORTH_EAST(EAST, NORTH_EAST), EAST_SOUTH_EAST(EAST, SOUTH_EAST), SOUTH_SOUTH_EAST(SOUTH, SOUTH_EAST), SOUTH_SOUTH_WEST(SOUTH, SOUTH_WEST), WEST_SOUTH_WEST(WEST, SOUTH_WEST), SELF(0, 0, 0);
these extra values too?
I thought you said "who have never played on your server"
@rugged topaz true I guess
I'd still recomend using an array of the BlockFaces than seperate blocks for each
even if you create an array of just the ones you want
You could check the slot type in the inventory click event for https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryType.SlotType.html#ARMOR
how do i set an item to a name?
https://paste.md-5.net/inoxemefaz.cs revised function after all the suggestions, lmk if i did something wrong
rather than one task per block I'd do them all at once, if not over 1000
also new BlockFace[] { BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
would probably be better
You may need to move the inserting into the player inventory to sync but test that
If all the blocks are being tested for a Material match you should total up how many are found and do a single addItem for that amount.
Cant find how to do it
?
Thanks
well you didn't ask to see which it is, only to see if it was armor
it changes the name of a player, not of an item
No its items
@quaint mantle what exactly are you attempting to do?
there's no setName method
Test if it has a name with https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/ItemMeta.html#hasDisplayName()
then put the meta back on the item or it will not apply
i type this ```java
evento.getPlayer().getInventory()
because thats inventory
@quaint mantle java if (event.getSlotType() == InventoryType.SlotType.ARMOR) { if (inventory.getItem(event.getSlot()).equals(yourHelmetObject)Something along the lines of
where would i put this?
if testing (best way being spamming /tps) then i'll see :)
for (BlockFace face : ...
sorry, BlockFace
oh lol
but i want to change the name of a specific item
you get the item in the inventory, get the item meta then set the display name
.getInventory() gets you the inventory
The docs ElgarL provided were for ItemMeta
then how do i do it?
(this is my 1st day doing a plugin)
this is productive
ItemStack item = inventory.getItem...
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("blah");
item.setItemMeta(meta);```
^
"but setMeta doesn't exist"
@eternal oxide unsure why this is on the log
fixed
im trying to use the packetevents plugin/api thing but I cant find PacketPlayInPosition, I probably a blind or did something wrong
If you use lambda expressions and want to access exterior variables they must be strictly final or you have to make them atomic cause of thread access
what atomic basically means is like multiple threads trying to access an object right. it blocks another thread and waits for one to finish
oh well, @eternal oxide not using log anyway and adding after, since the aesthetic is that you gain logs per broken object on time
@rugged topaz count how many you need then pass to a final variable for your runnable to access
so both runnables would run at the same time (in order to comply with the replied msg)
?
or
wait
misread
no, you run an Async to sort the blocks/count.
Then your sync runnable you make changes
so yea two runnables
use completablefuture (:
anything you pass from your Async to yoru sync you pass into a final variable so it can access it
but runnable will work
runnables are the simplest as its your first time
not in regards to the completablefuture
not my first time either (w spigot), just haven't worked w anything like this
Those are for when you understand threads better
yea use runnables at first
if you are new
i wouldn't say faster probably around the same speed but more functionality and useful utility methods
if you are like opening many theads you should consider using ExecutorService, that will definately help tho.
cause threads use space
an example...
run all yoru code Async to count/list teh blocks then IN the same Async runnable...
/*
* A Future as we are Asynchronous to get the result.
*/
Future<Boolean> future = plugin.getServer().getScheduler().callSyncMethod(plugin, new Callable<Boolean>(){
@Override
public Boolean call() throws Exception {
//Do all yoru replacing of blocks here.
return true
}
});
try {
// Lock NON-main thread to wait for the result.
return future.get();
} catch (Exception ex) {
ex.printStackTrace();
return false;
}```
My fingers don;t move fast enough to get everything in the right order these days
Yeps
why there is a line over this method? ```java
getItemInHand
like ; in my don;t. Pinky doesn't stretch quite far enough to get the '
getItemInMainHand()
here si sany exampe of me typign fast
identical ๐
returns this error: Cannot resolve method 'getItemInMainHand' in 'PlayerInteractEvent'
you need to get the PlayerInventory
and wierdly I read that fine. At first saw nothign wrong
lol
You and llama have the same thing lol
something like event.getPlayer() to get the player. Then call getInventory() on that to get the player's inventory
then call getItemInMainHand() on that
Yep, he's a little younger than me so he's just lazy ๐
3.0 is almost done. I just have to add the SQL code. Refactored for it, but not written it
oo nice
thats tiny. When it was bundled with Essentials it was thousands of servers.
hundreds of K downloads each version
These days its 3k servers
still big
@eternal oxide https://paste.md-5.net/igevilagod.cs current func now, suggestions/feedback/mistakes?
for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }) {```
can just be
```java
for (BlockFace blockFace : faces.asList()}) {```
it can;t as that includeds a lot of diagonals etc
ah right
also removed the redundant arraylist face
It looks fine. does it work is the question
sec, your future needs to be outside your amount loop
that'd be outside the runnable
oh ok
"IN the same runnable"
well it won't work
because
the ide gives that error
is it meant to be outside the runnable?
the indentation is throwing me off a bit, that return is for the asyncDelayedTask, right?
I know the future is fine, I use that myself
I see, you don;t need to return a value
it's a void ๐คฆ that's mb for not even noticing
because you are inside your async task its not expectign a value return
the task doesnt need a return
delete the entire try/catch?
just change teh return future.get() to future.get()
alr
and delete the return false
what's the diference between @brave glenHandler and @Override ?
Override is a default java annotation
@brave glenHandler tells bukkit that the method handles an event
eventhandler is an annotation that Bukkit looks for to know that is an event handler
im asking this cuz my code for opening an menu isnt working
@EventHandler
public boolean onPlayerUse(PlayerInteractEvent interact){
if(interact.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("ยงlยง6Menu")){
interact.getPlayer().sendMessage("Entrouuu, GG");
menuJogos.setItem(3, new ItemStack(Material.GRASS_BLOCK));
interact.getPlayer().openInventory(menuJogos);
}
return true;
}
if you want to help me
okok
interact.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("ยงlยง6Menu")
sry
this may give you issues aswell
have you registered the listener? or it it in yoru main class like the other?
im making everything in just one class
yep thats fine
public static Inventory menuJogos = Bukkit.createInventory(null, 3,"Modos de jogo!");
inventories can only be multiple of 9s
3x3 = 9
Look at teh javadoc for this method and you can see its nullable https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/ItemStack.html#getItemMeta()
yeah it only takes 9, 18, 27, etc
ahh ok
its overall slots not rows
damn auto tag
there is a dude literally named @urban grotto
haha
thats on them lmao
exactly
i though it was rows
import org.bukkit.event.EventHandler;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin
{
}
public class MyListener implements Listener
{
@EventHandler
public void onMove(PlayerMoveEvent event) {
final Location to = event.getTo();
System.out.println(to);
}
``` It wont log anything when I move
its not registered
oh god
especially in that case
you can;t put a class inside a class
you can
just not in this case
just not good practice in that case
java.util.ConcurrentModificationException is called on the for (Block block : blocksToRemove) { in the Future @eternal oxide, the tps seems to (on average) better than before, only a 0.04 dip per execution for a second or two, compared to 0.09-0.12
So what exactly do I have to change
so first off
um, it shoudl not be a cme as its running sync
well ๐คท that's the stacktradce
it works fine
wouldn't notice anything if u were a player
import org.bukkit.event.EventHandler;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin
{
}
public class MyListener implements Listener
{
@EventHandler
public void onMove(PlayerMoveEvent event) {
final Location to = event.getTo();
System.out.println(to);
}
```?
this
show me the code again
a thing i've noticed is that sometimes the blocks break in sets of 2/3 each, rather than each block every tick or so, might have to do in correlation to the stacktrace error
^ which isn't a desired effect
buoobuoo?
no completely separate files
Dont I need to like run the class
you also have to register it
I get it
and create an instance of MyListener
- add an onEnable method in your plugin class
- create an instance (as said above), and register it
using getServer().getPluginManager().registerEvents(this, new MyListenerThingy());
where
this refers to the current plugin instance
and
new MyListenerThingy() refers to the listener instance
i typed that from memory, so idk if the method names are correct
@rugged topaz are you running this with an amount more than 1?
you have a for loop that can spawn multiple Async tasks
thast why
so that it breaks 15 blocks in a link
So register the listener inside the onEnable event?
you are runnign multiple tasks at teh same time on teh same blocks
Pulse?
Yes
move teh for loop inside teh task
i love it when devs use teh
lol
really shows how bad we are at typing english
compared to code
๐
Imagine what code will be like in 10 years when IDEs adapt to the new language
that'd change the long at the end of it
instead of i, i'd use..?
drk how to refractor this code, sorry, wrote it a while ago and was buggy never looked back
In 10 years we will have self writing code
/s
and HKs
Yes
@paper viper isnt it the other way around according to the docs? like getServer().getPluginManager().registerEvents(new MyListener(), this);
@rugged topaz your current code looks like it runs until it runs out of compatible blocks, not by the counter
so i wouldn't be able to move the loop into the runnable?
you shoudl be able to delete teh first for loop
its just running the same code 35 times adn doing nothign other than causing a cme
but then i wouldn't be able to call the amount of blocks i'd want removed
which is what the loop is for
teh loop is not working. if you want to limit the blocks broken, add a check after the blocksToRemove.add(nearbyBlock);
if (blocksToRemove.size() >= amount) break;
I am having a problem with some code, I have code and error
Error:
I think taht code is what the error is mad at
asfor the runnable's long at the end?
i'd assume just 1
long?
yea but that's not the problem
it says that the things with my string to boolean or whatever conversion is the problem
this error is so small, so i cant see
sorry
o god ya
i c what u mean
lemmie try to make it bigger
my server is restarting
ill show u again
its text, just copy it
?paste
@eternal oxide breaking a block only deletes 1x of the faces connected to it, rather than 15
here's updated code
here is error
ah I see
line 10 is looping over a preCloned list. Change that to a while(!blocksToCheck.isEmpty())
you cna scrap the preClonedList then
@quaint mantle Try using the getCurrentItem()as thats the one thats clicked. You would also have to check the slot to make sure its being put on and not removed
is the "si" command in plugin.yml file?
yea the command works fine
the eror is based arround my method of converting book string to float
i did i send again sorry
?paste
Some1 already has this weirdy thing?
well if i change it, how would i get variable block
you already added the block to blocksToCheck. you grab it from there adn then remove it
@kindred solar did u get code?
so get the first entry
yes, im trying to understand it
k tell me if u dont' understand something
@rugged topaz that way as you add blocks to the list it keep the loop going.
currently it checks a single block and exits
o okay
to get the first entry?
.get(0)? i'd assume ur talking about something else
get(0)
works either way lmao
the only part thats probably not workgin yet is your leaves
if anything
it doesn't break any connecting blocks
prints no errors
but my ears are being spammed with the custom XP level up
try to do this ```java
item.equals(Material.WRITTEN_BOOK)
ook
i will
but I don't think that's where the error is
tha tpart works
it detects if it is book or not
i think it is in line 12 and 13
ok one sec, let me see if I can simplify this
ill brb
idk so
some1?
some1 = someone
resolved, in my code i has evento.getPlayer().setDisplayName("ยง8[ยงfMembroยง8]ยงf" + evento.getPlayer()); instead of evento.getPlayer().setDisplayName("ยง8[ยงfMembroยง8]ยงf" + evento.getPlayer().getName());
about your code?
yea
tbh i started today, so i cant help you that much, sorry
@rugged topaz not fully working but try this https://paste.md-5.net/jibipegumo.cs
@eternal oxide do u have ideas for mine?
Sorry I didn;t see your question
The IDE I am using recommended I add this getServer().getPluginManager().registerEvents(new MyListener(), (Plugin) this); the (Plugin) part
Will that ruin the plugin or
the blocks only break afterward all at once
@eternal oxide do u have time to look it fine if u don't
it will work, but its not needed, if the class you are in extends JavaPlugin
ill retype question
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.Listener;
public class Main extends JavaPlugin {
public class MyListener implements Listener {
@EventHandler
public void onMove(PlayerMoveEvent event) {
Location to = event.getTo();
System.out.println(to);
}
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new MyListener(), (Plugin) this);
}
}
}
``` It also recommends me to remove the `@Override`
yep thats how it works
Do I need to remove it
you want each block to break with a delay?
?paste
ok, one sec then
going from the epicenter (the original broken block) rippling out to every face and block connected to that up until my amount is met
and not only that but i've noticed some strange behavior
if i break a single block, not connected to anything, it also breaks 3 blocks that ARE connected to one another, but not connected to the single block that i broke
which i don't think happened before
unsure what the cause could be
looking at the code and i don't see anything
This is my error:https://paste.md-5.net/upacubazez.bash
And this is my code https://paste.md-5.net/wuguwuguwi.js
I think the error is under integer.parse
Any ideas?
How about, not using a future, still async https://paste.md-5.net/todiweyara.cs
i'll check it out :)
yea its prolly too complex
apparently the syncmethod is missing a return ?
@deft sedge which is line 42?
?
@eternal oxide
42 says int Thirst = Integer.parseInt(thirst);
it is supoosed to turn the string under var thirstRAW into an int and store int to Thirst
@rugged topaz change callSyncMethod to runTask
@deft sedge the value its seeing is "0.0" not an integer
@EventHandler
public boolean onPlayerUse(PlayerInteractEvent interact){
if (interact.getAction() == Action.LEFT_CLICK_AIR || interact.getAction() == Action.LEFT_CLICK_BLOCK) {
if (interact.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("ยงlยง6Menu")) {
interact.getPlayer().openInventory(menuJogos);
}
}
return true;
}
ok
not working
ohhhhj
cant fix it
@eternal oxide I need to convert that string to an integer
the problem
is that it gets this data from a book
and in a book this data has to be a string
@eternal oxide
ill show
working a lot better now, however the side issue of sometimes getting a block that is two blocks away of the same type rather than touching blocks, and also, if a block regenerates (by plugin) that i've mined, it'll break it again, and give me xp, and continue the loop
ok it is 0.0
can some1 help me fixing it?
you need a method that will try to fetch a float first, if it fails fetch an int
or, check the string for a decimal point
ooooo
ok
i see
so is there a way for me to remove the decimal
wait
i might be able to just make it in int
i'll try that
Float.parseFloat(String).intValue()
?
yes, thats the one thats clicked
