This repository has been archived by the owner on Oct 15, 2023. It is now read-only.
Code Snippets #12
nicokempe
announced in
Entwicklung
Replies: 3 comments
-
Installation unter MavenFüge das zu deiner pom.xml hinzu: <repository>
<id>verany</id>
<url>https://verany.net/repo/repository/maven-public/</url>
</repository> Und füg dann die Dependency hinzu: <dependency>
<groupId>net.verany.core</groupId>
<artifactId>core-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> |
Beta Was this translation helpful? Give feedback.
0 replies
-
Main Beispiel von @tylix: package net.verany.api.example.normal;
import net.verany.api.Verany;
import net.verany.api.example.normal.commands.ExampleCommand;
import net.verany.api.example.normal.listener.PlayerJoinListener;
import net.verany.api.example.normal.listener.PlayerQuitListener;
import net.verany.api.module.VeranyModule;
import net.verany.api.module.VeranyProject;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
@VeranyModule(name = "Example", prefix = "ExamplePrefix", version = "2021.6.1", authors = {"NicoVRNY"})
public class ExamplePlugin extends VeranyProject {
public static ExamplePlugin INSTANCE;
public ExamplePlugin() {
INSTANCE = this;
}
@Override
public void onEnable() {
Verany.loadModule(this);
init();
}
@Override
public void init() {
initCommands();
initListener();
}
private void initCommands() {
new ExampleCommand(this);
}
private void initListener() {
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new PlayerJoinListener(), this);
pluginManager.registerEvents(new PlayerQuitListener(), this);
}
@Override
public void onDisable() {
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Inventar Beispiel von @tylix (Aktualisierende Uhr im Inventar) package net.verany.api.example.normal.inventory;
import net.verany.api.example.normal.ExamplePlugin;
import net.verany.api.inventory.InventoryBuilder;
import net.verany.api.itembuilder.ItemBuilder;
import net.verany.api.message.KeyBuilder;
import net.verany.api.placeholder.Placeholder;
import net.verany.api.player.IPlayerInfo;
import net.verany.api.skull.SkullBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.text.SimpleDateFormat;
public class ExampleInventory {
private final Inventory inventory;
private BukkitTask task;
public ExampleInventory(IPlayerInfo playerInfo) {
Player player = playerInfo.getPlayer();
this.inventory = InventoryBuilder.builder().
title(playerInfo.getKey("inventory.title", new Placeholder("%name%", player.getName()))).
size(9 * 3).
onClick(event ->
{
KeyBuilder timeKey = KeyBuilder.builder().
key("current.time").
placeholders(new Placeholder[]
{
new Placeholder("%time%", getTime())
}
).
prefix(playerInfo.getPrefix("CurrentTime")).
build();
playerInfo.sendKey(timeKey);
}
).
onClose(event ->
task.cancel()
).
build().
fillInventory(new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE).setNoName().build()).
createAndOpen(player);
inventory.setItem(4, new SkullBuilder(playerInfo.getSkinData()).setDisplayName(playerInfo.getNameWithColor()).build());
startTask();
}
public void setItems() {
inventory.setItem(13,
new ItemBuilder(Material.CLOCK).
setDisplayName("Uhrzeit").
addLoreArray(
"§7Es ist §b" + getTime() + " §7Uhr"
).
build()
);
}
private void startTask() {
task = new BukkitRunnable() {
@Override
public void run() {
setItems();
}
}.runTaskTimer(ExamplePlugin.INSTANCE, 0, 20);
}
private String getTime() {
return new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis());
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Code Snippets
Hier können sich neue Entwickler durch Snippets arbeiten um die Funktionen der Core schneller zu verstehen.
Beta Was this translation helpful? Give feedback.
All reactions