Skip to content

Instantly share code, notes, and snippets.

Niclas Olofsson NiclasOlofsson

  • Malmö, Sweden
Block or report user

Report or block NiclasOlofsson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:aa58b88afc9e1a9c568d
[Plugin]
public class StartupPlugin : Plugin, IStartup
{
private static readonly ILog Log = LogManager.GetLogger(typeof (StartupPlugin));
/// <summary>
/// Startup class for MiNET. Example sets the user and role managers and stores
/// for the application.
/// </summary>
/// <param name="server"></param>
@NiclasOlofsson
NiclasOlofsson / gist:f07edb6df8de8ebc3a90
Created Mar 9, 2015
MiNET login command in plugin.
View gist:f07edb6df8de8ebc3a90
[Plugin("CoreCommands", "The core commands for MiNET", "1.0", "MiNET Team")]
public class CoreCommands : Plugin
{
[Command]
public void Login(Player player, string password)
{
UserManager<User> userManager = player.Server.UserManager;
if (userManager != null)
{
if (player.Username == null) return;
@NiclasOlofsson
NiclasOlofsson / Plugin.cs
Last active Dec 26, 2015
MiNET configuration using JSON
View Plugin.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Xml.Serialization;
using log4net;
using MiNET.Plugins;
View plugin.cs
[Plugin]
public class PlayerLoginPlugin
{
private static readonly ILog Log = LogManager.GetLogger(typeof (PlayerLoginPlugin));
[PacketHandler]
public Package OnLogin(McpeLogin packet, Player newPlayer)
{
Log.InfoFormat("Player {0} connected from {1}", newPlayer.Username, newPlayer.EndPoint.Address);
View Command sign.cs
using System.Collections.Generic;
using System.Threading.Tasks;
using MiNET;
using MiNET.BlockEntities;
using MiNET.Blocks;
using MiNET.Utils;
using MiNET.Worlds;
namespace TestPlugin.MobHunt
{
@NiclasOlofsson
NiclasOlofsson / server.conf
Created Jun 16, 2015
Example server.conf
View server.conf
#DO NOT REMOVE THIS LINE - MiNET Config
#WorldProvider=anvil
WorldProvider=flat
ViewDistance=250
#PCWorldFolder=D:\Downloads\KingsLanding1\KingsLanding1
#PCWaterOffset=30
#PCWorldFolder=D:\Development\Worlds\MiniGames\Capture the flag
#PCWorldFolder=D:\Development\Worlds\MiniGames\Castle Wars
#PCWorldFolder=D:\Development\Worlds\MiniGames\King of the hill
View hologram.cs
public class TextEntity : Entity
{
public TextEntity(Level level, string text, Vector3 pos) : base(64, level)
{
NameTag = text;
KnownPosition = new PlayerLocation(pos);
HealthManager = new NoDamageHealthManager(this);
}
public override void OnTick()
@NiclasOlofsson
NiclasOlofsson / ecdh.cs
Last active Apr 20, 2016
ECDH key import
View ecdh.cs
var clientKey = CreateEcDiffieHellmanPublicKey("MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDEKneqEvcqUqqFMM1HM1A4zWjJC+I8Y+aKzG5dl+6wNOHHQ4NmG2PEXRJYhujyodFH+wO0dEr4GM1WoaWog8xsYQ6mQJAC0eVpBM96spUB1eMN56+BwlJ4H3Qx4TAvAs");
private ECDiffieHellmanPublicKey CreateEcDiffieHellmanPublicKey(string clientPubKeyString)
{
byte[] clientPublicKeyBlob = Base64Url.Decode(clientPubKeyString);
clientPublicKeyBlob = FixPublicKey(clientPublicKeyBlob.Skip(23).ToArray());
ECDiffieHellmanPublicKey clientKey = ECDiffieHellmanCngPublicKey.FromByteArray(clientPublicKeyBlob, CngKeyBlobFormat.EccPublicBlob);
return clientKey;
}
View CountDownTimer.cs
public class CountDownTimer
{
private Stopwatch _startTimer;
private TimeSpan _delay;
private long _currentTick;
private readonly int _skipTicks;
private readonly Action<TimeSpan> _tickAction;
private readonly Action _endAction;
@NiclasOlofsson
NiclasOlofsson / Hologram.cs
Last active Jul 2, 2016
Hologram class based on invisible players.
View Hologram.cs
public class Hologram : Mob
{
public UUID Uuid { get; private set; }
public string Name { get; private set; }
public bool Silent { get; set; }
public bool HideNameTag { get; set; }
public bool NoAi { get; set; }
public Hologram(Level level) : base(63, level)
{
You can’t perform that action at this time.