Skip to content

Instantly share code, notes, and snippets.

View Yuhtin's full-sized avatar
:octocat:
Focusing

Davi Duarte Yuhtin

:octocat:
Focusing
View GitHub Profile
@Yuhtin
Yuhtin / ItemBuilder.java
Last active January 11, 2022 20:41
Parse ConfigurationSection as ItemStack
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
@Yuhtin
Yuhtin / DnsResolver.js
Last active January 25, 2021 19:53
Resolve DNS
const dns = require('dns');
const axios = require('axios');
const api = axios.create({ baseURL: 'http://ip-api.com' });
const dnsIp = 'netflix.com',
resetColor = '',
bold = '',
backgroundColor = '',
pinkColor = '',
cyanColor = '',
prefix = resetColor + '[' + cyanColor + '+' + resetColor + '] ' + cyanColor + bold + backgroundColor;
@Yuhtin
Yuhtin / CaseInsensitiveExample.java
Last active April 5, 2021 18:44
Case insensitive string as HashMap key
/**
* @author Yuhtin
* Github: https://github.com/Yuhtin
*/
public class CaseInsensitiveExample {
static final CaseInsensitiveLinkedMap<Character> CHARACTER_MAP = CaseInsensitiveLinkedMap.newMap();
public static void main(String[] args) {
@Yuhtin
Yuhtin / TextUtils.java
Created April 18, 2021 14:13
TextComponent with item (Reflection)
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Method;
import java.util.logging.Level;
@Yuhtin
Yuhtin / conversorProcessor.dart
Created May 31, 2021 00:47
Calculator from Real (BRL) to Euro (EUR) using API
class Conversor {
double value;
double price;
Conversor(double value, double price) {
this.value = value;
this.price = price;
}
double convert() {
@Yuhtin
Yuhtin / home.dart
Created May 31, 2021 01:40
Jokenpo system
import 'package:flutter/material.dart';
import 'jokenpo.dart';
import 'jokenpoTypes.dart';
class Homepage extends StatefulWidget {
Homepage({Key key, title: 'Home'}) : super(key: key);
@override
_HomepageState createState() => _HomepageState();
}
@Yuhtin
Yuhtin / MaterialUtils.java
Last active July 26, 2021 18:08
Support materials from 1.8 to 1.17 with data (colors)
public final class MaterialUtils {
public static ItemStack convertFromLegacy(String materialName, int damage) {
try {
return new ItemStack(Material.getMaterial(materialName), 1, (short) damage);
} catch (Exception error) {
Material material = Material.valueOf("LEGACY_" + materialName);
return new ItemStack(Bukkit.getUnsafe().fromLegacy(new MaterialData(material, (byte) damage)));
}
@Yuhtin
Yuhtin / bukkit.yml
Last active October 13, 2021 14:46
[1.8.x] Otimize server by configuring spigot, paper, sportpaper & bukkit.yml
# This is the main configuration file for Bukkit.
# As you can see, there's actually not that much to configure without any plugins.
# For a reference for any variable inside this file, check out the Bukkit Wiki at
# http://wiki.bukkit.org/Bukkit.yml
#
# If you need help on this file, feel free to join us on irc or leave a message
# on the forums asking for advice.
#
# IRC: #spigot @ irc.spi.gt
# (If this means nothing to you, just go to http://www.spigotmc.org/pages/irc/ )
@Yuhtin
Yuhtin / ChunkGrid.Java
Created March 3, 2022 17:14
Get chunk grid based on a central chunk/location
public Collection<Chunk> getNearbyChunksGrid(Location location) {
val offset = new int[]{-1, 0, 1};
val world = location.getWorld();
val baseX = location.getChunk().getX();
val baseZ = location.getChunk().getZ();
val chunksAroundPlayer = new HashSet<Chunk>();
for (val x : offset) {
for (val z : offset) {
@Yuhtin
Yuhtin / Products.java
Last active July 22, 2022 02:26
Calculate products prices
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of products:");
int products = scanner.nextInt();
List<Product> productsList = new ArrayList<>();
for (int i = 1; i <= products; i++) {
System.out.println("Insert Product #" + i + " code:");
int code = scanner.nextInt();