#help-development
1 messages · Page 1448 of 1
spigot performs like shit
most servers use paper
which has expanded api that lets you do things like chunk loading more efficiently
wait i wouldnt think that java threading would work with stuff in spigot and bukkit and stuff
chunks in particular are one thing you need to specifically design for
yep i heard about it but is it realye better than spigot on other aspect ?
in basically every aspect yes
more than 60% of servers use paper or its derivatives
but in my plugin i don't realy need fast load chunk
well yeah but if someone wants to run your plugin on a server, they want it to perform well
doing sync chunk loads will have severe repercussions on paper
well okay maybe in the future to look to adapte it to paper
as all of their chunk loads are asynchronous
and even a single synchronous one bogs down everything else
someone sees your plugin loading chunks synchronously, it'll be flying out of the window and they'll look for a paper specific replacement
haha ok get it thanks for the advises
paperlib allows you to use the most important features of paper like the async chunk api while maintaining compatibility with spigot
so if i code on paper it work without problem on spigot ?
if you build against paper-api, and you use methods that don't exist in spigot-api, the plugin will explode on spigot
you should build against spigot-api and add paperlib as a dependency, and then shade it in
that way the plugin will still run on spigot
but you can use the lib to take advantage of paper api
if the server is spigot, the library will default to spigot-api methods
if the server is paper, the library will take advantage of paper-api methods
hooo so i don't need to rewrite completly my plugin to paper
you'll just need to change some method calls related to chunk loads
overall, paper is api-compatible with spigot
meaning that you don't need to change anything
yeah most shit in paper is supported but some stuff in paper isnt supported tho
lmao
but that of course won't net you any good
okay nice
Can I ask the reason people use # instead of .
hanging onto every last user with tooth and nail
the death throes of a dying platform
people use # because javadoc links use # to anchor the browser to a specific line
Oh Oki
Is there a way to add custom colors to messages?
are you dumb
of course u can
;-;
Is there a simple way I mean
no like rgb and hex
i think u use hashtag?
punchBow.addEnchantment(Enchantment.VANISHING_CURSE, 1);
event.getEntity().getEquipment().setItemInMainHand(punchBow);
why is it bungee api
It bothers me
so this code is put onto a skeleton, of which the axe can drop, how do i stop the axe from dropping
LivingEntity.getEquipment.setItemInMainHandDropChance iirc
Because it is
ok thanks ill change the variable name too
but why does it have anything to do with bungeecoord?
getEquipment is invalid
Bungee can use colored chat too
why not put it in like a different directory tho
it says it can't be resolved
public void doorLol(CreatureSpawnEvent event) {
if (event.getEntityType() == EntityType.SKELETON) {
double num = Math.random();
if (num < .03) {
ItemStack punchBow = new ItemStack(Material.DIAMOND_AXE);
punchBow.addEnchantment(Enchantment.VANISHING_CURSE, 1);
event.getEntity().getEquipment().setItemInMainHand(punchBow);
LivingEntity.getEquipment.setItemInMainHandDropChance;
// 40% chance
} else if (num < .17) {
event.getEntity().getEquipment().setItemInMainHand(new ItemStack(Material.IRON_AXE, 1));
// 10% chance
} else if (num < .31) {
event.getEntity().getEquipment().setItemInMainHand(new ItemStack(Material.STONE_AXE, 1));
} else if (num < .42) {
event.getEntity().getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD, 1));
} else if (num < .5) {
event.getEntity().getEquipment().setItemInMainHand(new ItemStack(Material.IRON_SWORD, 1));
} else {```
thats more of my code
🤦♂️
Obviously you need the () and whatnot
You literally use it the line right above that
omg you're right im so dumb lol
Method takes a float 0-1 I believe
wtf is that
use a treemap
its code that i did back when i was more nooby
and now my poor naming and coding choices is dawning on me
map.put(total += <chance here>, <value here>)
map.getCeilingEntry(random.nextDouble(total))
ah thank you
Does anyone know why this is giving an error?
TextComponent test = new TextComponent("Test");
test.setColor(ChatColor.of("#1565C0"));
not without the error
make sure you import bungee chatcolor
there's a chatcolor in bukkit and another one in bungee
the bukkit one is an enum and doesn't support hex
the bungee one is the one you're looking for
is equipment the correct type?
the whole chat component api is batshit
im typing it in and nothing comes up for it
It's EntityEquipment IIRC
ty
Bukkit.getConsoleSender().sendMessage("passed");
if(sender instanceof Player) {
Player player = (Player) sender;
TextComponent test = new TextComponent("Test");
test.setColor(ChatColor.of("#1565C0"));
player.spigot().sendMessage(test);
} else {
sender.sendMessage("You're not a player");
}
I have a subcommand but I dont receive the message when I execute it
No errors and warnings
wait actually one error in the console
[ERROR] java.lang.IllegalStateException: zip file closed
did you /reload
but also you know the best part about errors
everything after the first line tells you where the error is
your zipperoni went pepperoni
the error only tells me this
[ERROR] java.lang.IllegalStateException: zip file closed
No further information
🌶
look at the first time it happened
First time the same
@EventHandler
public void onGeneralDeath(EntityDeathEvent evt) {
evt.getDrops().removeIf(item -> item != null && item.getType() == Material.WITHER_ROSE);
}``` any idea why this doesn't remove wither roses from the drops?
pretty sure it'll cause ConcurrentMod shit
¯_(ツ)_/¯
It won;t as it uses an iterator.
so then why does removeIf not work but java evt.getDrops().stream() .filter(i -> i.getType() == Material.WITHER_ROSE) .forEach(evt.getDrops()::remove); does
use that if u cant get something else to work idk if that is a good way to do it ¯_(ツ)_/¯
the list will never include wither rose
it's added to the drops separately from the death event
so basically you're fucked
i remember fucking with wither roses at one point and it was a total pain in the ass
it was for this drop multiplication thing for my spawner plugin
that reduces the # of mobs for inactive spawners, but increases their drop yield
wither roses were the one thing that the multiplication didn't work for
and it's because they're not in the fucking drop list
and pray that the locations are exact and don't have a random deviation like most natural drops
what tf are you trying to do ?
prevent shit from dropping wither roses presumably
yea
well distanceSquared < 1
well i want to stop mobs from dropping it and implement it in a different way
create ur own droplist
so...
overengineering
i also vaguely remember nether stars having the same issue
EntityDropItemEvent is not called for mob drops but im testing it for wither roses
but i'm not totally sure about that
its not that
not many wither spawners on my serbur
declaration: package: org.bukkit.event.entity, class: ItemSpawnEvent
i know
yeah that's the issue
you don't want to cancel it if the player breaks a wither rose block
or a chest containing one
interesting, I guess I could add that to the list of shit I listen to for drops to multiply
yep, cancels all wither rose drops
evt.setCancelled(evt.isCancelled() || evt.getItemDrop().getItemStack().getType() == Material.WITHER_ROSE); ez
alter drop table in nms
ent.a(null)
jk
ur cancelling it but i guess you should give some compensation
like throw a casual drop
give the fker a piece of coal
Player p = (Player) sender;
TextComponent test = new TextComponent("TEST");
p.spigot().sendMessage(test);
When I try to send a message using a TextComponent it says
[ERROR] java.lang.IllegalStateException: zip file closed
In the server console.
I imported TextComponent from import net.md_5.bungee.api.chat.TextComponent
XD
wtf is TextComponent
also why not just send a string
p.sendMessage("TEST");```
I want to use hex colors later on
you probably replaced a jar while the server was running
stop your server and restart it
Okay
u can still use chatcolor tho
;-;
I want to use hex
yeah that allows u to use hex
This one>
yes your code is fine
your error is from something else
see what I said about the jar above
ChatColor.of("")
is hex not implemented in normal messages yet? or its only component based
i think
you cant do that with sendmessage
yes u can?
yes you can?
really
private void doFirework(Location location, int level) {
Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
FireworkMeta meta = firework.getFireworkMeta();
meta.setPower(0);
for (int i = 0; i < level; i++) {
FireworkEffect.Builder effect = FireworkEffect.builder()
.with(types[Utils.random.nextInt(types.length)])
.withColor(
Color.LIME,
Color.AQUA,
Color.RED,
Color.YELLOW,
Color.fromRGB(0x00CC8F),
Color.fromRGB(0xFF00FF)
);
meta.addEffect(effect.build());
}
firework.setFireworkMeta(meta);
firework.detonate();
}``` any idea why the firework is still doing damage despite having a power of 0?
of course lmao
try -1
the power of the firework, from 0-128
depends on what parses that string
p.sendMessage(ChatColor.of("1565C0") + "test");
Like this?
¯_(ツ)_/¯
appending ChatColors into Strings involves serializing the chatcolors into a string format
which then relies on the method that takes that string to deserialize them back into proper colors
how can i affect the damage?
and not every method does this
change the damage
I think it might be best to disable damage with EntityDamageEvent
especially for the hex colors
hex always starts with # where is the #
And the ChatColor is the bungee import right?
I forgot it
if u dont u wont have the .of method
of course
that's what I did
Hey, I’m new to Spigot and had a question. Is there a standard way to ask a command sender for further info? As in, do you want to override a save file (y/n)
p.sendMessage(net.md_5.bungee.api.ChatColor.BOLD + "" + net.md_5.bungee.api.ChatColor.of("#1565C0") + "test");
Why is this not giving me a bold text?
;-;; what does getconsole sender do
get the console so you can run commands from it
i feel like i've seen this before, but is there a way to make a table of contents in a book so if you click, it opens a certain page?
i think so idk how tho
How to call a method from another java class within the same package?
you just do Class.method()
I think thats not my problem, I have moved my command from the main class to another class and know the methods reloadConfig and checkRecipes are undefined
then send a instance of Main to the other class
and then you do main.reloadConfig()
in the method
how can I do this
constructor ._.
constructor
which means u will have to instance the Command
unless u make a setPlugin() thing that sets a variable in there
¯_(ツ)_/¯
idfk
XD
dependency injection
say your main class (that extends JavaPlugin) is called MyAwesomePlugin
in your onEnable, you would do something like new AwesomeCommand(this), which is where you pass the main class along to the command class
in the AwesomeCommand class, you can have a private final variable such as private final MyAwesomePlugin plugin;
when you create the object (in the constructor), you will set the incoming instance of the plugin to the variable defined in that class ```java
private final MyAwesomePlugin plugin;
public AwesomeCommand(MyAwesomePlugin plugin) {
this.plugin = plugin;
}```
and then you can use the plugin variable to essentially access the class that extends JavaPlugin and all its functionality
thats what i said but i didnt really give any info on how XD
well i said constructor
i didnt know what it was called
;-;
there is a skill that many seek to master, called not sending 5 messages per sentence
i think it looks nicer with sending multiple messages
u did it too
its a habit
:(
too*, habit*, and again, i said per sentence, which is what i was doing: sending one message per sentence.
wtfca spelling
also i like saying k and idk separately
p.sendMessage( net.md_5.bungee.api.ChatColor.of("#8596ab") +
"[" +
net.md_5.bungee.api.ChatColor.of("#486d9c") +
"TEST" +
net.md_5.bungee.api.ChatColor.of("#8596ab") + "]" + net.md_5.bungee.api.ChatColor.BOLD
);
Why is this not giving me a bold text?
Dose anyonw know how id be able to get a score from ingame an display it in a gui? I already did the gui I just need the score?
In Python, you can add the "else" block after a "while" loop. It will be executed after the loop is over.#while #loop #for #iteration #iterate#else #codebloc...
If it’s a scoreboard just get the scoreboard through ScoreboardManager and then get objective and then score
is there a way to see when an enderman places a block?
I think the place block event handles that too I think
it says it is Called when a block is placed by a player.
EntityChangeBlockEvent I think
thanks!
Isn't that for placing and picking up
destroy and place?
And I don't think it's just for enderman
thats great! now I don't need a seperate class for destroying events
Oh lol
I think for creepers its different
Idk
¯\_(ツ)_/¯
I suck at coding MC plugins
Idk what I'm talking about really XD
Is smthing like this?
Yeah tho you want to return the score?
Also believe getScore(String) isn’t deprecated so might wanna use that instead
ok
do creepers trigger an entitychangeblockevent when they explode?
I don't think so
I think they trigger a different event
Since they explode other than change blocks
I gtg tho
They trigger an EntityExplodeEvent
guys why is not recognizing the getConnection() method?
what's the compilation error when you hover over it?
Am I doing something wrong with this?
https://paste.md-5.net/ucohuhesay.cs
Trying to store some things on an item using 1.16.5
on the ItemMeta?
If you don’t specifically need your own container you should just store it in the main one
What method should I use to set it back? I'm having trouble finding it.
also, I'm using my own container to identify a custom item no need to bother with that. Maybe I'll change it later.
so i made a gui but i want to make it so when you left click an item in the gui it sends a command
how do i do that?
A simple string is enough, no need for a whole container
You need to call ItemMeta.getPersistantDatContainer.set(key, yourcontainer)
that's what I'm doing. I don't create the container in that class
You need to call it again after modifying it
How can I remove a plugin from the SpigotMC website?
report it
Report it and ask for it to be removed
and my own plugin not from a third party!
same thing, report it
I've got this piece of code in my onEnable method in KeepInventory.java java getServer().getPluginManager().registerEvents(new DeathEvent(this), this);
And this piece of code to access the class from my DeathEvent.java class ```java
private final KeepInventory plugin;
public DeathEvent(KeepInventory plugin) {
this.plugin = plugin;
}```
The plugin is throwing an exception "plugin already initialized", could someone explain why this is happening?
That's my main class, I didn't initialize it and I'm sure I only have one jar https://pastebin.com/dTdgqssx
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
This is the DeathEvent class ```java
package dev.stan.mc.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin;
import dev.stan.mc.KeepInventory;
public class DeathEvent extends JavaPlugin implements Listener{
private final KeepInventory plugin;
public DeathEvent(KeepInventory plugin) {
this.plugin = plugin;
}
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
if (player.hasPermission(plugin.getCustomConfig().getString("permissions.keepinventory"))) {
event.setKeepInventory(true);
} else {
event.setKeepInventory(false);
}
}
}
You have two class that extends JavaPlugin.
thanks
also to clear things up I'm using the container for other things rather than just using it to identify a custom item.
also just a note I believe you could just do
event.setKeepInventory(player.hasPermission(plugin.getCustomConfig().getString("permissions.keepinventory")));
rather then use the if statement
anyone know why this doesnt work? I either get this to never work or it cancels all inventory clicks regardless of slot https://prnt.sc/135d092
event is registered properly and all
are you in creative
?paste
looks like the spacing on the description and the aliases.
thank you good sir 🙂
youre welcome
nope
nope
this gives me a error here
i wonder i wonder
getPluginLoader().disablePlugin(this);
the spacing fixed it ¯_(ツ)_/¯
ah, didnt see the error lmao
Maybe a bug with the wrong error then
anyway
this just sends a large error message to the console
getPluginLoader().disablePlugin(this);
it disables the plugin
but also spams console with smthng about a zip file
I don’t think I’ve ever had an issue
But I remember doing Bukkit.getPluginManager.disablePlugin
because it disables itself while running the method
put it in a runnable
k
although that might act weirdly as well since there has to be an owning plugin for runnables
¯_(ツ)_/¯
When I open a double chest through code like so:
Player player = (Player) sender;
final Block target = player.getTargetBlock(null, 5);
final Chest chest = (Chest) target.getState();
player.openInventory(chest.getInventory());
It remains open even after I close the double chest. This doesn't happen for single chests. I'm running 1.16.5
Does anyone know how I can fix this?
can't get that to work.
if (closing.getViewers().isEmpty() && closing.getHolder() instanceof DoubleChest) {
DoubleChest chest = (DoubleChest) closing.getHolder();
// ((Chest) chest.getRightSide()).close();
((Chest) chest.getLeftSide()).close();
System.out.println("Closed");
}
the print statement is ran but the chest won't close. I've tried running it a tick later as well and that doesn't change anything.
I'm probably doing it wrong
oh I see thanks.
now hear me out what is someone changes the name of the chest.
How do I make a percentage plugin? For example, I want to hit a command with a percentage message between 1 and 100, and each time it gives a message, for example, at 87%, say hello. Pls make a class for me because I am a newbie
Thx
No, learn how to use Random in java
Pls make a class for me because I am a newbie
Ok I am using random
so now do different things based on the output of nextInt(100)
you can also add nextInt(100) + <number> to make it start from that number
so nextInt(100) + 50 will make it 50-100 instead of 0-100
xD
well then I guess u can remove the 50 from that
dude that foncused guy is from my country
Wait what do you mean?
because #help-server seems to be a meme channel rn, i'll ask here
why do i get this? ports and ip's in config.yml are definitely right
07:05:05 [INFO] [RealRivex] -> UpstreamBridge has disconnected```
is the server online
yeah
show config
bungee?
connection_throttle: 4000
connection_throttle_limit: 3
timeout: 30000
stats: 806fb514-505c-4fc3-a4d1-0ef8ddbcde82
permissions:
default:
- bungeecord.command.server
- bungeecord.command.list
admin:
- bungeecord.command.alert
- bungeecord.command.end
- bungeecord.command.ip
- bungeecord.command.reload
network_compression_threshold: 256
servers:
lobby:
motd: '&1Just another BungeeCord - Forced Host'
address: localhost:25566
restricted: false
survival:
motd: '&1Just another BungeeCord - Forced Host'
address: localhost:25565
restricted: false
player_limit: -1
prevent_proxy_connections: false
server_connect_timeout: 5000
remote_ping_timeout: 5000
forge_support: false
remote_ping_cache: -1
log_commands: false
log_pings: true
ip_forward: false
disabled_commands:
- disabledcommandhere
groups:
md_5:
- admin
listeners:
- host: 0.0.0.0:25567
motd: '&1Another Bungee server'
max_players: 1
force_default_server: false
tab_size: 60
forced_hosts:
pvp.md-5.net: pvp
tab_list: GLOBAL_PING
bind_local_address: true
ping_passthrough: false
query_enabled: false
query_port: 25577
proxy_protocol: false
priorities:
- lobby
online_mode: true
god, longer than i'd expected lol
try using the full IP and port
change ip_forward to true first off
that wouldn't stop the server from connecting gecko
i know
tried that already. same issue
i mean it's connected tho
hmmmm
so idk why it doesnt work
tying to connect to survival as prio gives the same issue.
i even tried using waterfall because maybe that works better with paper, but nah
Ah it's a panel?
yea
enable it in your BungeeCord config as well!
the bungee is using an extern ip connection right?
thats not the issue
I've had this guy's problem before
ptero?
I know exactly how to solve it
Why is yoru lobby on 66 and your server is on 65?
i just tried to connect to the lobby directly to see if it's connected to the bungee
I couldn't run bungee on my ptero servers, had to put the servers on the actual root.
you can, just the ip and ports need to be configured in a strange way
as in the bungee being set to an extern ip (like 43.236.43.234)
and the server being set to 0.0.0.0 or 127.0.0.1 or something like that
because i changed from only survival, to bungee.
and it just added the 2 servers, and didn't changed the ports
and survival before was on 25565
the lobby should really be the default port of 65
why tho. don't think that makes an issue
as thats what you want them to connect to when default
bungee on 25565
k, i'll try tho
this is my test bungee config for two servers ```yaml
prevent_proxy_connections: false
listeners:
- query_port: 25565
motd: '&1Another Bungee server'
tab_list: GLOBAL_PING
query_enabled: false
proxy_protocol: false
forced_hosts:
pvp.md-5.net: pvp
ping_passthrough: false
priorities:- lobby
bind_local_address: true
host: 0.0.0.0:25565
max_players: 1
tab_size: 60
force_default_server: false
remote_ping_cache: -1
network_compression_threshold: 256
permissions:
default: - bungeecord.command.server
- bungeecord.command.list
admin: - bungeecord.command.alert
- bungeecord.command.end
- bungeecord.command.ip
- bungeecord.command.reload
log_pings: true
connection_throttle_limit: 3
server_connect_timeout: 5000
timeout: 30000
player_limit: -1
ip_forward: true
groups:
md_5: - admin
remote_ping_timeout: 5000
connection_throttle: 4000
log_commands: false
stats: fc7ce220-2bdc-4548-a441-05aed7a01159
online_mode: true
forge_support: false
disabled_commands:
- lobby
- disabledcommandhere
servers:
lobby:
motd: '&1ElgarLs BungeeCord1'
address: localhost:1
restricted: false
test2:
motd: '&1ElgarLs BungeeCord2'
address: localhost:2
restricted: false```
Yeah, that should work, just why is the port of the server's 1 and 2
just a placeholder or actually your config?
my actual config
Ah
I mean why not 
Well, isnt port 1 for TCP?
Aah
I personally prefer to do 25565 for bungee, and incrementing ports for the servers attached to it
yep, thats the normal way to do it
bungee and lobby should both be on 65. your other server should be on 66
sorry I thought you ment in yoru config
WYM
query_port: 25565 and host: 0.0.0.0:25565
bungee on 65, his lobby server on 66, and the other on 67 and so on
yeah, thats query lol
not lobby
yep
is your lobby server actually bound to localhost?
server-ip=127.0.0.1
in server.properties
`package noobsanj.bestsanjesh.ir;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class noobsanj implements Listener {
@EventHandler
public void onMessage( AsyncPlayerChatEvent e) {
Random rand = new Random();
int index = rand.nextInt(100);
e.getPlayer().sendMessage(ChatColor.AQUA + "NOOBSANJ " + ChatColor.DARK_GRAY + ">>" + ChatColor.YELLOW + "You are" + ChatColor.GREEN + index + ChatColor.YELLOW + "noob");
}
}`
well i fixed it
hello how can i create a command for this ?
by changing query port in bungee config to 25565
why tf is it 25577 on default if it doesnt work lol
it's not
hello how can i create a command for this ? :\
and i definitely didnt changed it
check docs
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i can'f find it :\
^
isnt the docs tho, thats the wiki
my bad
Do you know how to do this or not? 😐
i am using translator
dude
?
there
this explains how to create commands
what can't you find
i say how to create command for events :\
and this is for just create a example command not for events
:\
I want to create a plugin that will give me a random message if I use it
and i need events for this :
:\
you don;t need events for a random message from a command
yeah
Because I want to make a percentage command
ok how to create it
package noobsanj.bestsanjesh.ir;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class noobsanj implements Listener {
@EventHandler
public void onMessage( AsyncPlayerChatEvent e) {
Random rand = new Random();
int index = rand.nextInt(100);
e.getPlayer().sendMessage(ChatColor.AQUA + "NOOBSANJ " + ChatColor.DARK_GRAY + ">>" + ChatColor.YELLOW + "You are" + ChatColor.GREEN + index + ChatColor.YELLOW + "noob");
}
}
This is my class
and this is my main class
package noobsanj.bestsanjesh.ir;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public class onEnableDisable extends JavaPlugin {
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "[=-------------------=]");
getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "Noobsanj by " + ChatColor.GRAY + ">>" + ChatColor.AQUA + "ATLANTISMC");
getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "Discord Server" + ChatColor.GRAY + ">>" + ChatColor.AQUA + "");
getServer().getConsoleSender().sendMessage(ChatColor.DARK_GRAY + "[=-------------------=]");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "Noobsanj plugin has been disabled :(");
}
}
and this is my main class
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
int randomInt = ThreadLocalRandom.current().nextInt(100);
sender.sendMessage(whatever your message is);
return false
}
thats basic
ok wait
but really, just read how commands work.
public class onEnableDisable extends JavaPlugin {
i'll better say nothing
just follow a good tutorial https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
or if you like it more in video form:
https://www.youtube.com/playlist?list=PLdnyVeMcpY79UFZFfqwaXF2GUGc0v3YyG
This is eventHandler
Not cmd
Register events too
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().eqaulIgnoresCase("test")) {
sender.sendmessage("Test");
}
}```
Then Register on plugin.yml
I mean just
commands:
test:
can i get the chest location on inventorycloseevent if the inventory type is chest?
What do u mean
how can i make bungeecord now using real uuid's
I want to detect when they exit a chest from a skywars arena
i have a hashmap of all the chests with their location and a "id"
and i need to check the location of the chest they close out of (InventoryCloseEvent)
lmao
kek
:(
Post Installation section https://www.spigotmc.org/wiki/bungeecord-installation/
Maybe get Player Location :)
yeah, just enabling ip forwarding lol, readed that like 1 minute ago, but ty
Umi mean
um i*
When player Clos3s chest, Get Player loc
Check if Plyer Closed Chest and do i t
chests are entities right?
idk
tile entities
oh
On the inventory thats being closed
yeh
javadocs are your friend
I said to do this ;-;
yep
does anyone know how to detect if a living entity has hit a block?
armorstands have no AI and won;t hit blocks
so how i detect if has next a block
next block?
near**
you are fully controlling the stand
is that a question?
no, its a statement
tf
You are controlling the stand, its upto you to decide what it does
eeh but i don't know how to detect if it is close to a block, so i know i will make a runnable
i think i can detect if velocity == 0
you'd need to check its surrounding locations
if its moving you could raytrace to see if it collides with a block
I will see what I can
thxx
No problems
How can I get a list of serialized locations from config?
show how they are stored in config
Location is ConfigurationSerializable so you can probably just give it a List<Location> and it should probably serialize it properly
you'll have to get it with getList or something and then cast it to List<Location>
getLocation to get it back out
it's a list
I have List<Location> and then just set it on the config.
there's no getLocationList
yep, as a List you'd have to use getList
get every location and then save it as a world, x, y, z
no, waste of time when its already serializable
List<Location> spawnLocations = (List<Location>) data.getList(key + "spawnLocations");
``` like this?
okay, thank you very much
Is there no method that replaces the watch method in DataWatcher? I dug, but I couldn't find it.
I want to do thisDataWatcher#watch(10, (byte)127);
isn;t that second value supposed to be a boolean?
hmm,
in this thread, https://www.spigotmc.org/threads/npc-skin-second-layer-doesnt-showing-up.277869/ it's not boolean
not in there, thats out of date I expect
what signature is on the watch method?
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), watcher, true)); i'm trying to do this 😉
MetaData packet
hmm what do you mean?
I think
yes, and when you type watcher.watch what does auto complete offer you?
Index 10 says its a boolean
In order to change the skin you need to respawn the npc or send packets that respawn the npc. The Metadata doesnt contain the skin.
i'm setting npc's metadata 🙂
my npc already have skin
hmmmm okay
so what method should I use instead of DataWatcher#watch?
oh you are trying to enable all the skin parts?
in 1.15.2 not working
watch method doesn't exists
watcher.watch(It doesn't exists)(10, (byte) 127);```
I have no spigot up so can;t test
it doesn't exsits
whatever it wouldn;t be 10 anyway
ok
lettttts find method instead of DataWatcher#watch
thanks you but I can't access 😦
protected static final DataWatcherObject<Byte> bq;
okay i'll learn it@
can we create custom blocks using NMS ?
eff you GitHub, they just changed the format for all personal access tokens, forcing everyone to update
thanks you! I'll analyze and study the code you gave me.
awww wait
now I can access EntitySlime method!
so i can use entityslime's pathfinder yay
You serious...
Ugh
switch (container.getType()) {
case CHEST:
Chest chest = (Chest) container.getState();
content = chest.getInventory().getContents();
chest.getInventory().setContents(randomLoot(content, lootTable));
chest.update();
break;
case BARREL:
Barrel barrel = (Barrel) container.getState();
content = barrel.getInventory().getContents();
barrel.getInventory().setContents(randomLoot(content, lootTable));
barrel.update();
break;
default:
throw new IllegalStateException("Unexpected value: " + container.getType());
}```
Someone know why the barrel content are not set but for chest they are set ? (the methode randomLoot return a content and work for the chest)
and the case BARREL is trigger i checked
I'm trying to check if the player is holding a material which is in the yml file, for some reason the if statement doesn't work. Could someone help me out?
itemList = this.getCustomConfig().getList("repair.items");
Material mat = player.getInventory().getItemInMainHand().getType();
if(itemList.contains(mat)) {
// Do stuff
}
repair:
items:
- IRON_BLOCK
- IRON_INGOT
Um u didnt
thats wrong
you cannot test a string with a Material
nah my bad
.name()
Thanks!
holy formatting
public void onPlayerDropItem(final PlayerDropItemEvent event) {
final Item dropped = event.getItemDrop();
final Player dropper = event.getPlayer();
event.setCancelled(true)```
how i remove the item dropped of player inventory ? in the same slot he dropped from
One way to do it, all be it not the best: Summon a bolt of lightning on the location of the dropped item
Also plesae use discord code formatting so:
Boolean formatted = true;
if (!formatted) {
// Bad looking
}
Why are you making everything final tho?
for if i am going to compare a slot and not have the error of defining a variable instead of another
and don't change the variable for another one anyway
But your method is subject to change? you are cancelling it, aren't ya?
I might be completely wrong but I dunno
looks weird
no
...
But after putting an empty string after the ChatColor.BOLD it still not gives me a bold text
just to tell you, I want to remove exactly the item from, in your slot, and the amount of stock in the player
what do you mean by allow settings ?
so i don't need to update ?
so why it work with chest and not for barrel ?
and if i remember correctly the state of a block need an update to apply changes done on it
p.sendMessage(
net.md_5.bungee.api.ChatColor.of("#8596ab") +
"[" + net.md_5.bungee.api.ChatColor.of("#486d9c") +
"TEST" + net.md_5.bungee.api.ChatColor.of("#8596ab") + "]" +
net.md_5.bungee.api.ChatColor.BOLD + ""
);
seems like you don't know what your saying
remove update never change the state of the block
But I dont want any text after it
Hi, I'm trying to find a way that when I die I lose all items except a diamond pickaxe, can anyone help me?
Basically I want only the pickaxe to remain in my inventory after death!
I think you can modify PlayerDeathEvent#getDrops but if not just set keep inventory and remove all ItemStacks which aren’t a pickaxe
How?
ty
Where can I learn spigot api, I would like to deepen my knowledge!
Not work
Im pretty sure you can just set the itemstack type to air, in the early versions.
Hello, when I make a slime have no AI, and setGravity(true), gravity doesn't work. How do I fix this and is there an easy workaround?
package index
you cant really learn from just the docs, loom up a tutorial
look
Nah
java docs is for references when you already know what you're doing
if you're just starting out, a tutorial would be more useful
I recommend TheSourceCode's tutorials: https://www.youtube.com/watch?v=wysn_pFhcmE&list=PLdnyVeMcpY79UFZFfqwaXF2GUGc0v3YyG
Love the video or need more help...or maybe both?
💬Join us on Discord: http://discord.gg/invite/fw5cKM3
Thank you for tuning in to this episode of TheSourceCode! ❤️
If you enjoyed this video make sure to show your support by liking , commenting your thoughts, and sharing for all your friends to see and learn!
All code is available on Github:
...
He has a nice playlist, and you can skip through the ones that you don't need.
Navigating should be trivial, we have a searchbar and features like showing all classes in a package etc. Then spigot forums is a thing and a wiki site also exists nonetheless.
we have javadoc
Did you even take the time to scroll up?
if i try adding an item to a inventory and the inventory is full will it break? ( like give errors )
declaration: package: org.bukkit.inventory, interface: Inventory
Returns:
A HashMap containing items that didn't fit.```
No it won't, but nothing will happen afaik.
Hi, can you say me what is the name of an {} to set it in an nbt?
something like that
What library is that
actually my code is like that :
new NBTTagArray
I think at least
thanks
so i have this commands, but i want to have like /command args args1 args2 args3, if they only do command then a gui opens, and thats done, but,
i also want to make like shorcuts, for example command args args1 args2 opens the args2 gui, so i would normally set if command.args[..2] == X then open gui, but if i do that with every arg then im gonna have a lot of code
how I do in 1.8.9?
no because I need to setup it on a server with multiple version from 1.8 to 1.16 so I need it in 1.8
I don't want re-create my code on all version when there is a new one
iirc most packets are synced to main anyway before being sent but yeah, you can enqueue them on any thread you like
most tings will just work
ah
thanks
yes but when I use net.minecraft.server.v1_8_R3 I got a problem
and no you do not need to fucking "re-create your code" every time there's an update
lol just replace all lol
maybe if you used a version that isn't half a fucking decade old you could use the API instead of nms
It work with the api?
i mean
the api is very forwards compatible yes
i don't remember the last time i've had to go back and change something because of an update
How to manage/balance load or high amount of traffic from crashing the server ie. the member more than 400+ are not able to join and the error is showing "Server is Offline" but server isn't offline from host side?
@crude hound
yes?
look at that link
yes
but this version is used because I use it for pvp so it's better to dev in 1.8.9
ok so hello again
i have a question as always... any ways to display another item in hand while on hotbar a different item is selected
no
:(
Maybe by modifying the minecraft client
and any ideas so that when the map is my hand it doesnt actually show it up, since thats a problem im still facing
why does it have to be a map
too complicated idk
you want a map but you are literally removing everything from it that makes it a map
you might as well use a stick
is the args.lenght == 2 necessary? can i do
if(args[0].equals(something) && args[1].eqauls(somethingelse)) without checking if the args.length is 3?
Yes
youre damn right on that one but still :)
if you try to access an index that doesn't exist, you explode
if args.length == 1 and you try to get args[1] you explode
How do I set a custom items durability? I want to have a hoe with a custom properties, but only has the properties at a specific durability
the meta?
yea what would I put in
itemMeta.setdurability
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
when I do meta.setDurability there isnt any
yea
So how I spawn a nitwit in 1.8.9? (without glitched villager gui)
so
declaration: package: org.bukkit.inventory.meta, interface: Damageable
use this instead
i think
then what would I put
whats the proper way of doing this https://paste.md-5.net/acozawabaz.java
yea no not that
how to execute a class based on the args
make sure you return after checking length 0
i wwas thinking, can you call a class based on a variable?
like
/command test test1
new AllClasses.test
or
(CommandSender, String[] args)
ne AllClasses.test.test1
lol
if theres a doc explaining this
share the link
i cant find it myself
i dont even know how to call it
"replace args with classes name" is not a thing lol
just a question so i have bungee.yml and plugin.yml in my plugin which one does bungee take first the plugin.yml or bungee.yml?
`package plugins.romeo.healsucide;
import org.bukkit.plugin.java.JavaPlugin;
import plugins.romeo.healsucide.commands.Die;
public final class HealSucide extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("Your Plugin has started successfully");
getCommand("die").getExecutor(new Die());
}
}
`
am i doing smthing wrong here
i dont think so why
it says 'getExecutor()' in 'org.bukkit.command.PluginCommand' cannot be applied to '(plugins.romeo.healsucide.commands.Die)'
ty
ohh you need to do setExecutor()
didnt notice that
99% sure you are supposed to setExecutor()
Ohhh
Lmao small
yea u cant get something that doesnt exist xd
Sorry for disturbance, Thnx mates
its okay
whats the cheapest way to check if a block is of a certain type?
if(block.getType() == Material.BLAH)?
Like what are you trying to do?
lol spacedash
trying to check if a block has surrounding transparent blocks
you could do a getter in the main class so you would do check(Material.STONE) and it returns true or false
why in the main class
^
you could even do check(stone) and replace everything to upper case and add _ and material etc
And why is what i sent not efficient
oh idk its just an idea
How is that more efficient
like i think you can place it anywhere
you would just type check(stone) but i dont think its the best idea
That is still not more efficient speed wise
oh he means speed or typing speed?
i mean performance
If it is not transparent
No
aight
What
nvm
Hello. I am trying to fix plugin with no success. The plugin is abandoned so I can't contact the creator so I am kinda on my own in this. This plugins is MoreFish. It allows to modify fishes so you can have more types and stuff
Now I can set a biome condition to each fish so they can be catched in certain biome
The problem is that this one condition does not work
I found the piece of code that is faulty tho
override fun loadFrom(section: ConfigurationValueAccessor, path: String): Set<FishCondition> {
return if (section.contains(path)) {
section.strings(path).map {
it.split(DELIMITER).let { tokens ->
fishConditionFrom(
id = tokens[0],
args = tokens.subList(1, tokens.size)
)
}
}.toSet()
} else {
emptySet()
}
}
private fun fishConditionFrom(id: String, args: List<String>): FishCondition {
return when (id) {
"biome" ->
BiomeCondition(args.map { Biome.valueOf(it.toUpperCase()) })
else ->
throw IllegalStateException("There's no fish condition whose id is '$id'")
}
}
companion object {
private const val DELIMITER = '|'
}
}
The problem is that it is empty
In the config I can set the condition like this
condition:
- "biome|ocean|warm_ocean|deep_ocean|"
This is the only broken thing in the whole plugin so it would be nice if someone could help
For some reason the if statement where it splits using | throws empty string
Which ends up with error when trying to set biome condition in config
how can I set the rotation of a minecart?
You can just teleport it /tp x y z pitch yaw, the yaw will be ignored for minecart
thx
Oh wait is yaw the rotation?
I thought yaw is vertical rotation
Okay yaw is the left right rotation actually
I am not native english speaker sorry
why it is deprecated ?
declaration: package: org.bukkit.material, class: Crops
thank yoou
hi guys im currently having some troubles when editing my hashmap and im getting ConcurrentModificationException, i have tried reading documentation and google, sadly i can't find any way of fixing it, could you please help me?
stacktrace: https://paste.md-5.net/uzebodebit.rb
class: https://paste.md-5.net/ojipubipov.java
any code examples for iterator?
what should i use???
no since i also need Generator to store
and GenPlayer is the owner of the Generator, so i can't
yes?
i need to create new ones
since players can have multiple ones
what if i merge GenPlayer and Generator into one class and use a List instead?
how much are you typing man xd
Hey how do I remove pathfinder goals from a slime to make it not attac or move
Attack
how do you make a mob walk to a place
try removing it's ai
he's asking how to remove it lel, btw i think there is a method
like setAI(true/false) idk
setAware
@quaint mantle wtf are u writing man
how do you make a mob walk to a place
would summoning an invisible, invurnerable armor stand above that place and setting the mob's target there work?
Is there a way to make custom monument type things?
how do you make a mob walk to a place
would summoning an invisible, invurnerable armor stand above that place and setting the mob's target there work?
Greatings everyone
Hello.
cant any one tell me how to resolve this error
(CreepyCoder.AdventurePack.Core.Main.Plugin is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @f2ce57b;
Hi Gecko
Need code
probably wrong plugin.yml main class
package CreepyCoder.AdventurePack.Flowers.Main;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import CreepyCoder.AdventurePack.Core.YAMLManager.YAMLManager;
import CreepyCoder.AdventurePack.Core.YAMLManager.YAMLSettings;
public class Plugin extends JavaPlugin {
public YAMLManager YAMLManager = new YAMLManager(this);
public YAMLSettings YAMLSettings = new YAMLSettings();
private Plugin YAMLManager2 = (Plugin) Bukkit.getServer().getPluginManager().getPlugin("CreepyCoder.AdventurePack.Core");
@Override
public void onEnable() {
//YAMLManager.getSettings();
}
@Override
public void onDisable() {
}
}
Like, lets say custom structures in order to make a custom boss battle
how do you make a mob walk to a place
would summoning an invisible, invurnerable armor stand above that place and setting the mob's target to the armor stand work?
Other options include the ChunkLoadEvent, ChunkPopulateEvent, or NMS
How do I get an instance of EntitySlime?
HOOOLY cow thanks. but i really didn't want to get spoonfeeded ahah
What do I do
wait whats return if return when thats so cool lol
Kotlin
NMS allows you to hook into the Mojang generation stuff, but it's janky
why is everyone ignoring me
Im looking at this BlockPopulator on the jd and it is looking kinda sparse
Have you tried it?
for this tho i would need to make my checks for item right?
looking for alternetives, because that would mean players could hit the armor stand and invisibility isn't foolproof
is there a method or something?
whats an nms?
oh no
net.minecraft.server
how do you even move a mob, such as make it walk forward one block
You can teleport it or mess with velocity
hmm
But the proper way is a pathfinder
Hi, noob question here so sorry for that i just started today.
I want to make a plugin that constantly shows u how close are you to the world border above the hotbar. I made a command that does that but im not sure how to make it work without a command. like that it constantly runs all the time for everyone and displays above the hotbar
so the armor stand thing?
cant you teleport an entity like 0.1block north?
Sure?
so it "moves"
you would have to use a runnable
use a schedueler
thanks I will look into it
no moving animation
is a pathfinder just my invisible armor stand idea?
A simple move to location pathfinder would be handy tbh
could you explain what the solution was? I'm new to spigot, and I didn't really understand
this one seems to be marked as solved
beautiful
how can i get the persistent data container of a block that have been placed down before?
A block or a tile entity?
So a tile entity
once a block is placed you cant keep the data, unless you save it before placing
block.getState.getPersistantDataContainer iirc
if thats your question
someone said that I could save it in an eventhandler or something
.
Not work
what's the difference between a block and a tile entity?
When i death I don't have pick
does EntityChangeBlockEvent happen for tile entitys?
well but it's for my command to lock a block again, when a player executes /protect and rightclicks a container his uuis is placed inside a hashset and an eventlistener continue checks if a player if in that hashset and then applies a lock if that's true
I've told you how to do it
players?
there isn't a PlayerChangeBlockEvent
BlockPlaceEvent