#help-archived
1 messages · Page 156 of 1
Question for those more familiar... do init blocks get called after constructors? Or before?
Actually I should do this differently
Alright. That should fix that lol
Yep!
in a plugin with multiple shaped/shapeless recipes, are we supposed to use one NamespacedKey for each or one NamespacedKey only?
You need a new key for each recipe
right thanks 👌
How do i import 1.8 API using Intellij? It wont let me use ENDERDRAGON_GROWL and is forcing me to use ENTITY_ENDERDRAGON_GROWL
if it points to it,then thats the sound
https://media.discordapp.net/attachments/399719720502165515/727948279404560484/unknown.png Why is my yml file blank if i've set the defaults?
lavaproof cow?
Yessir!
hell yeah!
lmao
https://hastebin.com/dohineqewe.java Can someone help? The YML file is created but its blank but I set the defaults
One message removed from a suspended account.
send full error
Thanks a lot Choco!
One message removed from a suspended account.
https://hub.spigotmc.org/jira/plugins/servlet/mobile#issue/SPIGOT-5887 could you have a look at this 1.16 feature too? 😬
Sorry it's not super great with items :(( client-sided limitations
There's a hotkey for that?
oic
I went through the patchnotes and looked for this stuff
Already was 🙂
Yay progress
Oh wow
Horses will be striders
Hmm I'll take that
Now we need waterproof
Waterproof endermen
In that case you can cancel the teleport event iirc
🤔
My plugin version is on 1.1 but this method still shows 1.0 https://api.spigotmc.org/legacy/update.php?resource= resource id
6 hour cache time
Ah okay thanks
Is there a ProtocolLib PacketType that only refers to the off hand arm animation? PacketType.Play.Client.ARM_ANIMATION checks for both arms
How many players can spigot hold on a server?
^ That's usually up to whoever/whatever is hosting the server, not spigot
ideally you could just access bukkit reflection and set your player slots
Yes of course if i want to have 500 players on one server i also need a better server but can this hold spigot?
Spigot by itself can hold 120 on a single server
you can get upwards of 200 with the right equipment
usually 100 is enough,just split them up in more servers
private void createConfig() {
configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) {
configFile.getParentFile().mkdirs();
this.saveDefaultConfig();
saveResource("config.yml", true);
getLogger().info("'config.yml' didn't exist, so it was created.");
}
config = new YamlConfiguration();
try {
config.load(configFile);
} catch (IOException | InvalidConfigurationException exception) {
getLogger().info("Could not load config.yml");
}
}```
What did I do wrong here?
It's not making the file in the plugins directory or in the .jar
you can just use the method #saveDefaultConfig()
@tiny pebble there’s a pretty easy nms method for making the offhand move if that’s what you’re looking to do.
that's what I'm looking for yes. I've tried an NMS method but it made the offhand swing indefinitely
I don't use protocol lib so I wouldn't know
@tiny pebble I’ll get you the code. I use it for a little dual wielding feature thing of mine
thank you so much 🙂
How to get a horse neigh sound? I don't see anything in EntityEffect
@worn fiber it doesn't create at all?
I’m also working on a plugin that lets you bash people and things with your shield as a secondary attack, but it has to use the Paper API
Since spigot doesn’t support setting the shield cool down.
nms 😮
I don't think anybody uses just standalone spigot lol
Honestly lol
right now all i'm trying to do is when holding a certain item and you left-click with it, the other item in off-hand also hits lol
I do lol
do you guys not use craftbukkit to program?
wym by that? the Craft classes ?
Spigot is just a fork of craftbukkit
^
Uhh I'm having some issues with basic java lmao, I have a class called "GUI", it has a public variable called spawner, inside the class there's a public void method called openInventory which passed a Player object and a StackedSpawner object. In the method I set the aforementioned spawner variable with this.spawner = stackedSpawner (the StackedSpawner passed in the method). I then try to access it in my Listener method after the spawner has been initialized. I feel like i'm being stupid here but any help?
And craftbukkit shouldn't really be used anyway
what
So uh
Anybody know how to get the horse neigh sound?
Its not the EntityEffect enum
Jeeb send code ig
winner winner
yes im aware spigot is a fork of bukkit
but you shouldnt use spigot in your ide
whut
// Stacked Spawner Object
public StackedSpawner spawner;
// OpenInventory Method
public void openInventory(Player player, StackedSpawner stackedSpawner){
spawner = stackedSpawner;
for (InvItems invItems : InvItems.values()) inventory.setItem(invItems.getSlot(), invItems.getStack());
ItemStack spawnerStack;
spawnerStack = spawner.getDropItem();
ItemMeta meta = spawnerStack.getItemMeta();
meta.setDisplayName(meta.getDisplayName() + ChatColor.translateAlternateColorCodes('&', " &f(&6x" + spawner.getStackAmount() + "&f)"));
spawnerStack.setItemMeta(meta);
inventory.setItem(13, spawnerStack);
ItemStack spacer = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
for (int i = 0; i < inventory.getSize(); i++){
if (inventory.getItem(i) == null) inventory.setItem(i, spacer);
}
player.openInventory(inventory);
}
// Listener Method
@EventHandler
public void onClick(InventoryClickEvent event){
if (event.getInventory().getTitle().equalsIgnoreCase(inventory.getName()) &&
event.getCurrentItem() != null && !InvItems.isInteractable(event.getCurrentItem())){
event.setCancelled(true);
return;
}
event.setCancelled(true);
InvItems invItems = InvItems.stackToObject(event.getCurrentItem());
if (spawner == null) return;
}
there are different forks of spigot people use, but all bukkit is the same
some spigots have removed classes
Every fork comes from spigot though
hopefully
Or at least should
Jeeb and what was the issue? sorry for me
Well then they are bad forks /shrug
they arent lol
green I mean a good fork shouldn't remove anything
Even though the spawner is initialized through the openInventory method, it still returns null in the InventoryClickEvent
It's almost never necessary
it can is what im saying
Hey, when I set setPersistent(false) for a entity, does that mean that the entity will be removed on ChunkUnload or on server shutdown when saving world?
if (!plugin.getDataFolder().exists) { plugin.getDataFolder().mkdirs(); } or smtng
I did that
or if you have a file instance File#getParentFile
do people not just use #saveDefaultConfig() ?
I mean it's a good practice to do it by your own
wut
private void createConfig() {
configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) {
this.saveDefaultConfig();
saveResource("config.yml", true);
getLogger().info("'config.yml' didn't exist, so it was created.");
}
config = new YamlConfiguration();
try {
config.load(configFile);
} catch (IOException | InvalidConfigurationException exception) {
getLogger().info("Could not load config.yml");
}
}```
This doesn't work either
btw saveResource 2nd param should be false in most cases including yours pretty sure
@worn fiber And config.yml exist in jar?
bruh
Add it then lol
saveResource copies the file from the jar and puts it in plugin folder + dumps eventual content of the file
if you want to create a new file use File#createNewFile instead of JavaPlugin#saveResource
So if I ship out this plugin, it'll automatically create config.yml from the one in the jar file?
If you're using the built-in config it has to be an embedded resource.
But I mean you could eventually create a new config.yml and then dump content
but then again config.yml is pointless in todays world really
wth why lol
all you need it for is to set hostname data lol
everything else can be stores via redis
or mongodb
lmao not everyone has a database etc
Hello, I need help, I downloaded spigot 1.15.2, I made my server, and I deleted the folder by mistake, and now, i'm trying to make another spigot server, and the java file does not work
a plain file config isn't pointless but there is surely cases where it should be avoided
What did you do?
Even though the spawner is initialized through the
openInventorymethod, it still returns null in the InventoryClickEvent
All good ❤️
@sleek minnow just install it the same way you did
Well you're not directly initializing the spawner at openInventory
I want to have a config.yml so people can edit prices.
yeah
Does not work Green, I reinstalled and now, does not work
this.spawner = stackedSpawner;
didn't work either
Nope, just the java file doesn't do anything
@worn fiber ideally for player data use mysql
I want to automatically generate config.yml if it doesn't exist
just re-assigning spawner reference jeeb
This isn't playerdata
felix a premade one or a new one
spanish dude you need to add your start command
The StackedSpawner is only passed in the openInventory method.
or run.bat
And how i do that?
depending on your os
yes Jeeb
Windows 10
spigot wiki forums can help
IMO for small amounts of player data using yml is fine
@naive goblet Premade
Coll imagine hypixel though
How would I then re-assign it in the InventoryClickEvent
https://hastebin.com/dohineqewe.java Can someone help? The YML file is created but its blank but I set the defaults
i run a larger scale server so i just have no use for config
I want it to have a default set of prices that can be modified
yea thats good for a config then
Jeeb this kinda seem like a xy problem. What are you originally trying to do.
Felix start with adding a config.yml the same way you added your plugin.yml
Add/remove from a stacked spawner, I have the method setup, it's just that the spawner is returning null lmao
all servers large or small need a db regardless if you use flatfile storage or not
I made the config.yml
add your cfg options then
okay it should load now
But instead of throwing a hissy fit and melting down when it doesn't exist, I want to create it.
I have a config tutorial felix
I didn't do it there Green
@frigid ember I made a start.bat
great
@Override
public void onEnable() {
// Create the config file if it doesn't exist
saveDefaultConfig();
// Register commands
this.getCommand("helloworld").setExecutor(new HelloWorld());
}```
now run it
It does not create it.
add saveConfig after it
Does the jar contain config.yml?
Hey @naive goblet can you check this out and figure out why my yml file is blank https://hastebin.com/dohineqewe.java
And, does not work
did you add the start command line?
Error: Unable to acces jarfile spigot.jar
the jar needs the config lol
I want to create it if it doesn't exist
what config?
I said that
Spanish phone you need to run as an admin
you're saving it to nothing @lapis plinth & File.seperator yikes
Oof
@lapis plinth Just set the values of the keys?
you cant do that @worn fiber
So then how do other plugins auto-create it if it doesn't exist?
Oh
Says the same @frigid ember
Oh
such as what ram you want?
Double a workaround would be to create an empty config.yml and then add default options
So I need to make a file and load it into the config.yml on build
🤦♂️
This doesn't make any sense
i just put this @echo off java -Xms1G -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot.jar nogui pause @frigid ember
just run it using java -jar spigot.jar
try that
and make sure the file name is spigot.jar
for the actual jar file
keep start.bat the same
oh
Felix add the premade config.yml here
as I did
and then re export your project into a jar and see if the jar contains the premade config.yml
It works
good
alg then?
you're saving it to nothing @lapis plinth & File.seperator yikes
@frigid ember How do I save it to something?
I have customConfig set to smt here FileConfiguration customConfig = YamlConfiguration.loadConfiguration(customYml);
create file first
The file is created, the defaults arent added
try to create file first*
How do I access the config variables?
plugin.getConfig().getInteger();
This doesn't do it
you didnt create it though
how do i "create" it?
customYml.createNewFile();
plugin.getConfig().getInteger(”path”);
oh
it’s maybe getInt
yeah i guess a
@frigid ember still nothing
Nope
kk
or you could do saveDefaults
Felix send code v
public class HelloWorld implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
String x = plugin.getConfig().getInteger().toString();
player.sendMessage("x");
return true;
}
}```
Add/remove from a stacked spawner, I have the method setup, it's just that the spawner is returning null lmao
Remove from what?
@worn fiber you need to declare the plugin reference
That worked thanks!
public static Plugin plugin;
public static Plugin getPlugin() {
return plugin;
}```
Plugin plugin = PluginPlayground.getPlugin();
String x = plugin.getConfig().getInteger().toString();```
Like this?
Or should I make an instance of it?
would anyone be able to recommend a customisable coloured names plugin? ^^
it'd be cool to have custom patterns other than rainbow if that was possible
class Main extends JavaPlugin {
void onEnable() {
getCommand("command").setExecutor(new Command(this));
}
}
class Command implements CommandExecutor {
private final Main plugin;
public Command(Main plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
System.out.println(plugin.getConfig().getString("path"));
}
}``` @worn fiber
is a player ping(delay server-client) stored somewhere? or how would i acces it
sam as 1.16.1 released very recently there might not be any of those
yeah that's fair ^^ i've just not been able to find anything i was looking for in previous versions either
Any help 😅
Jeeb Idk I still don't know what exactly removing a spawner means. When a player breaks it or places it?
nvm found out ping is in craftplayer
All of that is working, it's just that when going from the openInventory() method to the InventoryClickEvent, spawner variable becomes null. It's not null in the openInventory() method since it's used for one of the ItemStack names.
Firstly you should encapsulate the variable spawner
and make a setter and a getter for it
much easier to maintain
simple question: what's the best way to keep TNT enabled but stop it from causing block damage?
Use a plugin for it, pretty sure
recommendations?
public StackedSpawner getSpawner(){
return spawner;
}
public void setSpawner(StackedSpawner spawner){
this.spawner = spawner;
}
Yeah
Now set it whenever you want and make sure it isnt null
zane nope but shouldn't be that hard to find
It was only null when I used it in the InventoryClickEvent, not in the openInventory() method
Then it wasn't assigned
I was using this.spawner = spawner
cool thanks :)
can someone tell me hoe to make a 60% stone adn 40% cobbleston
yes it would be null if you never assigned it
Doesn't work with getters and setters.
// OPEN INVENTORY METHOD
setSpawner(stackedSpawner);
// INVENTORY CLICK EVENT
StackedSpawner stackedSpawner = getSpawner();
ok
Think that capability isn’t there anymore
It is
Works with FAWE
Also why did //up stop being a thing
Or at least it was in 1.15
Has anyone noticed that?
I think it's /up now
Oh
Anyone got any ideas?
Hi, I have a question. If I create a Listener for event "InventoryEvent", will it also listen for events "InventoryClickEvent", "InventoryMoveItemEvent", etc?
manager.addPacketListener(new PacketAdapter(this, PacketType.Play.Client.ARM_ANIMATION) {
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
PacketContainer offhand = manager.createPacket(PacketType.Play.Client.ARM_ANIMATION);
offhand.getHands().write(0, EnumWrappers.Hand.OFF_HAND);
CraftPlayer player = (CraftPlayer) packetEvent.getPlayer();
final PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player.getHandle(), 3);
List<EnumWrappers.Hand> mainhand = new ArrayList<EnumWrappers.Hand>(Collections.singleton(EnumWrappers.Hand.MAIN_HAND));
player.sendMessage("checkpoint 1");
if (player.getInventory().getItemInMainHand().equals(Items.jasonSword) && packetEvent.getPacket().getHands().getValues().equals(mainhand)) {
player.sendMessage("checkpoint 2");
player.getHandle().playerConnection.sendPacket(packet);
player.sendMessage("checkpoint 3");
}
}
});
This is the farthest I've gotten.
I get to checkpoint 2 and 3 successfully, though the off-hand animation doesn't play. Any ideas?
anyone know how to get the current players on a bungeecord via spigot?
and the max players of the bungeecord.
@hot girder you can’t listen to the InventoryEvent
@winged sparrow Sorry for the mention, let me know if you don't want me to do it again. Just wanted to let you know what I've got so far and what doesn't work since you know how to do this kind of stuff
bruh, ok
@tiny pebble No problem. I’ve just been busy and haven’t had a chance to get to my machine
I don’t remember the code by heart but as soon as I get to my pc and open my IDE I will send it to you
no worries, i'm just working on doing it myself as of now and this is the closest i've gotten haha
alrighty, thank you
It’s been at the forefront of my mind, promise lol
haha no worries
is (byte) x the same as x & 0xff in bytecode?
Yes
@naive goblet Sorry, I'm a bit late. But in the code sample you posted (https://ptb.discordapp.com/channels/690411863766466590/690470011382267904/727964185543311370), what exactly is happening?
Are they in the same file?
How does it access Main from Command when it didn't make an instance?
Does Main() pass itself into Command(), which makes an instance allowing you to access Main?
whenever I set my server ips to localhost it gives me http://prntscr.com/ta0yku
It seems Spigot 1.16.1 is ignoring the world-container option in bukkit.yml.
All the folders are going into the main server dir instead of my /worlds folder :|
Information:
[16:26:50] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-4d9262c-3b9cf0f (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT)
[16:26:50] [Server thread/INFO]: Checking version, please wait...
[16:26:50] [Thread-9/INFO]: You are running the latest version
bukkit.yml
spawn-limits:
monsters: 70
animals: 10
water-animals: 15
water-ambient: 20
ambient: 15
chunk-gc:
period-in-ticks: 600
ticks-per:
animal-spawns: 400
monster-spawns: 1
water-spawns: 1
water-ambient-spawns: 1
ambient-spawns: 1
autosave: 6000
aliases: now-in-commands.yml
settings:
allow-end: true
warn-on-overload: true
permissions-file: permissions.yml
update-folder: update
plugin-profiling: false
connection-throttle: 4000
query-plugins: true
deprecated-verbose: default
shutdown-message: Server closed
minimum-api: none
world-container: worlds # This is not working
Yeah that is known
I believe MD didn't reimplement it because he didn't think many people used it
Oh, that's very unfortunate
I hate having worlds in the main folder
- all my servers have worlds in "worlds" that I've made
What is the link of the hastebin md5 ?
?paste
Does anyone know where I can get/hire someone to help with setting up a Spigot server with a few issues?
I've now seen the bug report for my issue, unfortunately my host does not allow me to edit the startup paramaters
I hope a better solution is found soon 😦
@crisp ermine Hello, I can not join your discord. I guess I'm ban but I have a question about one of your DeluxeChat plugins
Something different as well, the usercache.json was also moved to /worlds when I used a local server to test the startup parameter
Not sure if that's intended or not
is this a really overcomplicated way to randomly assign teams?
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
board.registerNewObjective("Paintball", "dummy", "Paintball Game");
Team red = board.registerNewTeam("red");
Team blue = board.registerNewTeam("blue");
Player[] playersArray = (Player[]) Bukkit.getOnlinePlayers().toArray();
List<Player> players = Arrays.asList(playersArray);
Collections.shuffle(players);
for (int i = players.size(); i > 0; i--) {
Player lastPlayer = players.get(players.size() - 1);
if (players.size() % 2 == 0) {
red.addEntry(lastPlayer.getName());
} else {
blue.addEntry(lastPlayer.getName());;
}
players.remove(lastPlayer);
}
}```
?paste
Yes, it is. Don't decompile code and you don't have that issue, robby
Where should I make my name change request
dont decompile code?
on your profile settings
Player[] playersArray = (Player[]) Bukkit.getOnlinePlayers().toArray();
List<Player> players = Arrays.asList(playersArray);
Collections.shuffle(players);
for (int i = players.size(); i > 0; i--) { ```
Tends to look a lot like what a decompiler would do
thanks
there is also Arrays.sort
so are you saying I used a decompiler?
because that runs like 3 times over 👀
Collections#shuffle just does toArray and calls Arrays.sort
Okay so bit of an error, updated to paper 1.16 from 1.15. A player logs in, hops in a boat.
Player lost connection: Internal Exception: java.lang.NoClassDefFoundError: net/minecraft/server/v1_15_R1/PacketPlayInVehicleMove
Every time they try to rejoin
they're insta disconnected
hit with that
can we make a petition to change the name to paper instead of spigot?
Doesn't look like a paper error to me
So wondering if anyone could help, that's all
Since Paper was made from Spigot
anything can be a paper error
especially since their build process is completly different
so unless you test that bug with a spigot build
there is nothing we can do
I'm just gunnah wait till someone else sees, might have experience. I hope thats okay with you
good luck with that then 😉
I'm allowed, right?
i'm just saying you're gonna get the same answear
I asked before about paper issue and got an answer
Regardless of whether or not you think it's a paper issue, you're running software that we do not maintain
You should seek support in the appropriate place, we cannot help you with something that may very well not have anything to do with us whatsoever
If they deem it to be an issue with CraftBukkit, they may push a patch upstream to resolve it
Until you can replicate that issue on Spigot or CraftBukkit, it's nothing we will resolve nor support you with
is there any way to get the sender from org.bukkit.plugin.messaging ?
Anyone know what's causing this?
whate exactly?
I'm wondering spigot (because Italic Problem (past), or Plugin
the names, they are the item names not the Custom names.
It's messed up to the point were Sub GUI's are also randomly effected.
[14:06:48] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-4d9262c-3b9cf0f (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT) [14:06:48] [Server thread/INFO]: Checking version, please wait... [14:06:49] [Thread-72/INFO]: You are running the latest version
whats the mthod to get a file of this name and to be able to read that file;s contents?
File file = YOURFILE;
FileConfiguration config = YamlConfiguration.loadConfiguration(file);``` ?
new inputstream?
found the problem, It's the Symboles
@fierce briar was about to say, they need to be in unicode
afaik
only utf-8
https://hastebin.com/ubegiyofaq.cpp So I have the file made here
https://hastebin.com/xezunigoyi.cs and want to read it in this separate class
You want to read config.yml?
hi @subtle blade , I think I found a bug in beehives again. it seems that EntityBlockStorage#setMaxEntities is not working correctly
if I print the #getMaxEntities it prints the correct value
but only 3 bees go inside
EDIT: Sorry for the ping, it does work. I forgot to update
AtomFTW I'd encapsulate the FileConfiguration instance and perhaps use dependency injection to access it from another class
is there a plugin for a kickme command?
@naive goblet I want to read a custom file name, it varies every time
and how do I do that xD
by name?
well could use a File instance and invoke it's constructor that takes a path and a filename
🤔
I wrote this, https://www.spigotmc.org/threads/yaml-configuration-tutorial.444987/ maybe it can help a bit
Lol kk ty
is there a plugin for a kickme command?
@frigid ember you dont need a plugin to have a /kickme command
can be done from command.yml
afaik
I can make that rn if you want lol
i dont want to let the entire world kick each other
if you have the time, that would be great ❤️
and ofc if its not a bother to you
What server version?
1.16.1
So perhaps if they have a permission to do it?
haha well should take 5 min if my wifi and pc wants to show some mercy
yeah lmao
How do I make a post on the forums im an idiot
First get an account
Done
Then choose which forum you want to post on
..
IDRK what I would post it to
Im trying to give players the permission to run /warp with essentials using luckperms but when I search it I cant find it 😢
Oh lul
sorry and thx
Oh thx
How can I completely disallow GUI Inventory modification?
// Cancel items being dragged into our GUI
@EventHandler
public void onInventoryClick(InventoryDragEvent event) {
if (event.getInventory() == gui) {
event.setCancelled(true);
}
}```
I tried this but it doesn't work
InventoryClickEvent#setCancelled(true)
hey I have a question
What does the pound sign mean?
£ ?
gbp i think
lmao yeah
the british pound
InventoryClickEvent#setCancelled(true)
/
this
no
no
£ is gbp
It's Javadoc notation, Felix
that's hashtag
*octothorpe
I already have an event handler for InventoryClickEvent
;)
or a sharp
^
Have you never gotten an automated message when dialing a company or anything?
Is there a full list of events?
Dialed an extension?
what
how many names must a symbol have before people stop using it altogether
cuz im british
"octothorp" is the actual name according to Wiki
we call it 'diez' here
I have
// Cancel items being dragged into our GUI
@EventHandler
public void onInventoryClick(InventoryDragEvent event) {
if (event.getInventory() == gui) {
event.setCancelled(true);
}
}```
And
```java
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
// Ignore if the item clicked was not in our GUI
if (event.getInventory() != gui) return;
// Cancel the event so the player doesn't actually take the item
event.setCancelled(true);
// Bunch of stuff below here but it's long
I can still drag and place items into my GUI
DoubleFelix, what is gui
An inventory
._.
However the views are
yeah you don't use == for objects usually
Inventories aren't == comparable
@subtle blade The Spigot website lied 😱
lol
It's full of liars! 😛
ok i read that as what is a gui
remember when the wiki told us to use InventoryHolder
You should be able to safely compare references of an inventory view
ye
// Cancel items being dragged into our GUI
@EventHandler
public void onInventoryClick(InventoryDragEvent event) {
if (event.getInventory().getContents().equals(gui.getContents())) {
event.setCancelled(true);
}
}```
Like this?
No, its view
When you open an inventory you're returned an InventoryView
In an InventoryEvent, you can getView() to get an InventoryView
if (event.getView().equals(gui)) {?
You could but == should be enough
But it should still work?
it will
is gui an inventory or inventoryview
Inventory
pretty sure you should compare 2 inventoryviews ?
You can. You just have to be verified
oh!
well now i feel encouraged to make a forum acc
whether I actually will is another question
always handy
There isn't an event for player death :(
Oh
.-.
just heal the entity
you can't bring back deads to life
By that point, the player's already in the process of dying
Maybe you could listen to EntityDamageEvent and check if the damage will kill the player.
if it does, cancel it.
maybe
store player location, if they die, respawn them, set their location back?
hmm yeah get if health is under 0 or smtng
no collision is not possible without teams?
.
Works fine now lol
Now I need to fix this broken GUI
Since I can still put items into it.
how do i make a backup script?
@frigid ember
becaise i do /backup and it say there is not an external backup script
Does an event handler method need to have the same name as the event?
nope
I cannot figure out why this is wack then
The method can be named whatever you want
Dang
public void anyname(InventoryClickEvent /* <-- has to be specific and is case sensitive.*/ e /* <-- can be anything aslong as it doesn't take a java keyword*/) {
}```
// Cancel items being dragged into our GUI
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
if (event.getView() == gui) {
event.setCancelled(true);
}
}```
I made the edits that were suggested
gui is still an inventory?
Does anyone know how to set group chat colours e.g: '&8[{GROUP}] &f{DISPLAYNAME}&7:&r {MESSAGE}' with both essentialschat and luckperms together? I'd assume the bigger community on here know of both plugins and have experiance with them rather than asking the same question on the individual discords. @tropic nacelle
I know the answer but you pingd me, go ask in essx discord
does getHostname on PlayerJoinEvent get hostname even if behind bungee? is there a way to get hostname connected with from individual servers?
i mean, you said you knew the answer so why not help? i ping for your help 🤦♂️
sorry if this is the wrong place to ask.
Masa's Tweakeroo mod allows you to place directional blocks facing away or to the side relative to you. Making redstone building easier. Sadly this is a fabric mod so I can't put it on my server without changing from spigot to Fabric, but spigot is just so much better for performance. Is anyone here aware of a plugin that allows the same trick?
or even datapack?
Elijahzeal pretty sure you could fix it by per group format
Hyperbus I don't think anything like that exist as a plugin atleast
well could use a File instance and invoke it's constructor that takes a path and a filename
@naive goblet IDK how to do this, I just got back to my PC and I don't see where in your tutorial would help with this xD
It does cover how you could implement a system that takes different filenames etc
But if you have command you'd do something like this: [typing takes sometime]
//oncommand
String arg = /* your string */;
File file = new File(plugin.getDataFolder() /*path\folder*/, arg + ".yml");
if (!file.exists()) {
System.out.println(arg + ".yml doesnt exist!");
return true;
}
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
Huh, I wouldn't have to JUST use a command, this could be used within a Event as well right?
yep
kk
though eventhandlers is void methods you should just return in File#exists
kk
help how do i make a backup script pls help
of what?
minecraft
wym
Well idk what you'd need a backup script for?
to back up a thing
what specifically
make your own .sh script
?
backup isnt a built in minecraft command
when you run that command its like running backup in the linux terminal
use this
mac?
Linux
im on mac
Pretty sure you could find a decent tutorial that covers mac
I doubt you'd need backups if you're localhosting a mc server for dev uses
gui is still an inventory?
If I switch it to an InventoryView, will it still work as normal?
how lmao
I backup daily with systemd and crontab
DoubleFelix I think you'd do something like InventoryEvent#getView == InventoryInteractEvent#getWhoClicked#getOpenInventory
or perhaps not
i dont have a hosting i run it off my computer
?
Google probably has plenty of backup scripts and resources
?
What?
how do i get mmy world back
just double checking, this means X doesnt exist right?
it turned into ocean
What did you do to it
😂
Yes atom
kk
it was floating island and then oceean
Well if you don’t have a backup you are likely screwed
wot how why i try make backup but no work
does Mac even have system restore
what is that
Mac has time machine iirc
Glhf
is there a way to get the hostname connected with from individual servers behind a bungee? e.getHostName gets the bungeeIP
Why tf does it say this file doesnt exist
when it does
lmao
"[18:36:19 INFO]: 22445145-791f-487a-ade0-c93469a7cd2a.yml doesnt exist for some wierd reason!"
Why are you loading from it before you check that it exists :p
what is "path"
Why are you loading from it before you check that it exists :p
@lone fog wdym
and this is path
why not use new File(getDataFolder(), arg + ".yml")
^
getDataFolder() is a method from JavaPlugin
Just use an instance of your plugin
but that shouldn't be the issue tho should it?
Is that code in your plugin class or another?
That code is in a listener class
I'm guessing the listener is constructed from your plugin class then?
I have the listener registered if thats what you're asking
im not using any constructors in this class yet
anyone know if jobs is working 1.16? i cant get mine to work :/
If you create a constructor for you're listener with a parameter for your plugin. and then from your plugin class where you use "new Listener()" pass your plugin as an argument e.g. new Listener(this)
where this would be your plugin because it's inside your plugin class
Then you would store the plugin in a field in your listener class
No, you pass this in your plugin constructor
Do I have to register events for them to work?
I didn't register a GUI lib class that implements Listener
Yes you do
It says the file still doesnt exist
How do I register those?
heres some pseudo code you can take xD
public void registerListeners() {
PluginManager pm = Bukkit.getServer().getPluginManager();
pm.registerEvents(new PlayerRightClick(this), this);
pm.registerEvents(new CorePlace(), this);
System.out.println("Plugin has successfully registered listeners");
}
Does anyone know how spigot handles a BlockBreakEvent that breaks multiple blocks? My issue is that if I cancel the drops for a block with a torch attached, then use e.getBlock().getDrops() then I only get the drops for the block, not the torch.
GUI is a class which creates a GUI object
Do I need to register it?
It requires two parameters
IDK i use SimpleInvs api for guis
Hello ✋👋
It's possible for buy system to bug?
A buyer of my plugins say than he have been receive the payment fracture but can't download the plugins
Felix I think comparing 2 inventory instances is fine
You don't necessarily need to check the inventoryview
So I don't need to register it?
if (event.getContents() == gui) {?
i still need help with my account because i sent email to support tmp-support (at) spigotmc.org and i havent heard anything since atl east yesratday or two
event.getInventory() == gui
So this should all work then?
or perhaps event.getView().getTopInventory()
Should I post a pastebin to all my code?
What then?
That code is kinda meh
What's wrong with it?
well use this check:
if (event.getView().getTopInventory() == gui) {
event.setCancelled(true);
}```
I can tell u tmrw, too tired rn
welp
But it doesn't cancel it
wth dude
Oh
am i sending email to right email? tmp-support@spigotmc.org
why do you have 2 methods with the same name
if (event.getInventory() == gui) {
// Cancel the event so the player doesn't actually take the item
event.setCancelled(true);
}
I just followed a tutorial
I renamed the last one
also, are you registering the eventhandlers?
Nothing wrong with overloaded methods
Method names should be discriptive and not missleading. onInventoryClick(InventoryDragEvent e) is kinda meh
Ah I thought you meant addItem
How's your main looking?
@Override
public void onEnable() {
// Register commands
this.getCommand("shop").setExecutor(new Shop(this));
}```
@subtle blade sorry for the ping but is this current email tmp-support (at) spigotmc.org
I don't know how to register it with parameters
//onEnable
getServer().getPluginManager().registerEvents(new GUI(), this);
But GUI() takes 2 parameters
How so?
You should follow srp
What?
Single Responsibility Principle
😦
Sentaku well, be patient
sorry
Felix
I'd send all classes
so we can get a look on what you're really trying to do
Anyone elses bungee plugins get absolutely kneecapped by the latest updates? lol
Namely;
- Add the MessageRaw channel
- Add support for contents in Hover Event
Broke so much of my Bungee plugins it's not even funny
Okay start with making a class called Gui
Done
then add a private final Inventory field
and then add a constructor with a String parameter and int parameter
Let me type this perhaps
public GUI(String name, int size) {
}```
now in that one
declare the inv field to be Bukkit.createInventory(null, Utils.color(name), size);
If you don't have a Utils class make one
and add this method
public class Utils {
public static String color(String str) {
return ChatColor.translateAlternateColorCodes('&', str):
}
}```
Essentially this is just a shortcut method
Calling Utils.color(String)
would give us a string but it would transform all valid colorcodes like &6 to color
well in your Gui class
@worn fiber you there?
um how do I get spigot
I have eclipse
and idk how to like get spigot to start doing stuff for mc
ty
Why?
What does it do?
I know it makes it constant
But what does it do for a class?
wrong
Oh
It doesn't make it constant
It makes it un-extendable
well okay did you make that with the color method?
Yes.
now back to Gui class
we have a private final Inventory field
well did you add this?
private final Inventory inv;
public Gui(String title, int size) {
inv = Bukkit.createInventory(null, Utils.color(title), size);
}```
now add a boolean method with a Inventory parameter
and make it return inventory == parameter
like this
public boolean compareTo(Inventory inv) {
return this.inv = inv;
}``` taking it as the private final Inventory field is named inv as well
You could also add a getter method
I named my private final field gui
public boolean compareTo(Inventory inv) {
return this.gui == inv;
}```
What's wrong with directly accessing this.gui?
I mean essentially gui is final so we can't re assign it but it's generally better to encapsulate objects as it's oop principles and it's more maitainable
let's say another plugin uses that class and uses the variable by calling it directly
if you now would change name of that variable, their class would break also
Got it
a getter would prevent it
Just a simple public Inventory getGUI() { return this.gui; }?
yeah
Also this plugin is gonna be private too
yeah but it's not a bad practice
hi
that's the thing
?
Multimap?
ye
What do I use getGUI() for then?
Can store more values against a single key
Something later?
yes outside the class
?
Fency
ok I'm trying to use the buildtool thing, I put in the command, and it says I don't have the right amount of storage, but I have 1.4 terabytes on my computer
Okay, all done.
Fenzy for instance Multimap<String, Integer> can store both 1 and 3 for a single String
yes but how do i use it??
Multimaps.newMultimap I think
hello?
Crazy what's your used storage maybe it's full
Felix create an ItemBuilder class
We'll use that to easier construct items
Can I copy the one I had before?
protected ItemStack createItem(Material itemType, String name, String lore, int quantity) {
ItemStack item = new ItemStack(itemType, quantity);
ItemMeta meta = item.getItemMeta();
// Set the meta name and lore
meta.setDisplayName(name);
meta.setLore(Arrays.asList(lore));
// Apply the meta to the item
item.setItemMeta(meta);
return item;
}```
Oh ok
Make this
ok guys what do I do
🤷
public final class ItemBuilder implements Supplier<ItemStack> {
private final Material material;
private int count;
private List<Consumer<ItemMeta>> meta;
public ItemBuilder(Material material) {
this.material = material;
this.count = 1;
this.meta = new LinkedList<>();
}
public ItemBuilder setCount(int count) {
this.count = count;
return this;
}
private ItemBuilder withMeta(Consumer<ItemMeta> meta) {
meta.add(meta);
return this;
}
public ItemBuilder setName(String name) {
return withMeta(meta -> meta.setDisplayName(Utils.color(name)));
}
public ItemBuilder setLore(String lore, String... lores) {
return withMeta(meta -> meta.setLore(Lists.asList(lore, lores).stream().map(Utils::color).collect(Collectors.toList());
}
@Override
public ItemStack get() {
ItemStack itemStack = new ItemStack(material, count);
ItemMeta itemMeta = item.getItemMeta();
meta.forEach(consumer -> consumer.accept(itemMeta));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}```
that took some time sry
but now what you can do is something like this:
inv.addItem(new ItemBuilder(Material.DIRT).setName("Test").get());
.setLore() .setName() .setCount() is all optional
What was wrong with mybuilder?
It worked though
¯_(ツ)_/¯
And I understood what it did 👀
Okay well
I can make a simpler one
but the idea is to have one class for building items
oh dear
What is String...?
yeah
Just waiting on review

