This file contains 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.Material; | |
import org.bukkit.NamespacedKey; | |
import org.bukkit.entity.Entity; | |
import org.bukkit.inventory.ItemStack; | |
import org.bukkit.inventory.meta.ItemMeta; | |
import org.bukkit.persistence.PersistentDataContainer; | |
import org.bukkit.persistence.PersistentDataType; | |
import java.util.Optional; |
This file contains 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 BuffHandler implements Runnable, Listener { | |
private static final BuffHandler instance = new BuffHandler(); | |
private final TheArtifact plugin; | |
private final Map<BuffType, Buff> buffs = new EnumMap<>(BuffType.class); | |
private final Multimap<LivingEntity, Buff> activeBuffs = Multimaps.synchronizedMultimap(HashMultimap.create()); | |
private BuffHandler() { | |
this.plugin = TheArtifact.getPlugin(); | |
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this, 20, 20); |
This file contains 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 ChunkTaskHandler implements Listener { | |
private static ChunkTaskHandler instance = new ChunkTaskHandler(); | |
private final TheArtifact plugin; | |
private Map<Integer, Map<Object, WorldRunnable>> registeredChunks = new HashMap<>(); | |
public boolean debug = true; | |
private class WorldRunnable { | |
private final Object key; | |
private final Runnable runnable; | |
private final int delay; |
This file contains 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 java.sql.Connection | |
import java.sql.DriverManager | |
import java.sql.PreparedStatement | |
import java.sql.ResultSet | |
import java.sql.SQLException | |
import java.util.concurrent.TimeUnit | |
class Location { | |
public String world; | |
public double x, y, z; |
This file contains 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
@NotNull | |
private Comparator<ItemStack> itemStackComparator() { | |
return (o1, o2) -> { | |
//Sort first by their order in storableItems (left to right) | |
ItemStack o1BaseItem = getBaseItem(o1); | |
ItemStack o2BaseItem = getBaseItem(o2); | |
List<ItemStack> storablesList = new ArrayList<>(storableItems.keySet()); | |
int compare = Integer.compare(storablesList.indexOf(o1BaseItem), storablesList.indexOf(o2BaseItem)); | |
if (compare != 0) return compare; |
This file contains 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 static ItemStack getHeadByUrl(String url) { | |
if (url == null) return new ItemStack(Material.BARRIER); | |
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3); | |
if (url.isEmpty()) return head; | |
SkullMeta headMeta = (SkullMeta) head.getItemMeta(); | |
GameProfile profile = getGameProfile(url); | |
Field profileField; | |
try { |
This file contains 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
private static final BuildingPreviewExtent customExtent; | |
private abstract static class BuildingPreviewExtent implements Extent { | |
@Override | |
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) { | |
return false; | |
} | |
} | |
static { |
This file contains 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 FancyMessage { | |
private List<TextComponent> componentList; | |
private List<TextComponent> lastThenSet; | |
private UUID setId; | |
private Map<UUID, Consumer<Player>> commandsMap = new HashMap<>(); | |
private net.md_5.bungee.api.ChatColor currentColor = net.md_5.bungee.api.ChatColor.WHITE; | |
public FancyMessage() { | |
this(""); | |
} |
This file contains 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 ChunkSnapshotCache { | |
private final LoadingCache<StringChunk, ChunkSnapshot> cache; | |
private ChunkSnapshotCache() { | |
cache = CacheBuilder.newBuilder() | |
.build(new CacheLoader<StringChunk, ChunkSnapshot>() { | |
@Override | |
public ChunkSnapshot load(StringChunk chunk) { | |
return chunk.getChunk().getChunkSnapshot(false, false, false); | |
} | |
}); |
This file contains 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 static void getEntitiesWithinRegion(Location p1, Location p2, Consumer<List<Entity>> entitiesConsumer) { | |
int minX = Math.min(p1.getBlockX(), p2.getBlockX()) >> 4; | |
int maxX = Math.max(p1.getBlockX(), p2.getBlockX()) >> 4; | |
int minZ = Math.min(p1.getBlockZ(), p2.getBlockZ()) >> 4; | |
int maxZ = Math.max(p1.getBlockZ(), p2.getBlockZ()) >> 4; | |
List<CompletableFuture> futures = new ArrayList<>(); | |
List<Entity> entities = new ArrayList<>(); | |
for (int x = minX; x <= maxX; x++) { | |
for (int z = minZ; z <= maxZ; z++) { |
NewerOlder