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 / verify-numbers.py
Created April 19, 2024 18:07
Print sorted and unduplicated numbers with variable range
def requestNumbers():
str = input('Digite os números iniciais: ')
splitted = str.split(' ')
number1 = float(splitted[0])
number2 = float(splitted[1])
return [ number1, number2 ]
def preencher():
@Yuhtin
Yuhtin / compress.js
Created October 22, 2023 00:11
Compress projects recursively respecting .gitignore
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
const tarPath = 'C:\\Windows\\System32\\tar.exe';
const scriptDir = process.cwd();
const sourceDir = scriptDir;
const destDir = path.join(scriptDir, 'compressed');
if (!fs.existsSync(destDir)) {
@Yuhtin
Yuhtin / ConfigLoader.java
Last active February 20, 2023 18:33
Load every class from config using fieldnames
/**
* @author <a href="https://github.com/Yuhtin">Yuhtin</a>
*/
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.ArrayList;
@Yuhtin
Yuhtin / Hitbox.java
Last active September 17, 2022 00:52
Check if location is inside a Player hitbox
@Getter
@AllArgsConstructor
public class Hitbox {
private final Location aa, ab;
public Hitbox(Player player) {
this.aa = player.getLocation().subtract(0.4, 0, 0.4);
this.ab = player.getLocation().add(0.4, 1.8, 0.4);
}
@Yuhtin
Yuhtin / Employee.java
Created September 1, 2022 23:52
Employee Salary System
public class Employee {
private final int id;
private final String name;
private double salary;
public Employee(int id, String name, double salary) {
this.id = id;
this.name = name;
this.salary = salary;
@Yuhtin
Yuhtin / CircleQuadrant.java
Created July 22, 2022 06:27
Get four circle quadrant
static HashMap<String, String> QUADRANTS = new HashMap<String, String>(){{
put("1,1", "Q1");
put("-1,1", "Q2");
put("-1,-1", "Q3");
put("1,-1", "Q4");
}};
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
@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();
@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 / 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 / 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)));
}