public static bool OnWhitelist(string ip, TPulse tPulse) { if (!tPulse.Config.EnableWhitelist) { return(true); } CreateIfNot(WhitelistPath, "127.0.0.1"); using (var tr = new StreamReader(WhitelistPath)) { string whitelist = tr.ReadToEnd(); ip = Utils.GetRealIP(ip); bool contains = whitelist.Contains(ip); if (!contains) { foreach (var line in whitelist.Split(Environment.NewLine.ToCharArray())) { if (string.IsNullOrWhiteSpace(line)) { continue; } contains = Utils.GetIPv4Address(line).Equals(ip); if (contains) { return(true); } } return(false); } return(true); } }
public RegionManager(IDbConnection db, TPulse tPulse) { this.tPulse = tPulse; database = db; var table = new SqlTable("Regions", new SqlColumn("X1", MySqlDbType.Int32), new SqlColumn("Y1", MySqlDbType.Int32), new SqlColumn("width", MySqlDbType.Int32), new SqlColumn("height", MySqlDbType.Int32), new SqlColumn("RegionName", MySqlDbType.VarChar, 50) { Primary = true }, new SqlColumn("WorldID", MySqlDbType.Text), new SqlColumn("UserIds", MySqlDbType.Text), new SqlColumn("Protected", MySqlDbType.Int32), new SqlColumn("Groups", MySqlDbType.Text), new SqlColumn("Owner", MySqlDbType.VarChar, 50), new SqlColumn("Z", MySqlDbType.Int32) { DefaultValue = "0" } ); var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator()); creator.EnsureExists(table); ReloadAllRegions(); }
public UserManager(IDbConnection db, TPulse tPulse) { this.tPulse = tPulse; database = db; var table = new SqlTable("Users", new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true }, new SqlColumn("Username", MySqlDbType.VarChar, 32) { Unique = true }, new SqlColumn("Password", MySqlDbType.VarChar, 128), new SqlColumn("Usergroup", MySqlDbType.Text), new SqlColumn("IP", MySqlDbType.VarChar, 16) ); var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator()); creator.EnsureExists(table); }
public override void Initialize() { tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse)); //Loading Friends DB if (File.Exists(FriendsDB.DefaultFile)) { FriendsList = FriendsDB.Load(FriendsDB.DefaultFile); } else { FriendsList.Save(FriendsDB.DefaultFile); } //Adding commands tPulse.Commands.ChatCommands.Add(new Command("", FriendCommand, "friend")); tPulse.Commands.ChatCommands.Add(new Command("", MessageCommand, "fmsg")); tPulse.Commands.ChatCommands.Add(new Command("", MessageAllCommand, "fall")); //Commands.ChatCommands.Add(new Command("", MessageCommand, "sendcoord")); tPulse.Commands.OnPlayerLogin += new PlayerLoginHandler(PlayerLogin); //Hooks.WorldHooks.SaveWorld += new Hooks.WorldHooks.SaveWorldD(WorldHooks_SaveWorld); tPulse.OnWorldSaved += new WorldSavedHandler(OnWorldSaved); }
public override void Initialize() { //Get TPulse instance tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse)); //Commands // /join : to join a channel // /channel : super-command // add : add channel (need group < admin) // del : delete a channel (need group < admin) // list : listing // /cmsg : send a message in the channel //can be null be aware ! tPulse.Commands.ChatCommands.Add(new Command("", JoinCommand, "join")); tPulse.Commands.ChatCommands.Add(new Command("", LeaveCommand, "leave")); tPulse.Commands.ChatCommands.Add(new Command("", ChannelCommand, "channel")); tPulse.Commands.ChatCommands.Add(new Command("", ChannelMessage, "cmsg")); DefaultChannel = Manager.DefaultChannel; Channels.AddRange(Manager.ChatChannels); //Connection hooks tPulse.OnPlayerJoin += new PlayerConnectionHandler(PlayerJoinServer); tPulse.OnPlayerLeave += new PlayerConnectionHandler(PlayerLeaveServer); //World Saved Hooks tPulse.OnWorldSaved += new WorldSavedHandler(OnWorldSaved); }
static Permissions() { //getting the instance of TPulse tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse)); foreach (var field in typeof(Permissions).GetFields()) { field.SetValue(null, field.Name); } //Backwards compatability. restapi = "api"; }
public static void SetupConfig(TPulse tPulse) { if (!Directory.Exists(TPulse.SavePath)) { Directory.CreateDirectory(TPulse.SavePath); } CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!"); CreateIfNot(MotdPath, "This server is running TPulse for Terraria.\n Type /help for a list of commands.\n%255,000,000%Current map: %map%\nCurrent players: %players%"); CreateIfNot(WhitelistPath); if (File.Exists(ConfigPath)) { tPulse.Config = ConfigFile.Read(ConfigPath); // Add all the missing config properties in the json file } tPulse.Config.Write(ConfigPath); }
public override void Initialize() { tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse)); Setting = ArenaSetting.Load(ArenaSettingFile); //todo //commands tPulse.Commands.ChatCommands.Add(new Command("", SetPrepare, "asetprepare")); tPulse.Commands.ChatCommands.Add(new Command("", SetTeamStart, "asetstart")); tPulse.Commands.ChatCommands.Add(new Command("", PreparePlayers, "aprepare")); tPulse.Commands.ChatCommands.Add(new Command("", AssignPlayerTeam, "aassign")); tPulse.Commands.ChatCommands.Add(new Command("", ResetTeams, "areset")); tPulse.Commands.ChatCommands.Add(new Command("", SetArenaHall, "asethall")); tPulse.Commands.ChatCommands.Add(new Command("", SetAterMatch, "asetroom")); Hooks.GameHooks.Update += new Action(GameHooks_Update); //Team Color //Console.WriteLine(Main.teamColor.Length); Main.teamColor[1] = Color.Blue; Main.teamColor[2] = Color.Pink; }
public GroupManager(IDbConnection db, TPulse tPulse) { this.tPulse = tPulse; database = db; var table = new SqlTable("GroupList", new SqlColumn("GroupName", MySqlDbType.VarChar, 32) { Primary = true }, new SqlColumn("Parent", MySqlDbType.VarChar, 32), new SqlColumn("Commands", MySqlDbType.Text), new SqlColumn("ChatColor", MySqlDbType.Text), new SqlColumn("Prefix", MySqlDbType.Text), new SqlColumn("Suffix", MySqlDbType.Text) ); var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator()); creator.EnsureExists(table); // Load Permissions from the DB LoadPermisions(); //need to change those permissions for the groups //set some preset, // Add default groups if they don't exist AddDefaultGroup("guest", "", "canbuild,canregister,canlogin,canpartychat,cantalkinthird"); AddDefaultGroup("default", "guest", "warp,canchangepassword"); AddDefaultGroup("newadmin", "default", "kick,editspawn,reservedslot"); AddDefaultGroup("admin", "newadmin", "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere"); AddDefaultGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers"); AddDefaultGroup("vip", "default", "reservedslot"); }
public RestManager(Rest rest, TPulse tPulse) { Rest = rest; TPulse = tPulse; }
public override void Initialize() { tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse)); //chat commands to add }
public ServerHandler(TPulse tPulse) { this.tPulse = tPulse; }
public ServerHandler(TPulse tPulse) { this.tPulse = tPulse; }
public UserManager(IDbConnection db, TPulse tPulse) { this.tPulse = tPulse; database = db; var table = new SqlTable("Users", new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true}, new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true}, new SqlColumn("Password", MySqlDbType.VarChar, 128), new SqlColumn("Usergroup", MySqlDbType.Text), new SqlColumn("IP", MySqlDbType.VarChar, 16) ); var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator()); creator.EnsureExists(table); }
public PlayerHandler(TPulse tPulse) { this.tPulse = tPulse; }
public override void Initialize() { tPulse = (TPulse)PlugInHandler.GetPluginByType(typeof(TPulse)); //chat commands to add }
public RegionManager(IDbConnection db, TPulse tPulse) { this.tPulse = tPulse; database = db; var table = new SqlTable("Regions", new SqlColumn("X1", MySqlDbType.Int32), new SqlColumn("Y1", MySqlDbType.Int32), new SqlColumn("width", MySqlDbType.Int32), new SqlColumn("height", MySqlDbType.Int32), new SqlColumn("RegionName", MySqlDbType.VarChar, 50) {Primary = true}, new SqlColumn("WorldID", MySqlDbType.Text), new SqlColumn("UserIds", MySqlDbType.Text), new SqlColumn("Protected", MySqlDbType.Int32), new SqlColumn("Groups", MySqlDbType.Text), new SqlColumn("Owner", MySqlDbType.VarChar, 50), new SqlColumn("Z", MySqlDbType.Int32){ DefaultValue = "0" } ); var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator()); creator.EnsureExists(table); ReloadAllRegions(); }
public PlayerHandler(TPulse tPulse) { this.tPulse = tPulse; }