Skip to content

Instantly share code, notes, and snippets.

View Spotlightsrule's full-sized avatar

Spotlightsrule Spotlightsrule

  • Spotrealms Network
View GitHub Profile
@KoalaOnCaffeine
KoalaOnCaffeine / DependencyInjection.java
Last active April 30, 2025 01:11
Constructor dependency injection
public final class CustomCommandPlugin extends JavaPlugin {
@Override
public final void onEnable() {
getCommand("command").setExecutor(new CommandClass(getConfig().getString("Hello-Message")));
// creating a new instance of the command class, passing in the hello message parameter as the String from the command class' constructor.
// getCommand being an inherited method from JavaPlugin.
// setExecutor being a method which every PluginCommand has, defining where it will run to.
// new CommandClass being the constructor of the class below.
// getConfig().getString("Hello-Message"); being a String located in the config, if this string is not there:
@Exerosis
Exerosis / Events.java
Last active January 15, 2024 06:37
A simpler and faster system for registering Bukkit event listeners in Java, Kotlin or Scala.
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.EventExecutor;
import java.util.function.Consumer;
public interface Events extends Listener, EventExecutor {
package com.gitlab.avelyn.core.utilities;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@EronWright
EronWright / README.md
Last active June 24, 2024 13:34
Simple Maven repository hosted on Apache httpd web server

Simple Maven Repository

Hosting a shared Maven repository on a remote server may be accomplished with a simple web server such as Apache HTTP server. This works because most of the resolution and publishing logic of Maven is implemented in the client. That said, it works only if you know the groupId and artifactId to be published, since appropriate directories must be created by hand.

Do consider using more sophisticated server software such as Artifactory or Sonatype Nexus. Below is the 'bare minimum' alternative.

Caution: this example exposes a writable directory without any authentication, and thus assumes a trusted network.

@derlin
derlin / Polynomial.java
Created November 29, 2016 09:13
a polynomial class for java implementing the basic operations +, -, /, *, compose and integrate.
// see http://introcs.cs.princeton.edu/java/92symbolic/Polynomial.java.html
public class Polynomial{
private int[] coef; // coefficients
private int deg; // degree of polynomial (0 for the zero polynomial)
// a * x^b
public Polynomial( int a, int b ){
coef = new int[ b + 1 ];
@stereokai
stereokai / gist:36dc0095b9d24ce93b045e2ddc60d7a0
Last active July 12, 2025 23:08
CSS rounded corners with gradient border
.rounded-corners-gradient-borders {
width: 300px;
height: 80px;
border: double 4px transparent;
border-radius: 80px;
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
background-origin: border-box;
background-clip: padding-box, border-box;
}
@uklimaschewski
uklimaschewski / UnescapeJavaString
Created September 28, 2013 12:50
Unescapes a string that contains standard Java escape sequences: - \b \f \n \r \t \" \' : BS, FF, NL, CR, TAB, single and double quote - \X \XX \XXX : Octal character from 0 to 377 (that is in Hex: 0x00 to 0xFF) - \uXXXX : Hexadecimal based Unicode character
/**
* Unescapes a string that contains standard Java escape sequences.
* <ul>
* <li><strong>&#92;b &#92;f &#92;n &#92;r &#92;t &#92;" &#92;'</strong> :
* BS, FF, NL, CR, TAB, double and single quote.</li>
* <li><strong>&#92;X &#92;XX &#92;XXX</strong> : Octal character
* specification (0 - 377, 0x00 - 0xFF).</li>
* <li><strong>&#92;uXXXX</strong> : Hexadecimal based Unicode character.</li>
* </ul>