Created
March 23, 2015 22:08
-
-
Save NiclasOlofsson/c273a8f0f38f54723ea3 to your computer and use it in GitHub Desktop.
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
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 | |
{ | |
public class CustomStandingSign : StandingSign | |
{ | |
private static readonly Dictionary<string, Level> Worlds = new Dictionary<string, Level>(); | |
public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face) | |
{ | |
Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign; | |
if (signEntity == null) return false; | |
string world = signEntity.Text1; | |
if (player.Level.LevelId.Equals(world)) return true; | |
if (!Worlds.ContainsKey(player.Level.LevelId)) | |
{ | |
Worlds.Add(player.Level.LevelId, player.Level); | |
} | |
if (!Worlds.ContainsKey(world)) | |
{ | |
Worlds.Add(world, new MobHuntLevel(world, new FlatlandWorldProvider())); | |
} | |
Level level = Worlds[world]; | |
new Task(() => player.SpawnLevel(level)).Start(); | |
level.BroadcastTextMessage(string.Format("{0} teleported to world <{1}>.", player.Username, level.LevelId)); | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment