This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A custom ThreadPoolTaskExecutor based on this SO answer https://stackoverflow.com/a/24493856. | |
* | |
* The main distinction of this executor is that it will not wait for the queue to be full before scaling up the number | |
* of threads in the pool. Instead, it will scale up the number of threads in the pool (up to the maximum) as soon as | |
* a new task is submitted and no idle threads are available to run it. Then, once the number of threads reaches the | |
* maximum, it will start to queue tasks. | |
*/ | |
class ImmediatelyScalingThreadPoolTaskExecutor : ThreadPoolTaskExecutor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any | |
def snake_to_camel(name): | |
components = name.split('_') | |
return components[0] + ''.join(x.title() for x in components[1:]) | |
def snake_case_attrs(klass): | |
"""A class decorator that enables getting and setting of attributes with lowerCamelCase names using snake_case.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SpawnLocationSharable { | |
public static final Sharable<Location> SPAWN_LOCATION = new Sharable.Builder<Location>("spawn_location", Location.class, | |
new SharableHandler<Location>() { | |
@Override | |
public void updateProfile(PlayerProfile profile, Player player) { | |
profile.set(SPAWN_LOCATION, getPlayerSpawnLocation(player)); | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.bukkit.Bukkit; | |
import org.bukkit.Location; | |
import org.bukkit.World; | |
import org.bukkit.block.Block; | |
import org.bukkit.configuration.serialization.ConfigurationSerializable; | |
import org.bukkit.configuration.serialization.SerializableAs; | |
import org.jetbrains.annotations.NotNull; | |
import org.jetbrains.annotations.Nullable; | |
import java.util.LinkedHashMap; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.string :as s]) | |
(use 'clojure.zip) | |
(defn vectorize-program [code] | |
(let [t #(read-string (.substring % 1))] | |
(mapv #(mapv (juxt first t) (into [] (re-seq #"\w-?\d+" %))) | |
(s/split-lines code)))) | |
(defn prep-code [code] | |
(down (vector-zip (vectorize-program code)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dumptruckman.a0a0 | |
import java.util.LinkedList | |
import java.util.Scanner | |
fun main(args: Array<String>) { | |
// Example usage with cat program | |
Interpreter.interpret("A0 A0\n" + | |
"A0 C3 G1 G1 A0\n" + | |
"A0 I0 V0 P0 A0\n" + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmd.set.unknown_prop=''{0}'' is not a valid chest property! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You need this to create an "uberjar" | |
plugins { | |
id "com.github.johnrengelman.shadow" version "2.0.2" | |
} | |
apply plugin: 'java' | |
apply plugin: 'com.github.johnrengelman.shadow' // also needed for "uberjar" | |
group 'xyz.yourdomain' | |
version '0.0.1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.annotation.Nullable; | |
import java.time.LocalDateTime; | |
import java.time.temporal.ChronoUnit; | |
public class DelayedTaskManager implements Runnable { | |
private static final long PRECISION_CHECK_TIME_MS = 10000; | |
private final DelayedTaskStore taskStore; | |
private final DelayedTaskRunner taskRunner; |
NewerOlder