Skip to content

Instantly share code, notes, and snippets.

View sahirshahryar's full-sized avatar

Sahir Shahryar sahirshahryar

View GitHub Profile
@sahirshahryar
sahirshahryar / message.json
Created June 10, 2015 22:08
Really, Mojang?
"NOTE: This was written using an automated parser. Optimizations can obviously be made."
/tellraw @p
{
"text": "[",
"color": "dark_gray",
"extra": [
{
"text": "6/3 ",
"color": "red",
@sahirshahryar
sahirshahryar / Facepalm.java
Last active December 31, 2015 02:49
The epitome of awesome code.
package com.futuredev.facepalm;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
/**
* My masterpiece, a true work of genius.
* Composed 2012.
@sahirshahryar
sahirshahryar / CompactRomanNumeral.java
Last active March 31, 2023 04:12
Roman numeral conversion
public static String romanNumerals (int value) {
String[] values = {
"M", "CM", "D", "CD", "C", "XC",
"L", "XL", "X", "IX", "V", "IV", "I"
};
int[] correspondents = {
1000, 900, 500, 400, 100, 90,
50, 40, 10, 9, 5, 4, 1
}
import java.util.ArrayList;
// Changes a long into a human-readable format.
public class DateComparison {
int weeks, days, hours, minutes, seconds;
long time;
public DateComparison (long earlier, long later) {
this (later > earlier ? (later - earlier) : (earlier - later));
package com.icloud.dcljr.MineCloudHardMode;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@sahirshahryar
sahirshahryar / CainKilgore.java
Last active December 19, 2015 12:49
afistofirony's examples
// Ignore imports for our purposes
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable () {
saveDefaultConfig();
List<String> aliases = getConfig().getStringList("path.to.list");
getCommand("test").setAliases(aliases);
}
@sahirshahryar
sahirshahryar / TargetLexer.java
Last active December 19, 2015 10:29
Evaluates stuff.
// A revamped version of the BooleanLogic class, with recursive parenthetical support.
package org.futuredev.tracker.util.lexers.params;
import org.futuredev.tracker.Tracker;
import org.futuredev.tracker.session.user.PlayerSession;
import org.futuredev.tracker.session.user.Session;
import org.futuredev.tracker.util.cmd.CommandProcessing;
import org.futuredev.tracker.util.enums.Permissions;
import org.futuredev.tracker.util.ex.CommandException;
@sahirshahryar
sahirshahryar / StringMath.java
Created June 14, 2013 11:18
String math. We already have algebra (math with letters), so why not just math with words? NOTE: Untested, will test later.
package com.futuredev.tracker.msg;
import java.util.ArrayList;
public class StringMath {
// "Multiplies" a string.
public static String multiply (String start, int times, String separator) {
String result = "";
boolean first = true;
@sahirshahryar
sahirshahryar / MessageAssist.java
Created June 13, 2013 02:44
Assists in loading messages for your plugin. Inspired by ProjectInfinity's version for ReportRTS, but made to be instantiated.
package com.futuredev.tracker.util.msg;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.InputStream;
import java.text.MessageFormat;