Polymart is now Voxel Shop! We're upgrading many features of the site, and during this open beta you will experience occasional bugs. Learn more  
VCore icon

VCore 1.0.6

This project is mainly intended to be a helpful tool for developing our own projects.

VCore

For many projects, instead of adding these auxiliary elements one by one, just
You can access all these features by adding a maven code.

This project is mainly intended to be a helpful tool for developing our own projects.

Features
Armor wearing events
Customizing the world border
Custom commandsystem
Custom config file system
Inventory creation system
Create particle effects
Hologram creation
Send text to the screen or action bar
Adding nbt tags to items

Installation


<repository>
  <id>mineala-repo</id>
  <url>https://repo.mineala.com/repository</url>
</repository>


<dependency>
  <groupId>net.kayega</groupId>
  <artifactId>vcore</artifactId>
  <version>VERSION</version>
</dependecy>



Usage/Examples

Creating commands



@VCommandArguments(
commandName = "test", <- required
isPlayerCommand = true, <- optional
permission = "testperm", <- optional
hasSubCommand = false <- required if have a sub command
)
public class ExampleCommand extends VCommand {
public void run(Player player, String[] args) {

}

public List tabComplete(CommandSender player, String[] args) {
return null;
}
}

Creating subcommands



@VSubCommandArguments(
commandName = "test", <- required
commandDescription = "Test command", <- optional
commandPermission = "testperm" <- required
)
public class TestKomut extends VSubCommand {
public void run(Player player, String[] args) {

}

public List tabComplete(CommandSender player, String[] args) {
return null;
}
}

Extra Functions in the VCommand Class



/* Given string list and initialization
Starting from the starting index by taking the * index
* returns all string values as a single string
*/
getFinalArgs(args, start)

/*
* Names of all players on the server
* returns as a list
*/
getPlayerNicknames()

/*
* Starting with the given value on the server
* returns the names of players as a list
*/
getPlayerNicknames(startsWith)

/*
* Used to define the given command to the server
*/
registerCommand(plugin, command)

/*
* Used to define the given command to the server
* + set "withTabCompleter" to use Tab completion
* make it "true".
*/
registerCommand(plugin, command, withTabCompleter)


Creating Config Files



@VConfigArguments(
configFileName = "config", <- don't write .yml at the end
)
public class TestConfig extends VConfig {
public TestConfig(JavaPlugin plugin) {
super(plugin);
}
}

Then you can make the following call in your main class.



@Override
public void onEnable() {
TestConfig config = new TestConfig(this);
// config.getConfig()
// config.getConfig().addDefault("test", "test")
// config.saveConfig()
// config.getConfig().get("test")
// config.reloadConfig()
}


Creating Inventory UI



public class ExampleInventory extends FastInv {

private boolean preventClose = false;

public ExampleInventory() {
super(45, ChatColor.GOLD + "Example inventory");

// Just add a random item
setItem(22, new ItemStack(Material.IRON_SWORD), e -> e.getWhoClicked().sendMessage("You clicked on the sword"));

// Add some blocks to the borders
setItems(getBorders(), new ItemBuilder(Material.LAPIS_BLOCK).name(" ").build());

// Add a simple item to prevent closing the inventory
setItem(34, new ItemBuilder(Material.BARRIER).name(ChatColor.RED + "Prevent close").build(), e -> {
this.preventClose = !this.preventClose;
});

// Prevent from closing when preventClose is to true
setCloseFilter(p -> this.preventClose);
}

@Override
public void onOpen(InventoryOpenEvent event) {
event.getPlayer().sendMessage(ChatColor.GOLD + "You opened the inventory");
}

@Override
public void onClose(InventoryCloseEvent event) {
event.getPlayer().sendMessage(ChatColor.GOLD + "You closed the inventory");
}

@Override
public void onClick(InventoryClickEvent event) {
// do something
}
}

Now you can open the inventory:



new TestEnvanter().open(player);

Getting VInv instance?



if (inventory.getHolder() instanceof VInv) {
VInv fastInv = (VInv) inventory.getHolder();
}


Creating Particles



// Get a ParticleType
VParticleType flame = VParticleType.of("FLAME");
VParticleType redstone = VParticleType.of("REDSTONE");
VParticleType blockCrack = VParticleType.of("BLOCK_CRACK");

// Spawn particle for a player
flame.spawn(player, loc, 1);

// Spawn particle for all players in a world
flame.spawn(world, loc, 1);

// Spawn colored particle to a player
redstone.spawn(player, loc, 1, VParticleData.createDustOptions(Color.BLUE, 1));

