Skip to content

Instantly share code, notes, and snippets.

View hamza-cskn's full-sized avatar
🎯
Focusing

Hamza Coşkun hamza-cskn

🎯
Focusing
  • Türkiye/Kocaeli
  • 13:26 (UTC +03:00)
View GitHub Profile
@hamza-cskn
hamza-cskn / ItemBuilder
Last active July 31, 2021 16:11
My Simple ItemBuilder
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@hamza-cskn
hamza-cskn / Convert location list to cuboid
Created September 26, 2021 08:49
Creates a cuboid that is includes all locations of a locations list.
//to get main cuboid class: https://www.spigotmc.org/threads/region-cuboid.329859/
public static Cuboid convertCuboid(final List<Location> locations) {
int firstPosX = Integer.MIN_VALUE;
int firstPosY = Integer.MIN_VALUE;
int firstPosZ = Integer.MIN_VALUE;
int secondPosX = Integer.MAX_VALUE;
int secondPosY = Integer.MAX_VALUE;
package mc.obliviate.masterduels.utils.placeholder;
public class InternalPlaceholder {
private final String placeholder;
private final String value;
protected InternalPlaceholder(final String placeholder, final String value) {
this.placeholder = placeholder;
this.value = value;
@hamza-cskn
hamza-cskn / Invite.java
Last active June 17, 2022 09:12
Useful invite code that provides players invites others.
package mc.obliviate.test.textapi;
import com.google.common.base.Preconditions;
import mc.obliviate.test.Test;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.UUID;
import java.util.function.Consumer;
@hamza-cskn
hamza-cskn / MessageUtils
Last active June 26, 2022 14:01
MessageUtils for plugin configs.
package mc.obliviate.masterduels.utils;
import mc.obliviate.masterduels.utils.placeholder.InternalPlaceholder;
import mc.obliviate.masterduels.utils.placeholder.PlaceholderUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@hamza-cskn
hamza-cskn / ChainExecutor.java
Last active December 5, 2022 22:27
Simple Task Chain for Bukkit
import org.bukkit.Bukkit;
import java.util.function.Function;
public class ChainExecutor {
private ChainTask first;
private static Function<ChainTask, Boolean> toBooleanFunction(Runnable runnable) {
return chain -> {
@hamza-cskn
hamza-cskn / TimeFormatUtil.java
Created December 25, 2022 10:27
Formats durations to relative times
public static Duration getRelativeDuration(Date date) {
return Duration.ofMillis(Objects.requireNonNull(date).toInstant().toEpochMilli() - System.currentTimeMillis());
}
public static String formatRelativeDuration(Duration duration, boolean verbose) {
if (duration.isZero()) return "now";
String direction = duration.isNegative() ? "ago" : "later";
duration = duration.abs();
StringBuilder builder = new StringBuilder();
if (!applyTimeFormat(builder, duration.toDaysPart(), "day") || verbose)
@hamza-cskn
hamza-cskn / ChatEntry.java
Created January 22, 2023 10:31
Provides taking text input from players using chat. Extremely lightweight.
public final class ChatEntry implements Listener {
private static final Map<UUID, ChatEntry> entryMap = new HashMap<>();
public Consumer<AsyncPlayerChatEvent> action;
public ChatEntry(UUID uuid) {
entryMap.put(uuid, this);
Bukkit.getPluginManager().registerEvents(this, SeniorRegions.getInstance());
}
@hamza-cskn
hamza-cskn / itoa.c
Last active February 12, 2023 21:25
converts integers to string.
int power(int n, int pow) {
int res = n;
if (pow == 0) return 1;
while (--pow > 0) res *= n;
return res;
}
// increases 'pow' until find the smallest power of 10
// which is bigger than the number. and its gives the digit count.
int count_digits(int nbr) {
@hamza-cskn
hamza-cskn / ft_split.c
Created February 19, 2023 07:15
split exercise for école thirty four
#include <stdlib.h>
#include <printf.h>
int is_seperator(char c) {
return (c == '\0' || c == ' ' || c == '\n');
}
int word_length(char *str) {
int i;