Skip to content

Instantly share code, notes, and snippets.

View Magnum97's full-sized avatar

Richard Simpson Magnum97

  • Redding, CA USA
View GitHub Profile
import lombok.experimental.UtilityClass;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
@Magnum97
Magnum97 / Messages.java
Last active May 6, 2021 06:28
Bukkit / Spigot message sender with placeholder and prefix ability
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.google.common.collect.Maps;
import de.leonhard.storage.Toml;
import org.apache.commons.lang.text.StrSubstitutor;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import java.util.Map;
@Magnum97
Magnum97 / CacheManager.java
Last active May 28, 2021 05:23
Auto expire object cache
import java.util.HashMap;
import java.util.Set;
public class CacheManager {
/* This is the HashMap that contains all objects in the cache. */
private static HashMap cacheHashMap = new HashMap();
@Magnum97
Magnum97 / FetchUUID.java
Created March 27, 2021 05:11
Minecraft UUID fetcher
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import java.util.Optional;
import java.util.UUID;
public class FetchUUID {
public FetchUUID() {
@Magnum97
Magnum97 / gist:f181001cfe8e78dbd84b55e4bd59c52d
Created June 6, 2020 08:08 — forked from danielestevez/gist:2044589
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@Magnum97
Magnum97 / gist:b8b93c287e57f156fb53f8dc84637dec
Created June 6, 2020 08:06 — forked from danielestevez/gist:1391076
GIT Configurations: Alias to Push/Pull automatically on working branch, nice git log format #git
#include this in your .gitconfigure to perform a pull/push origin on the branch you are currently working
# avoids mistakes performing 'pull origin master' when you are in stable and so on
#
[alias]
# Pushes/pulls to/from remote branch with corresponding name
pl = !git pull origin $(git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,')
ps = !git push origin $(git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,')
@Magnum97
Magnum97 / YamlHelper.java
Created May 9, 2020 07:12
Convert String array to List and frame it
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
@NoArgsConstructor
public class YamlHelper {
private String[] header;
/* Copyright (C) dumptruckman 2014
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
@Magnum97
Magnum97 / AFKPoolListener.java
Created May 1, 2020 05:02 — forked from dumptruckman/AFKPoolListener.java
Punishes players who stand in liquid for too long.
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
@Magnum97
Magnum97 / DebugLogHandler.java
Created May 1, 2020 04:23 — forked from dumptruckman/DebugLogHandler.java
A simple option for enabling debug logging in your Bukkit plugin,
/**
* Copyright 2019 dumptruckman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.