// Spawn block crack particle to a player
blockCrack.spawn(player, loc, 1, VParticleData.createBlockData(Material.DIAMOND));

When you need to spawn a large amount of particles, you can cache instances of "ParticleType" and "ParticleData" to slightly improve performances.

Creating Holograms



// Type location and lines
VHologram hologram = new VHologram(loc, lines);

// Spawning hologram
hologram.spawn();

// Despawning hologram
hologram.remove();


Creating Text on Screen or ActionBar



// Creating text on screen
// fadeIn, stay and fadeOut for 20 = 1 second, 10 = 0.5 second
VTitle.sendTitle(player, title, subTitle, fadeIn, stay, fadeOut);
// Creating text on ActionBar
VTitle.sendActionbar(player, text)


Creating NBT Tags



VNbt nbt = new VNbt(item, key);
nbt.add(type, value); // Adding value
nbt.has(type); // Check whether there is any value
nbt.get(type); // Reading value
nbt.getItemContainer();
nbt.getKey()
;


Creating Database


public class UserData {
    private final UUID uuid;
    private int credits;
    private int level;


    public UserData(UUID uuid, int credits, int level) {
        this.uuid = uuid;
        this.credits = credits;
        this.level = level;
    }
    // Getters and Setters
    public UUID getUuid() { return uuid; }
    public int getCredits() { return credits; }
    public int getLevel() { return level; }
}


public class DatabaseManager {
    private final DatabaseFactory factory;
    private final DatabaseTable<UserData> userTable;


    public DatabaseManager(JavaPlugin plugin) {
        // 1. Ayarları hazırla (Config'den çekilebilir)
        Map<String, Object> dbConfig = new HashMap<>();
        dbConfig.put("host", "localhost");
        dbConfig.put("port", 3306);
        dbConfig.put("db", "minecraft_db");
        dbConfig.put("user", "root");
        dbConfig.put("pass", "password");


        // 2. Factory'yi başlat (MySQL seçtik)
        this.factory = new DatabaseFactory(DatabaseType.MYSQL, dbConfig, plugin.getDataFolder());


        // 3. Tabloyu oluştur
        this.userTable = factory.createTable("player_data");
        userTable.addColumn("uuid", "VARCHAR(36)", true, false)
                 .addColumn("credits", "INT", false, false)
                 .addColumn("level", "INT", false, false);


        // 4. Mapper'ları ayarla (Java Nesnesi <-> SQL)
        userTable.setMappers(
            (ps, data) -> { // SAVE
                try {
                    ps.setString(1, data.getUuid().toString());
                    ps.setInt(2, data.getCredits());
                    ps.setInt(3, data.getLevel());
                } catch (SQLException e) { e.printStackTrace(); }
            },
            rs -> { // LOAD
                try {
                    return new UserData(
                        UUID.fromString(rs.getString("uuid")),
                        rs.getInt("credits"),
                        rs.getInt("level")
                    );
                } catch (SQLException e) { return null; }
            }
        );


        userTable.createTable();
    }


    public DatabaseTable<UserData> getUserTable() { return userTable; }
    public DatabaseFactory getFactory() { return factory; }
}

Examples


@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();


    // Veriyi ASENKRON çekiyoruz (Sunucu donmaz)
    databaseManager.getUserTable().loadAsync("uuid", player.getUniqueId().toString(), null, false, 1, 1)
        .thenAccept(results -> {
            UserData data;
            if (results.isEmpty()) {
                data = new UserData(player.getUniqueId(), 0, 1);
                databaseManager.getUserTable().saveAsync(data);
            } else {
                data = results.get(0);
            }


            // DİKKAT: Minecraft API'sine (mesaj, ışınlanma vb.) dönmek için senkron thread'e geçmeliyiz!
            Bukkit.getScheduler().runTask(plugin, () -> {
                player.sendMessage("§aVerilerin yüklendi! Kredi: " + data.getCredits());
            });
        });
}
-
public void showLeaderboard(Player player) {
    // Krediye göre DESC (büyükten küçüme) sırala, ilk 10'u getir
    databaseManager.getUserTable().loadAsync(null, null, "credits", false, 10, 1)
        .thenAccept(topList -> {
            Bukkit.getScheduler().runTask(plugin, () -> {
                player.sendMessage("§e--- EN ZENGİN 10 OYUNCU ---");
                int rank = 1;
                for (UserData data : topList) {
                    player.sendMessage("§7" + rank + ". §f" + data.getUuid() + " §8- §6" + data.getCredits());
                    rank++;
                }
            });
        });
}


Owned
Ready to download
This resource is already attached to your account. You can download the latest file any time.