Merge branch 'master' into general-devel

Conflicts:
	DBEditor/TShockDBEditor.csproj
This commit is contained in:
Lucas Nicodemus 2011-07-23 17:30:20 -06:00
commit 1c7d71431f
33 changed files with 2251 additions and 266 deletions

View file

@ -1,2 +0,0 @@
// Assembly Terraria, Version 1.0.0.0

55
DBEditor/.gitignore vendored Normal file
View file

@ -0,0 +1,55 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*/bin/*
*/obj/*
bin/*
obj/*
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
# Visual Studio shit Motherfucka #
##################################
*.suo
*.sdf
*.opensdf
*.cache
*.pdb
*.csproj.user
*/_ReSharper*/*
*.user
#Template Bat file#
###################
myass.bat

47
DBEditor/CommandList.cs Normal file
View file

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TShockDBEditor
{
public class Commandlist
{
public static List<string> CommandList = new List<string>();
public static void AddCommands()
{
CommandList.Add("reservedslot");
CommandList.Add("canwater");
CommandList.Add("canlava");
CommandList.Add("warp");
CommandList.Add("kick");
CommandList.Add("ban");
CommandList.Add("unban");
CommandList.Add("whitelist");
CommandList.Add("maintenace");
CommandList.Add("causeevents");
CommandList.Add("spawnboss");
CommandList.Add("spawnmob");
CommandList.Add("tp");
CommandList.Add("tphere");
CommandList.Add("managewarp");
CommandList.Add("editspawn");
CommandList.Add("cfg");
CommandList.Add("time");
CommandList.Add("pvpfun");
CommandList.Add("logs");
CommandList.Add("kill");
CommandList.Add("butcher");
CommandList.Add("item");
CommandList.Add("heal");
CommandList.Add("whisper");
CommandList.Add("annoy");
CommandList.Add("immunetokick");
CommandList.Add("immunetoban");
CommandList.Add("ignorecheatdetection");
CommandList.Add("ignoregriefdetection");
CommandList.Add("usebanneditem");
}
}
}

46
DBEditor/DbExt.cs Normal file
View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace TShockDBEditor
{
public static class DbExt
{
public static IDbDataParameter AddParameter(this IDbCommand command, string name, object data)
{
var parm = command.CreateParameter();
parm.ParameterName = name;
parm.Value = data;
command.Parameters.Add(parm);
return parm;
}
static Dictionary<Type, Func<IDataReader, int, object>> ReadFuncs = new Dictionary<Type, Func<IDataReader, int, object>>()
{
{typeof(bool), (s, i) => s.GetBoolean(i)},
{typeof(byte), (s, i) => s.GetByte(i)},
{typeof(Int16), (s, i) => s.GetInt16(i)},
{typeof(Int32), (s, i) => s.GetInt32(i)},
{typeof(Int64), (s, i) => s.GetInt64(i)},
{typeof(string), (s, i) => s.GetString(i)},
{typeof(decimal), (s, i) => s.GetDecimal(i)},
{typeof(float), (s, i) => s.GetFloat(i)},
{typeof(double), (s, i) => s.GetDouble(i)},
};
public static T Get<T>(this IDataReader reader, string column)
{
return reader.Get<T>(reader.GetOrdinal(column));
}
public static T Get<T>(this IDataReader reader, int column)
{
if (ReadFuncs.ContainsKey(typeof(T)))
return (T)ReadFuncs[typeof(T)](reader, column);
throw new NotImplementedException();
}
}
}

24
DBEditor/Group.cs Normal file
View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
namespace TShockDBEditor
{
public class Group
{
public readonly List<string> permissions = new List<string>();
private readonly List<string> negatedpermissions = new List<string>();
public int ID { get; protected set; }
public string Name { get; set; }
public Group Parent { get; set; }
public int Order { get; set; }
public Group(int id, string groupname, int order, Group parentgroup = null)
{
Order = order;
ID = id;
Name = groupname;
Parent = parentgroup;
}
}
}

342
DBEditor/Itemlist.cs Normal file
View file

@ -0,0 +1,342 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TShockDBEditor
{
public class Itemlist
{
public static List<string> ItemList = new List<string>();
public static void AddItems()
{
ItemList.Add("Iron Pickaxe");
ItemList.Add("Dirt Block");
ItemList.Add("Stone Block");
ItemList.Add("Iron Broadsword");
ItemList.Add("Mushroom");
ItemList.Add("Iron Shortsword");
ItemList.Add("Iron Hammer");
ItemList.Add("Torch");
ItemList.Add("Wood");
ItemList.Add("Iron Axe");
ItemList.Add("Iron Ore");
ItemList.Add("Copper Ore");
ItemList.Add("Gold Ore");
ItemList.Add("Silver Ore");
ItemList.Add("Copper Watch");
ItemList.Add("Silver Watch");
ItemList.Add("Gold Watch");
ItemList.Add("Depth Meter");
ItemList.Add("Gold Bar");
ItemList.Add("Copper Bar");
ItemList.Add("Silver Bar");
ItemList.Add("Iron Bar");
ItemList.Add("Gel");
ItemList.Add("Wooden Sword");
ItemList.Add("Wooden Door");
ItemList.Add("Stone Wall");
ItemList.Add("Acorn");
ItemList.Add("Lesser Healing Potion");
ItemList.Add("Life Crystal");
ItemList.Add("Dirt Wall");
ItemList.Add("Bottle");
ItemList.Add("Wooden Table");
ItemList.Add("Furnace");
ItemList.Add("Wooden Chair");
ItemList.Add("Iron Anvil");
ItemList.Add("Work Bench");
ItemList.Add("Goggles");
ItemList.Add("Lens");
ItemList.Add("Wooden Bow");
ItemList.Add("Wooden Arrow");
ItemList.Add("Flaming Arrow");
ItemList.Add("Shuriken");
ItemList.Add("Suspicious Looking Eye");
ItemList.Add("Demon Bow");
ItemList.Add("War Axe of the Night");
ItemList.Add("Light's Bane");
ItemList.Add("Unholy Arrow");
ItemList.Add("Chest");
ItemList.Add("Band of Regeneration");
ItemList.Add("Magic Mirror");
ItemList.Add("Jester's Arrow");
ItemList.Add("Angel Statue");
ItemList.Add("Cloud in a Bottle");
ItemList.Add("Hermes Boots");
ItemList.Add("Enchanted Boomerang");
ItemList.Add("Demonite Ore");
ItemList.Add("Demonite Bar");
ItemList.Add("Heart");
ItemList.Add("Corrupt Seeds");
ItemList.Add("Vile Mushroom");
ItemList.Add("Ebonstone Block");
ItemList.Add("Grass Seeds");
ItemList.Add("Sunflower");
ItemList.Add("Vilethorn");
ItemList.Add("Starfury");
ItemList.Add("Purification Powder");
ItemList.Add("Vile Powder");
ItemList.Add("Rotten Chunk");
ItemList.Add("Worm Tooth");
ItemList.Add("Worm Food");
ItemList.Add("Copper Coin");
ItemList.Add("Silver Coin");
ItemList.Add("Gold Coin");
ItemList.Add("Platinum Coin");
ItemList.Add("Fallen Star");
ItemList.Add("Copper Greaves");
ItemList.Add("Iron Greaves");
ItemList.Add("Silver Greaves");
ItemList.Add("Gold Greaves");
ItemList.Add("Copper Chainmail");
ItemList.Add("Iron Chainmail");
ItemList.Add("Silver Chainmail");
ItemList.Add("Gold Chainmail");
ItemList.Add("Grappling Hook");
ItemList.Add("Iron Chain");
ItemList.Add("Shadow Scale");
ItemList.Add("Piggy Bank");
ItemList.Add("Mining Helmet");
ItemList.Add("Copper Helmet");
ItemList.Add("Iron Helmet");
ItemList.Add("Silver Helmet");
ItemList.Add("Gold Helmet");
ItemList.Add("Wood Wall");
ItemList.Add("Wood Platform");
ItemList.Add("Flintlock Pistol");
ItemList.Add("Musket");
ItemList.Add("Musket Ball");
ItemList.Add("Minishark");
ItemList.Add("Iron Bow");
ItemList.Add("Shadow Greaves");
ItemList.Add("Shadow Scalemail");
ItemList.Add("Shadow Helmet");
ItemList.Add("Nightmare Pickaxe");
ItemList.Add("The Breaker");
ItemList.Add("Candle");
ItemList.Add("Copper Chandelier");
ItemList.Add("Silver Chandelier");
ItemList.Add("Gold Chandelier");
ItemList.Add("Mana Crystal");
ItemList.Add("Lesser Mana Potion");
ItemList.Add("Band of Starpower");
ItemList.Add("Flower of Fire");
ItemList.Add("Magic Missile");
ItemList.Add("Dirt Rod");
ItemList.Add("Orb of Light");
ItemList.Add("Meteorite");
ItemList.Add("Meteorite Bar");
ItemList.Add("Hook");
ItemList.Add("Flamarang");
ItemList.Add("Molten Fury");
ItemList.Add("Fiery Greatsword");
ItemList.Add("Molten Pickaxe");
ItemList.Add("Meteor Helmet");
ItemList.Add("Meteor Suit");
ItemList.Add("Meteor Leggings");
ItemList.Add("Bottled Water");
ItemList.Add("Space Gun");
ItemList.Add("Rocket Boots");
ItemList.Add("Gray Brick");
ItemList.Add("Gray Brick Wall");
ItemList.Add("Red Brick");
ItemList.Add("Red Brick Wall");
ItemList.Add("Clay Block");
ItemList.Add("Blue Brick");
ItemList.Add("Blue Brick Wall");
ItemList.Add("Chain Lantern");
ItemList.Add("Green Brick");
ItemList.Add("Green Brick Wall");
ItemList.Add("Pink Brick");
ItemList.Add("Pink Brick Wall");
ItemList.Add("Gold Brick");
ItemList.Add("Gold Brick Wall");
ItemList.Add("Silver Brick");
ItemList.Add("Silver Brick Wall");
ItemList.Add("Copper Brick");
ItemList.Add("Copper Brick Wall");
ItemList.Add("Spike");
ItemList.Add("Water Candle");
ItemList.Add("Book");
ItemList.Add("Cobweb");
ItemList.Add("Necro Helmet");
ItemList.Add("Necro Breastplate");
ItemList.Add("Necro Greaves");
ItemList.Add("Bone");
ItemList.Add("Muramasa");
ItemList.Add("Cobalt Shield");
ItemList.Add("Aqua Scepter");
ItemList.Add("Lucky Horseshoe");
ItemList.Add("Shiny Red Balloon");
ItemList.Add("Harpoon");
ItemList.Add("Spiky Ball");
ItemList.Add("Ball 'O Hurt");
ItemList.Add("Blue Moon");
ItemList.Add("Handgun");
ItemList.Add("Water Bolt");
ItemList.Add("Bomb");
ItemList.Add("Dynamite");
ItemList.Add("Grenade");
ItemList.Add("Sand Block");
ItemList.Add("Glass");
ItemList.Add("Sign");
ItemList.Add("Ash Block");
ItemList.Add("Obsidian");
ItemList.Add("Hellstone");
ItemList.Add("Hellstone Bar");
ItemList.Add("Mud Block");
ItemList.Add("Sapphire");
ItemList.Add("Ruby");
ItemList.Add("Emerald");
ItemList.Add("Topaz");
ItemList.Add("Amethyst");
ItemList.Add("Diamond");
ItemList.Add("Glowing Mushroom");
ItemList.Add("Star");
ItemList.Add("Ivy Whip");
ItemList.Add("Breathing Reed");
ItemList.Add("Flipper");
ItemList.Add("Healing Potion");
ItemList.Add("Mana Potion");
ItemList.Add("Blade of Grass");
ItemList.Add("Thorn Chakrum");
ItemList.Add("Obsidian Brick");
ItemList.Add("Obsidian Skull");
ItemList.Add("Mushroom Grass Seeds");
ItemList.Add("Jungle Grass Seeds");
ItemList.Add("Wooden Hammer");
ItemList.Add("Star Cannon");
ItemList.Add("Blue Phaseblade");
ItemList.Add("Red Phaseblade");
ItemList.Add("Green Phaseblade");
ItemList.Add("Purple Phaseblade");
ItemList.Add("White Phaseblade");
ItemList.Add("Yellow Phaseblade");
ItemList.Add("Meteor Hamaxe");
ItemList.Add("Empty Bucket");
ItemList.Add("Water Bucket");
ItemList.Add("Lava Bucket");
ItemList.Add("Jungle Rose");
ItemList.Add("Stinger");
ItemList.Add("Vine");
ItemList.Add("Feral Claws");
ItemList.Add("Anklet of the Wind");
ItemList.Add("Staff of Regrowth");
ItemList.Add("Hellstone Brick");
ItemList.Add("Whoopie Cushion");
ItemList.Add("Shackle");
ItemList.Add("Molten Hamaxe");
ItemList.Add("Flamelash");
ItemList.Add("Phoenix Blaster");
ItemList.Add("Sunfury");
ItemList.Add("Hellforge");
ItemList.Add("Clay Pot");
ItemList.Add("Nature's Gift");
ItemList.Add("Bed");
ItemList.Add("Silk");
ItemList.Add("Lesser Restoration Potion");
ItemList.Add("Restoration Potion");
ItemList.Add("Jungle Hat");
ItemList.Add("Jungle Shirt");
ItemList.Add("Jungle Pants");
ItemList.Add("Molten Helmet");
ItemList.Add("Molten Breastplate");
ItemList.Add("Molten Greaves");
ItemList.Add("Meteor Shot");
ItemList.Add("Sticky Bomb");
ItemList.Add("Black Lens");
ItemList.Add("Sunglasses");
ItemList.Add("Wizard Hat");
ItemList.Add("Top Hat");
ItemList.Add("Tuxedo Shirt");
ItemList.Add("Tuxedo Pants");
ItemList.Add("Summer Hat");
ItemList.Add("Bunny Hood");
ItemList.Add("Plumber's Hat");
ItemList.Add("Plumber's Shirt");
ItemList.Add("Plumber's Pants");
ItemList.Add("Hero's Hat");
ItemList.Add("Hero's Shirt");
ItemList.Add("Hero's Pants");
ItemList.Add("Fish Bowl");
ItemList.Add("Archaeologist's Hat");
ItemList.Add("Archaeologist's Jacket");
ItemList.Add("Archaeologist's Pants");
ItemList.Add("Black Dye");
ItemList.Add("Green Dye");
ItemList.Add("Ninja Hood");
ItemList.Add("Ninja Shirt");
ItemList.Add("Ninja Pants");
ItemList.Add("Leather");
ItemList.Add("Red Hat");
ItemList.Add("Goldfish");
ItemList.Add("Robe");
ItemList.Add("Robot Hat");
ItemList.Add("Gold Crown");
ItemList.Add("Hellfire Arrow");
ItemList.Add("Sandgun");
ItemList.Add("Guide Voodoo Doll");
ItemList.Add("Diving Helmet");
ItemList.Add("Familiar Shirt");
ItemList.Add("Familiar Pants");
ItemList.Add("Familiar Wig");
ItemList.Add("Demon Scythe");
ItemList.Add("Night's Edge");
ItemList.Add("Dark Lance");
ItemList.Add("Coral");
ItemList.Add("Cactus");
ItemList.Add("Trident");
ItemList.Add("Silver Bullet");
ItemList.Add("Throwing Knife");
ItemList.Add("Spear");
ItemList.Add("Blowpipe");
ItemList.Add("Glowstick");
ItemList.Add("Seed");
ItemList.Add("Wooden Boomerang");
ItemList.Add("Aglet");
ItemList.Add("Sticky Glowstick");
ItemList.Add("Poisoned Knife");
ItemList.Add("Obsidian Skin Potion");
ItemList.Add("Regeneration Potion");
ItemList.Add("Swiftness Potion");
ItemList.Add("Gills potion");
ItemList.Add("Ironskin Potion");
ItemList.Add("Mana Regeneration Potion");
ItemList.Add("Magic Power Potion");
ItemList.Add("Featherfall Potion");
ItemList.Add("Spelunker Potion");
ItemList.Add("Invisibility Potion");
ItemList.Add("Shine Potion");
ItemList.Add("Night Owl Potion");
ItemList.Add("Battle Potion");
ItemList.Add("Thorns Potion");
ItemList.Add("Water Walking Potion");
ItemList.Add("Archery Potion");
ItemList.Add("Hunter Potion");
ItemList.Add("Gravitation Potion");
ItemList.Add("Gold Chest");
ItemList.Add("Daybloom Seeds");
ItemList.Add("Moonglow Seeds");
ItemList.Add("Blinkroot Seeds");
ItemList.Add("Deathweed Seeds");
ItemList.Add("Waterleaf Seeds");
ItemList.Add("Fireblossom Seeds");
ItemList.Add("Daybloom");
ItemList.Add("Moonglow");
ItemList.Add("Blinkroot");
ItemList.Add("Deathweed");
ItemList.Add("Waterleaf");
ItemList.Add("Fireblossom");
ItemList.Add("Shark Fin");
ItemList.Add("Feather");
ItemList.Add("Tombstone");
ItemList.Add("Mime Mask");
ItemList.Add("Antlion Mandible");
ItemList.Add("Illegal Gun Parts");
ItemList.Add("The Doctor's Shirt");
ItemList.Add("The Doctor's Pants");
}
}
}

579
DBEditor/Main.Designer.cs generated Normal file
View file

@ -0,0 +1,579 @@
namespace TShockDBEditor
{
partial class TShockDBEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.itemListBanned = new System.Windows.Forms.ListBox();
this.itemListAvailable = new System.Windows.Forms.ListBox();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.btn_moveAllLeft = new System.Windows.Forms.Button();
this.btn_moveAllRight = new System.Windows.Forms.Button();
this.btn_moveLeft = new System.Windows.Forms.Button();
this.btn_moveRight = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.lst_inheritgrps = new System.Windows.Forms.ComboBox();
this.label11 = new System.Windows.Forms.Label();
this.txt_grpname = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.btn_deletegroup = new System.Windows.Forms.Button();
this.btn_newgroup = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.btn_moveAllLeftCmd = new System.Windows.Forms.Button();
this.btn_moveLeftCmd = new System.Windows.Forms.Button();
this.btn_moveRightCmd = new System.Windows.Forms.Button();
this.lst_AvailableCmds = new System.Windows.Forms.ListBox();
this.btn_moveAllRightCmd = new System.Windows.Forms.Button();
this.lst_bannedCmds = new System.Windows.Forms.ListBox();
this.lst_groupList = new System.Windows.Forms.ListBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.btn_OpenLocalDB = new System.Windows.Forms.Button();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.btn_connect = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label();
this.txt_password = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txt_username = new System.Windows.Forms.TextBox();
this.txt_port = new System.Windows.Forms.TextBox();
this.txt_dbname = new System.Windows.Forms.TextBox();
this.txt_hostname = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.lbl_grpchild = new System.Windows.Forms.Label();
this.tabControl.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage3.SuspendLayout();
this.tabPage4.SuspendLayout();
this.SuspendLayout();
//
// itemListBanned
//
this.itemListBanned.FormattingEnabled = true;
this.itemListBanned.Location = new System.Drawing.Point(321, 19);
this.itemListBanned.Name = "itemListBanned";
this.itemListBanned.Size = new System.Drawing.Size(275, 290);
this.itemListBanned.TabIndex = 1;
//
// itemListAvailable
//
this.itemListAvailable.FormattingEnabled = true;
this.itemListAvailable.Location = new System.Drawing.Point(7, 19);
this.itemListAvailable.Name = "itemListAvailable";
this.itemListAvailable.Size = new System.Drawing.Size(275, 290);
this.itemListAvailable.TabIndex = 2;
//
// tabControl
//
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(12, 143);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(610, 407);
this.tabControl.TabIndex = 3;
this.tabControl.Visible = false;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btn_moveAllLeft);
this.tabPage1.Controls.Add(this.btn_moveAllRight);
this.tabPage1.Controls.Add(this.btn_moveLeft);
this.tabPage1.Controls.Add(this.btn_moveRight);
this.tabPage1.Controls.Add(this.label2);
this.tabPage1.Controls.Add(this.label1);
this.tabPage1.Controls.Add(this.itemListAvailable);
this.tabPage1.Controls.Add(this.itemListBanned);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(602, 381);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Item Bans";
this.tabPage1.UseVisualStyleBackColor = true;
//
// btn_moveAllLeft
//
this.btn_moveAllLeft.Location = new System.Drawing.Point(288, 193);
this.btn_moveAllLeft.Name = "btn_moveAllLeft";
this.btn_moveAllLeft.Size = new System.Drawing.Size(27, 23);
this.btn_moveAllLeft.TabIndex = 8;
this.btn_moveAllLeft.Text = "<<";
this.btn_moveAllLeft.UseVisualStyleBackColor = true;
this.btn_moveAllLeft.Click += new System.EventHandler(this.btn_moveAllLeftItems_Click);
//
// btn_moveAllRight
//
this.btn_moveAllRight.Location = new System.Drawing.Point(288, 106);
this.btn_moveAllRight.Name = "btn_moveAllRight";
this.btn_moveAllRight.Size = new System.Drawing.Size(27, 23);
this.btn_moveAllRight.TabIndex = 7;
this.btn_moveAllRight.Text = ">>";
this.btn_moveAllRight.UseVisualStyleBackColor = true;
this.btn_moveAllRight.Click += new System.EventHandler(this.btn_moveAllRightItems_Click);
//
// btn_moveLeft
//
this.btn_moveLeft.Location = new System.Drawing.Point(288, 164);
this.btn_moveLeft.Name = "btn_moveLeft";
this.btn_moveLeft.Size = new System.Drawing.Size(27, 23);
this.btn_moveLeft.TabIndex = 6;
this.btn_moveLeft.Text = "<";
this.btn_moveLeft.UseVisualStyleBackColor = true;
this.btn_moveLeft.Click += new System.EventHandler(this.btn_moveLeftItems_Click);
//
// btn_moveRight
//
this.btn_moveRight.Location = new System.Drawing.Point(288, 135);
this.btn_moveRight.Name = "btn_moveRight";
this.btn_moveRight.Size = new System.Drawing.Size(27, 23);
this.btn_moveRight.TabIndex = 5;
this.btn_moveRight.Text = ">";
this.btn_moveRight.UseVisualStyleBackColor = true;
this.btn_moveRight.Click += new System.EventHandler(this.btn_moveRightItems_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(318, 3);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(86, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Blacklisted Items";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 3);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(87, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Whitelisted Items";
//
// tabPage2
//
this.tabPage2.Controls.Add(this.lbl_grpchild);
this.tabPage2.Controls.Add(this.label12);
this.tabPage2.Controls.Add(this.lst_inheritgrps);
this.tabPage2.Controls.Add(this.label11);
this.tabPage2.Controls.Add(this.txt_grpname);
this.tabPage2.Controls.Add(this.label10);
this.tabPage2.Controls.Add(this.btn_deletegroup);
this.tabPage2.Controls.Add(this.btn_newgroup);
this.tabPage2.Controls.Add(this.label4);
this.tabPage2.Controls.Add(this.label3);
this.tabPage2.Controls.Add(this.btn_moveAllLeftCmd);
this.tabPage2.Controls.Add(this.btn_moveLeftCmd);
this.tabPage2.Controls.Add(this.btn_moveRightCmd);
this.tabPage2.Controls.Add(this.lst_AvailableCmds);
this.tabPage2.Controls.Add(this.btn_moveAllRightCmd);
this.tabPage2.Controls.Add(this.lst_bannedCmds);
this.tabPage2.Controls.Add(this.lst_groupList);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(602, 381);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Group Manager";
this.tabPage2.UseVisualStyleBackColor = true;
//
// lst_inheritgrps
//
this.lst_inheritgrps.FormattingEnabled = true;
this.lst_inheritgrps.Location = new System.Drawing.Point(375, 84);
this.lst_inheritgrps.Name = "lst_inheritgrps";
this.lst_inheritgrps.Size = new System.Drawing.Size(100, 21);
this.lst_inheritgrps.TabIndex = 23;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(299, 87);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(65, 13);
this.label11.TabIndex = 22;
this.label11.Text = "Inherit From:";
//
// txt_grpname
//
this.txt_grpname.Location = new System.Drawing.Point(375, 55);
this.txt_grpname.Name = "txt_grpname";
this.txt_grpname.Size = new System.Drawing.Size(100, 20);
this.txt_grpname.TabIndex = 21;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(299, 58);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(70, 13);
this.label10.TabIndex = 20;
this.label10.Text = "Group Name:";
//
// btn_deletegroup
//
this.btn_deletegroup.Location = new System.Drawing.Point(215, 82);
this.btn_deletegroup.Name = "btn_deletegroup";
this.btn_deletegroup.Size = new System.Drawing.Size(78, 23);
this.btn_deletegroup.TabIndex = 19;
this.btn_deletegroup.Text = "Delete Group";
this.btn_deletegroup.UseVisualStyleBackColor = true;
this.btn_deletegroup.Click += new System.EventHandler(this.btn_deletegroup_Click);
//
// btn_newgroup
//
this.btn_newgroup.Location = new System.Drawing.Point(215, 53);
this.btn_newgroup.Name = "btn_newgroup";
this.btn_newgroup.Size = new System.Drawing.Size(78, 23);
this.btn_newgroup.TabIndex = 18;
this.btn_newgroup.Text = "New Group";
this.btn_newgroup.UseVisualStyleBackColor = true;
this.btn_newgroup.Click += new System.EventHandler(this.btn_newgroup_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(324, 144);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(114, 13);
this.label4.TabIndex = 17;
this.label4.Text = "Whitelisted Commands";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 145);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(99, 13);
this.label3.TabIndex = 16;
this.label3.Text = "Banned Commands";
//
// btn_moveAllLeftCmd
//
this.btn_moveAllLeftCmd.Location = new System.Drawing.Point(291, 300);
this.btn_moveAllLeftCmd.Name = "btn_moveAllLeftCmd";
this.btn_moveAllLeftCmd.Size = new System.Drawing.Size(27, 23);
this.btn_moveAllLeftCmd.TabIndex = 15;
this.btn_moveAllLeftCmd.Text = "<<";
this.btn_moveAllLeftCmd.UseVisualStyleBackColor = true;
this.btn_moveAllLeftCmd.Click += new System.EventHandler(this.btn_moveAllLeftCmd_Click);
//
// btn_moveLeftCmd
//
this.btn_moveLeftCmd.Location = new System.Drawing.Point(291, 270);
this.btn_moveLeftCmd.Name = "btn_moveLeftCmd";
this.btn_moveLeftCmd.Size = new System.Drawing.Size(27, 23);
this.btn_moveLeftCmd.TabIndex = 14;
this.btn_moveLeftCmd.Text = "<";
this.btn_moveLeftCmd.UseVisualStyleBackColor = true;
this.btn_moveLeftCmd.Click += new System.EventHandler(this.btn_moveLeftCmd_Click);
//
// btn_moveRightCmd
//
this.btn_moveRightCmd.Location = new System.Drawing.Point(291, 240);
this.btn_moveRightCmd.Name = "btn_moveRightCmd";
this.btn_moveRightCmd.Size = new System.Drawing.Size(27, 23);
this.btn_moveRightCmd.TabIndex = 13;
this.btn_moveRightCmd.Text = ">";
this.btn_moveRightCmd.UseVisualStyleBackColor = true;
this.btn_moveRightCmd.Click += new System.EventHandler(this.btn_moveRightCmd_Click);
//
// lst_AvailableCmds
//
this.lst_AvailableCmds.FormattingEnabled = true;
this.lst_AvailableCmds.Location = new System.Drawing.Point(324, 161);
this.lst_AvailableCmds.Name = "lst_AvailableCmds";
this.lst_AvailableCmds.Size = new System.Drawing.Size(272, 212);
this.lst_AvailableCmds.TabIndex = 12;
//
// btn_moveAllRightCmd
//
this.btn_moveAllRightCmd.Location = new System.Drawing.Point(291, 210);
this.btn_moveAllRightCmd.Name = "btn_moveAllRightCmd";
this.btn_moveAllRightCmd.Size = new System.Drawing.Size(27, 23);
this.btn_moveAllRightCmd.TabIndex = 11;
this.btn_moveAllRightCmd.Text = ">>";
this.btn_moveAllRightCmd.UseVisualStyleBackColor = true;
this.btn_moveAllRightCmd.Click += new System.EventHandler(this.btn_moveAllRightCmd_Click);
//
// lst_bannedCmds
//
this.lst_bannedCmds.FormattingEnabled = true;
this.lst_bannedCmds.Location = new System.Drawing.Point(9, 161);
this.lst_bannedCmds.Name = "lst_bannedCmds";
this.lst_bannedCmds.Size = new System.Drawing.Size(275, 212);
this.lst_bannedCmds.TabIndex = 10;
//
// lst_groupList
//
this.lst_groupList.FormattingEnabled = true;
this.lst_groupList.Location = new System.Drawing.Point(9, 8);
this.lst_groupList.Name = "lst_groupList";
this.lst_groupList.Size = new System.Drawing.Size(200, 134);
this.lst_groupList.TabIndex = 0;
this.lst_groupList.SelectedIndexChanged += new System.EventHandler(this.lst_groupList_SelectedIndexChanged);
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(610, 125);
this.tabControl1.TabIndex = 6;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.btn_OpenLocalDB);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(602, 99);
this.tabPage3.TabIndex = 0;
this.tabPage3.Text = "Local Database (SQLite)";
this.tabPage3.UseVisualStyleBackColor = true;
//
// btn_OpenLocalDB
//
this.btn_OpenLocalDB.Location = new System.Drawing.Point(9, 6);
this.btn_OpenLocalDB.Name = "btn_OpenLocalDB";
this.btn_OpenLocalDB.Size = new System.Drawing.Size(96, 23);
this.btn_OpenLocalDB.TabIndex = 0;
this.btn_OpenLocalDB.Text = "Open Database";
this.btn_OpenLocalDB.UseVisualStyleBackColor = true;
this.btn_OpenLocalDB.Click += new System.EventHandler(this.btn_OpenLocalDB_Click);
//
// tabPage4
//
this.tabPage4.Controls.Add(this.btn_connect);
this.tabPage4.Controls.Add(this.label9);
this.tabPage4.Controls.Add(this.txt_password);
this.tabPage4.Controls.Add(this.label8);
this.tabPage4.Controls.Add(this.txt_username);
this.tabPage4.Controls.Add(this.txt_port);
this.tabPage4.Controls.Add(this.txt_dbname);
this.tabPage4.Controls.Add(this.txt_hostname);
this.tabPage4.Controls.Add(this.label7);
this.tabPage4.Controls.Add(this.label6);
this.tabPage4.Controls.Add(this.label5);
this.tabPage4.Location = new System.Drawing.Point(4, 22);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
this.tabPage4.Size = new System.Drawing.Size(602, 99);
this.tabPage4.TabIndex = 1;
this.tabPage4.Text = "Remote Database (MySql)";
this.tabPage4.UseVisualStyleBackColor = true;
//
// btn_connect
//
this.btn_connect.Location = new System.Drawing.Point(213, 63);
this.btn_connect.Name = "btn_connect";
this.btn_connect.Size = new System.Drawing.Size(75, 23);
this.btn_connect.TabIndex = 10;
this.btn_connect.Text = "Connect";
this.btn_connect.UseVisualStyleBackColor = true;
this.btn_connect.Click += new System.EventHandler(this.btn_connect_Click);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(210, 36);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(56, 13);
this.label9.TabIndex = 9;
this.label9.Text = "Password:";
//
// txt_password
//
this.txt_password.Location = new System.Drawing.Point(272, 33);
this.txt_password.Name = "txt_password";
this.txt_password.Size = new System.Drawing.Size(100, 20);
this.txt_password.TabIndex = 8;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(208, 10);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(58, 13);
this.label8.TabIndex = 7;
this.label8.Text = "Username:";
//
// txt_username
//
this.txt_username.Location = new System.Drawing.Point(272, 7);
this.txt_username.Name = "txt_username";
this.txt_username.Size = new System.Drawing.Size(100, 20);
this.txt_username.TabIndex = 6;
//
// txt_port
//
this.txt_port.Location = new System.Drawing.Point(102, 60);
this.txt_port.Name = "txt_port";
this.txt_port.Size = new System.Drawing.Size(100, 20);
this.txt_port.TabIndex = 5;
this.txt_port.Text = "3306";
//
// txt_dbname
//
this.txt_dbname.Location = new System.Drawing.Point(102, 33);
this.txt_dbname.Name = "txt_dbname";
this.txt_dbname.Size = new System.Drawing.Size(100, 20);
this.txt_dbname.TabIndex = 4;
//
// txt_hostname
//
this.txt_hostname.Location = new System.Drawing.Point(102, 7);
this.txt_hostname.Name = "txt_hostname";
this.txt_hostname.Size = new System.Drawing.Size(100, 20);
this.txt_hostname.TabIndex = 3;
this.txt_hostname.Text = "localhost";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(70, 63);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(26, 13);
this.label7.TabIndex = 2;
this.label7.Text = "Port";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(9, 36);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(87, 13);
this.label6.TabIndex = 1;
this.label6.Text = "Database Name:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(38, 10);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(58, 13);
this.label5.TabIndex = 0;
this.label5.Text = "Hostname:";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(215, 8);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(65, 13);
this.label12.TabIndex = 24;
this.label12.Text = "Group Child:";
//
// lbl_grpchild
//
this.lbl_grpchild.AutoSize = true;
this.lbl_grpchild.Location = new System.Drawing.Point(286, 8);
this.lbl_grpchild.Name = "lbl_grpchild";
this.lbl_grpchild.Size = new System.Drawing.Size(16, 13);
this.lbl_grpchild.TabIndex = 25;
this.lbl_grpchild.Text = " ";
//
// TShockDBEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(634, 562);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.tabControl);
this.Name = "TShockDBEditor";
this.Text = "TShockDBEditor";
this.tabControl.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tabPage4.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox itemListBanned;
private System.Windows.Forms.ListBox itemListAvailable;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btn_moveAllLeft;
private System.Windows.Forms.Button btn_moveAllRight;
private System.Windows.Forms.Button btn_moveLeft;
private System.Windows.Forms.Button btn_moveRight;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.TabPage tabPage4;
private System.Windows.Forms.Button btn_OpenLocalDB;
private System.Windows.Forms.Button btn_moveAllLeftCmd;
private System.Windows.Forms.Button btn_moveLeftCmd;
private System.Windows.Forms.Button btn_moveRightCmd;
private System.Windows.Forms.ListBox lst_AvailableCmds;
private System.Windows.Forms.Button btn_moveAllRightCmd;
private System.Windows.Forms.ListBox lst_bannedCmds;
private System.Windows.Forms.ListBox lst_groupList;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button btn_connect;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txt_password;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txt_username;
private System.Windows.Forms.TextBox txt_port;
private System.Windows.Forms.TextBox txt_dbname;
private System.Windows.Forms.TextBox txt_hostname;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button btn_deletegroup;
private System.Windows.Forms.Button btn_newgroup;
private System.Windows.Forms.ComboBox lst_inheritgrps;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox txt_grpname;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label lbl_grpchild;
private System.Windows.Forms.Label label12;
}
}

436
DBEditor/Main.cs Normal file
View file

@ -0,0 +1,436 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using Community.CsharpSqlite.SQLiteClient;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
namespace TShockDBEditor
{
public partial class TShockDBEditor : Form
{
public OpenFileDialog dialog = new OpenFileDialog();
public List<Group> groups = new List<Group>();
public IDbConnection DB;
public string dbtype = "";
public TShockDBEditor()
{
InitializeComponent();
Itemlist.AddItems();
Commandlist.AddCommands();
dialog.FileOk += new CancelEventHandler(dialog_FileOk);
dialog.Filter = "SQLite Database (*.sqlite)|*.sqlite";
}
public void LoadSqliteDatabase(string path)
{
string sql = dialog.FileName;
DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
DB.Open();
dbtype = "sqlite";
itemListBanned.Items.Clear();
lst_groupList.Items.Clear();
lst_AvailableCmds.Items.Clear();
lst_bannedCmds.Items.Clear();
itemListAvailable.Items.Clear();
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Itembans";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
itemListBanned.Items.Add(reader.Get<string>("ItemName"));
}
}
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM GroupList";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
lst_groupList.Items.Add(reader.Get<string>("GroupName"));
lst_inheritgrps.Items.Add(reader.Get<string>("GroupName"));
}
}
}
for (int i = 0; i < Itemlist.ItemList.Count; i++)
{
if (!itemListBanned.Items.Contains(Itemlist.ItemList[i]))
itemListAvailable.Items.Add(Itemlist.ItemList[i]);
}
}
public void LoadMySqlDatabase(string hostname = "localhost", string port = "3306", string database = "", string username = "", string password = "")
{
DB = new MySqlConnection();
DB.ConnectionString =
"Server='" + hostname +
"';Port='" + port +
"';Database='" + database +
"';Uid='" + username +
"';Pwd='" + password + "';";
DB.Open();
dbtype = "mysql";
itemListBanned.Items.Clear();
lst_groupList.Items.Clear();
lst_AvailableCmds.Items.Clear();
lst_bannedCmds.Items.Clear();
itemListAvailable.Items.Clear();
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Itembans";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
itemListBanned.Items.Add(reader.Get<string>("ItemName"));
}
}
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM GroupList";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
lst_groupList.Items.Add(reader.Get<string>("GroupName"));
}
}
}
for (int i = 0; i < Itemlist.ItemList.Count; i++)
{
if (!itemListBanned.Items.Contains(Itemlist.ItemList[i]))
itemListAvailable.Items.Add(Itemlist.ItemList[i]);
}
}
#region BannedItemsTab
public void btn_moveAllRightItems_Click(object sender, EventArgs e)
{
foreach (object item in itemListAvailable.Items)
{
itemListBanned.Items.Add(item);
using (var com = DB.CreateCommand())
{
com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);";
com.AddParameter("@itemname", item.ToString());
com.ExecuteNonQuery();
com.Parameters.Clear();
}
}
itemListAvailable.Items.Clear();
}
private void btn_moveAllLeftItems_Click(object sender, EventArgs e)
{
foreach (object item in itemListBanned.Items)
{
itemListAvailable.Items.Add(item);
using (var com = DB.CreateCommand())
{
com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;";
com.AddParameter("@itemname", item.ToString());
com.ExecuteNonQuery();
com.Parameters.Clear();
}
}
itemListBanned.Items.Clear();
}
private void btn_moveRightItems_Click(object sender, EventArgs e)
{
if (itemListAvailable.SelectedItem != null)
{
itemListBanned.Items.Add(itemListAvailable.SelectedItem);
using (var com = DB.CreateCommand())
{
com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);";
com.AddParameter("@itemname", itemListAvailable.SelectedItem.ToString());
com.ExecuteNonQuery();
}
itemListAvailable.Items.Remove(itemListAvailable.SelectedItem);
}
}
private void btn_moveLeftItems_Click(object sender, EventArgs e)
{
if (itemListBanned.SelectedItem != null)
{
itemListAvailable.Items.Add(itemListBanned.SelectedItem);
using (var com = DB.CreateCommand())
{
com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;";
com.AddParameter("@itemname", itemListBanned.SelectedItem.ToString());
com.ExecuteNonQuery();
}
itemListBanned.Items.Remove(itemListBanned.SelectedItem);
}
}
#endregion
#region GroupTab
private void lst_groupList_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateGroupIndex(lst_groupList.SelectedIndex);
}
private void UpdateGroupIndex(int index)
{
try
{
using (var com = DB.CreateCommand())
{
lst_AvailableCmds.Items.Clear();
lst_bannedCmds.Items.Clear();
com.CommandText =
"SELECT * FROM GroupList WHERE GroupName=@groupname";
com.AddParameter("@groupname", lst_groupList.Items[index].ToString());
lbl_grpchild.Text = "";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
foreach (string command in reader.Get<string>("Commands").Split(','))
{
if (lst_groupList.Items.Contains(command) || command == "")
lbl_grpchild.Text = command;
else
lst_AvailableCmds.Items.Add(command);
}
}
}
if (lbl_grpchild.Text == "")
lbl_grpchild.Text = "none";
for (int i = 0; i < Commandlist.CommandList.Count; i++)
{
if (!lst_AvailableCmds.Items.Contains(Commandlist.CommandList[i]))
lst_bannedCmds.Items.Add(Commandlist.CommandList[i]);
}
}
}
catch { }
}
private void btn_moveAllRightCmd_Click(object sender, EventArgs e)
{
try
{
var sb = new StringBuilder();
foreach (object cmd in lst_bannedCmds.Items)
{
lst_AvailableCmds.Items.Add(cmd);
if (string.IsNullOrEmpty(sb.ToString()))
sb.Append(cmd.ToString());
else
sb.Append(",").Append(cmd.ToString());
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", sb.ToString());
com.ExecuteNonQuery();
}
lst_bannedCmds.Items.Clear();
}
catch { }
}
private void btn_moveRightCmd_Click(object sender, EventArgs e)
{
try
{
lst_AvailableCmds.Items.Add(lst_bannedCmds.Items[lst_bannedCmds.SelectedIndex]);
var sb = new StringBuilder();
foreach (object cmd in lst_AvailableCmds.Items)
{
if (string.IsNullOrEmpty(sb.ToString()))
sb.Append(cmd.ToString());
else
sb.Append(",").Append(cmd.ToString());
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", sb.ToString());
com.ExecuteNonQuery();
}
lst_bannedCmds.Items.Remove(lst_bannedCmds.Items[lst_bannedCmds.SelectedIndex]);
}
catch { }
}
private void btn_moveLeftCmd_Click(object sender, EventArgs e)
{
try
{
lst_bannedCmds.Items.Add(lst_AvailableCmds.Items[lst_AvailableCmds.SelectedIndex]);
lst_AvailableCmds.Items.Remove(lst_AvailableCmds.Items[lst_AvailableCmds.SelectedIndex]);
var sb = new StringBuilder();
foreach (object cmd in lst_AvailableCmds.Items)
{
if (string.IsNullOrEmpty(sb.ToString()))
sb.Append(cmd.ToString());
else
sb.Append(",").Append(cmd.ToString());
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", sb.ToString());
com.ExecuteNonQuery();
}
}
catch { }
}
private void btn_moveAllLeftCmd_Click(object sender, EventArgs e)
{
try
{
foreach (object cmd in lst_AvailableCmds.Items)
{
lst_bannedCmds.Items.Add(cmd);
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", "");
com.ExecuteNonQuery();
}
lst_AvailableCmds.Items.Clear();
}
catch { }
}
private void btn_newgroup_Click(object sender, EventArgs e)
{
try
{
if (txt_grpname.Text != "")
{
using (var com = DB.CreateCommand())
{
if (dbtype == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands) VALUES (@groupname, @commands);";
else if (dbtype == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands;";
com.AddParameter("@groupname", txt_grpname.Text);
if(lst_inheritgrps.SelectedIndex > -1)
com.AddParameter("@commands", lst_inheritgrps.Items[lst_inheritgrps.SelectedIndex]);
else
com.AddParameter("@commands", "");
using (var reader = com.ExecuteReader())
{
if (reader.RecordsAffected > 0)
{
lst_groupList.Items.Add(txt_grpname.Text);
lst_inheritgrps.Items.Add(txt_grpname.Text);
txt_grpname.Text = "";
}
}
com.Parameters.Clear();
}
}
}
catch { }
}
private void btn_deletegroup_Click(object sender, EventArgs e)
{
try
{
using (var com = DB.CreateCommand())
{
com.CommandText = "DELETE FROM Grouplist WHERE GroupName = @groupname";
com.AddParameter("@groupname", lst_groupList.Items[lst_groupList.SelectedIndex]);
com.ExecuteNonQuery();
lst_groupList.Items.Remove(lst_groupList.Items[lst_groupList.SelectedIndex]);
lst_inheritgrps.Items.Clear();
com.CommandText =
"SELECT * FROM GroupList";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
lst_inheritgrps.Items.Add(reader.Get<string>("GroupName"));
}
}
}
}
catch { }
}
#endregion
#region FileOpenTabs
private void btn_OpenLocalDB_Click(object sender, EventArgs e)
{
dialog.ShowDialog();
}
void dialog_FileOk(object sender, CancelEventArgs e)
{
LoadSqliteDatabase(dialog.FileName);
tabControl.Visible = true;
}
private void btn_connect_Click(object sender, EventArgs e)
{
LoadMySqlDatabase(txt_hostname.Text, txt_port.Text, txt_dbname.Text, txt_username.Text, txt_password.Text);
tabControl.Visible = true;
}
#endregion
}
}

120
DBEditor/Main.resx Normal file
View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

22
DBEditor/Program.cs Normal file
View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TShockDBEditor;
namespace TShockDBEditor
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TShockDBEditor());
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsFormsApplication2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("WindowsFormsApplication2")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ffdb92d1-7f89-4f59-a671-22ea6cda680c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TShockDBEditor.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TShockDBEditor.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
DBEditor/Properties/Settings.Designer.cs generated Normal file
View file

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TShockDBEditor.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -14,7 +14,6 @@
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>

3
DBEditor/app.config Normal file
View file

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View file

@ -110,6 +110,7 @@ namespace TShockAPI
public static void InitCommands()
{
//When adding new perm in here, add new perm to CommandList in DBEditor
ChatCommands.Add(new Command("kick", Kick, "kick"));
ChatCommands.Add(new Command("ban", Ban, "ban"));
ChatCommands.Add(new Command("ban", BanIP, "banip"));
@ -330,7 +331,8 @@ namespace TShockAPI
args.Player.LoginAttempts++;
return;
}
} catch (Exception)
}
catch (Exception)
{
args.Player.SendMessage("There was an error processing your request. Maybe your account doesn't exist?", Color.Red);
return;
@ -392,7 +394,7 @@ namespace TShockAPI
else
{
args.Player.SendMessage("Account " + user.Name + " has already been registered.", Color.Green);
Log.ConsoleInfo(args.Player.Name + " failed to register an existing Account: " + user.Name);
Log.ConsoleInfo(args.Player.Name + " failed to register an existing Account: " + user.Name);
}
}
@ -432,7 +434,7 @@ namespace TShockAPI
{
if (namepass.Length == 2)
{
user.Name = namepass[0];
user.Name = namepass[0].ToLower();
user.Password = namepass[1];
user.Group = args.Parameters[2];
}
@ -730,7 +732,8 @@ namespace TShockAPI
args.Player.SendMessage("This command will also change all Worlds to reference this WorldID.");
args.Player.SendMessage("You must manually fix multi-world configurations.");
args.Player.SendMessage("To confirm this: /convert yes");
} else if (args.Parameters[0] == "yes")
}
else if (args.Parameters[0] == "yes")
{
TShock.Warps.ConvertDB();
TShock.Regions.ConvertDB();
@ -1098,7 +1101,7 @@ namespace TShockAPI
{
args.Player.SendMessage("Name reserved, use a different name", Color.Red);
}
else if (TShock.Warps.AddWarp(args.Player.TileX, args.Player.TileY, warpName, Main.worldName))
else if (TShock.Warps.AddWarp(args.Player.TileX, args.Player.TileY, warpName, Main.worldID.ToString()))
{
args.Player.SendMessage("Set warp " + warpName, Color.Yellow);
}
@ -1127,61 +1130,79 @@ namespace TShockAPI
private static void UseWarp(CommandArgs args)
{
if (args.Parameters.Count > 0)
if (args.Parameters.Count < 1)
{
if (args.Parameters[0].Equals("list"))
{
args.Player.SendMessage("Current Warps:", Color.Green);
int page = 1;
if (args.Parameters.Count > 1)
int.TryParse(args.Parameters[1], out page);
var sb = new StringBuilder();
List<Warp> Warps = TShock.Warps.ListAllWarps();
args.Player.SendMessage("Invalid syntax! Proper syntax: /warp [name] or /warp list <page>", Color.Red);
return;
}
if (Warps.Count > (15 * (page - 1)))
{
for (int j = (15 * (page - 1)); j < (15 * page); j++)
{
if (Warps[j].WorldWarpID == Main.worldName)
{
if (sb.Length != 0)
sb.Append(", ");
sb.Append(Warps[j].WarpName);
if (j == Warps.Count - 1)
{
args.Player.SendMessage(sb.ToString(), Color.Yellow);
break;
}
if ((j + 1) % 5 == 0)
{
args.Player.SendMessage(sb.ToString(), Color.Yellow);
sb.Clear();
}
}
}
}
if (Warps.Count > (15 * page))
{
args.Player.SendMessage(string.Format("Type /warp list {0} for more warps.", (page + 1)), Color.Yellow);
}
}
else
if (args.Parameters[0].Equals("list"))
{
//How many warps per page
const int pagelimit = 15;
//How many warps per line
const int perline = 5;
//Pages start at 0 but are displayed and parsed at 1
int page = 0;
if (args.Parameters.Count > 1)
{
string warpName = String.Join(" ", args.Parameters);
var warp = TShock.Warps.FindWarp(warpName);
if (warp.WarpPos != Vector2.Zero)
if (!int.TryParse(args.Parameters[1], out page) || page < 1)
{
if (args.Player.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3))
args.Player.SendMessage("Warped to " + warpName, Color.Yellow);
}
else
{
args.Player.SendMessage("Specified warp not found", Color.Red);
args.Player.SendMessage(string.Format("Invalid page number ({0})", page), Color.Red);
return;
}
page--; //Substract 1 as pages are parsed starting at 1 and not 0
}
var warps = TShock.Warps.ListAllWarps(Main.worldID.ToString());
//Check if they are trying to access a page that doesn't exist.
int pagecount = warps.Count / pagelimit;
if (page > pagecount)
{
args.Player.SendMessage(string.Format("Page number exceeds pages ({0}/{1})", page + 1, pagecount + 1), Color.Red);
return;
}
//Display the current page and the number of pages.
args.Player.SendMessage(string.Format("Current Warps ({0}/{1}):", page + 1, pagecount + 1), Color.Green);
//Add up to pagelimit names to a list
var nameslist = new List<string>();
for (int i = 0; i < pagelimit && i + (page * pagelimit) < warps.Count; i++)
{
nameslist.Add(warps[i].WarpName);
}
//convert the list to an array for joining
var names = nameslist.ToArray();
for (int i = 0; i < names.Length; i += perline)
{
args.Player.SendMessage(string.Join(", ", names, i, Math.Min(names.Length - i, perline)), Color.Yellow);
}
if (page < pagecount)
{
args.Player.SendMessage(string.Format("Type /warp list {0} for more warps.", (page + 1)), Color.Yellow);
}
}
else
args.Player.SendMessage("Invalid syntax! Proper syntax: /warp [name] or warp list", Color.Red);
{
string warpName = String.Join(" ", args.Parameters);
var warp = TShock.Warps.FindWarp(warpName);
if (warp.WarpPos != Vector2.Zero)
{
if (args.Player.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3))
args.Player.SendMessage("Warped to " + warpName, Color.Yellow);
}
else
{
args.Player.SendMessage("Specified warp not found", Color.Red);
}
}
}
#endregion Teleport Commands
@ -1444,7 +1465,7 @@ namespace TShockAPI
{
foreach (Region r in TShock.Regions.Regions)
{
args.Player.SendMessage(r.RegionName + ": P: " + r.DisableBuild + " X: " + r.RegionArea.X + " Y: " + r.RegionArea.Y + " W: " + r.RegionArea.Width + " H: " + r.RegionArea.Height );
args.Player.SendMessage(r.RegionName + ": P: " + r.DisableBuild + " X: " + r.RegionArea.X + " Y: " + r.RegionArea.Y + " W: " + r.RegionArea.Width + " H: " + r.RegionArea.Height);
foreach (int s in r.RegionAllowedIDs)
{
args.Player.SendMessage(r.RegionName + ": " + s);
@ -1508,7 +1529,7 @@ namespace TShockAPI
string regionName = String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1));
if (TShock.Regions.AddRegion(args.Player.TempArea.X, args.Player.TempArea.Y,
args.Player.TempArea.Width, args.Player.TempArea.Height,
regionName, Main.worldName))
regionName, Main.worldID.ToString()))
{
args.Player.TempArea = Rectangle.Empty;
args.Player.SendMessage("Set region " + regionName, Color.Yellow);
@ -1610,40 +1631,56 @@ namespace TShockAPI
}
case "list":
{
args.Player.SendMessage("Current Regions:", Color.Green);
int page = 1;
//How many regions per page
const int pagelimit = 15;
//How many regions per line
const int perline = 5;
//Pages start at 0 but are displayed and parsed at 1
int page = 0;
if (args.Parameters.Count > 1)
int.TryParse(args.Parameters[1], out page);
var sb = new StringBuilder();
List<Region> Regions = TShock.Regions.ListAllRegions();
if (Regions.Count > (15 * (page - 1)))
{
for (int j = (15 * (page - 1)); j < (15 * page); j++)
if (!int.TryParse(args.Parameters[1], out page) || page < 1)
{
if (Regions[j].RegionWorldID == Main.worldName)
{
if (sb.Length != 0)
sb.Append(", ");
sb.Append(Regions[j].RegionName);
if (j == Regions.Count - 1)
{
args.Player.SendMessage(sb.ToString(), Color.Yellow);
break;
}
if ((j + 1) % 5 == 0)
{
args.Player.SendMessage(sb.ToString(), Color.Yellow);
sb.Clear();
}
}
args.Player.SendMessage(string.Format("Invalid page number ({0})", page), Color.Red);
return;
}
page--; //Substract 1 as pages are parsed starting at 1 and not 0
}
if (Regions.Count > (15 * page))
var regions = TShock.Regions.ListAllRegions(Main.worldID.ToString());
//Check if they are trying to access a page that doesn't exist.
int pagecount = regions.Count / pagelimit;
if (page > pagecount)
{
args.Player.SendMessage(string.Format("Page number exceeds pages ({0}/{1})", page + 1, pagecount + 1), Color.Red);
return;
}
//Display the current page and the number of pages.
args.Player.SendMessage(string.Format("Current Regions ({0}/{1}):", page + 1, pagecount + 1), Color.Green);
//Add up to pagelimit names to a list
var nameslist = new List<string>();
for (int i = 0; i < pagelimit && i + (page * pagelimit) < regions.Count; i++)
{
nameslist.Add(regions[i].RegionName);
}
//convert the list to an array for joining
var names = nameslist.ToArray();
for (int i = 0; i < names.Length; i += perline)
{
args.Player.SendMessage(string.Join(", ", names, i, Math.Min(names.Length - i, perline)), Color.Yellow);
}
if (page < pagecount)
{
args.Player.SendMessage(string.Format("Type /region list {0} for more regions.", (page + 1)), Color.Yellow);
}
break;
}
case "help":
@ -1945,12 +1982,9 @@ namespace TShockAPI
args.Player.SendMessage("Missing item name/id", Color.Red);
return;
}
var items = Tools.GetItemByIdOrName(args.Parameters[0]);
args.Parameters.RemoveAt(0);
int itemAmount = 0;
if( args.Parameters.Count > 0 )
int.TryParse( args.Parameters[0], out itemAmount );
int.TryParse(args.Parameters[args.Parameters.Count - 1], out itemAmount);
var items = Tools.GetItemByIdOrName(args.Parameters[0]);
if (items.Count == 0)
{
args.Player.SendMessage("Invalid item type!", Color.Red);
@ -1966,7 +2000,7 @@ namespace TShockAPI
{
if (args.Player.InventorySlotAvailable || item.name.Contains("Coin"))
{
if( itemAmount == 0 || itemAmount > item.maxStack )
if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack;
args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount.ToString(), item.name));

View file

@ -28,101 +28,83 @@ namespace TShockAPI.DB
"CREATE TABLE IF NOT EXISTS GroupList (GroupName VARCHAR(255) PRIMARY, Commands VARCHAR(255), OrderBy VARCHAR(255));";
com.ExecuteNonQuery();
}
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
com.AddParameter("@groupname", "trustedadmin");
com.AddParameter("@commands", "admin,maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,ignoregriefdetection,usebanneditem,manageusers");
com.AddParameter("@order", "0");
com.ExecuteNonQuery();
com.Parameters.Clear();
//Add default groups
AddGroup("trustedadmin", "admin,maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,ignoregriefdetection,usebanneditem,manageusers");
AddGroup("admin", "newadmin,ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
AddGroup("newadmin", "default,kick,editspawn,reservedslot");
AddGroup("default", "canwater,canlava,warp,canbuild");
AddGroup("vip", "default,canwater,canlava,warp,canbuild,reservedslot");
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
com.AddParameter("@groupname", "admin");
com.AddParameter("@commands", "newadmin,ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere, managegroup");
com.AddParameter("@order", "0");
com.ExecuteNonQuery();
com.Parameters.Clear();
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
com.AddParameter("@groupname", "newadmin");
com.AddParameter("@commands", "default,kick,editspawn,reservedslot");
com.AddParameter("@order", "0");
com.ExecuteNonQuery();
com.Parameters.Clear();
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
com.AddParameter("@groupname", "default");
com.AddParameter("@commands", "canwater,canlava,warp,canbuild");
com.AddParameter("@order", "0");
com.ExecuteNonQuery();
com.Parameters.Clear();
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
com.AddParameter("@groupname", "vip");
com.AddParameter("@commands", "default,canwater,canlava,warp,canbuild,reservedslot");
com.AddParameter("@order", "0");
com.ExecuteNonQuery();
com.Parameters.Clear();
String file = Path.Combine(TShock.SavePath, "groups.txt");
if (File.Exists(file))
String file = Path.Combine(TShock.SavePath, "groups.txt");
if (File.Exists(file))
{
using (StreamReader sr = new StreamReader(file))
{
using (StreamReader sr = new StreamReader(file))
String line;
while ((line = sr.ReadLine()) != null)
{
String line;
while ((line = sr.ReadLine()) != null)
if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
{
if( !line.Equals("") && !line.Substring( 0,1 ).Equals( "#" ) )
String[] info = line.Split(' ');
String comms = "";
int size = info.Length;
int test = 0;
bool hasOrder = int.TryParse(info[info.Length - 1], out test);
if (hasOrder)
size = info.Length - 1;
for (int i = 1; i < size; i++)
{
if (!comms.Equals(""))
comms = comms + ",";
comms = comms + info[i].Trim();
}
using (var com = database.CreateCommand())
{
String[] info = line.Split(' ');
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
String comms = "";
int size = info.Length;
int test = 0;
bool hasOrder = int.TryParse(info[info.Length - 1], out test);
if( hasOrder )
size = info.Length - 1;
for (int i = 1; i < size; i++)
{
if (!comms.Equals(""))
comms = comms + ",";
comms = comms + info[i].Trim();
}
com.AddParameter("@groupname", info[0].Trim().ToString());
com.AddParameter("@groupname", info[0].Trim());
com.AddParameter("@commands", comms);
com.AddParameter("@order", hasOrder ? info[info.Length-1] : "0");
com.AddParameter("@order", hasOrder ? info[info.Length - 1] : "0");
com.ExecuteNonQuery();
com.Parameters.Clear();
}
}
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "groups.txt");
if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "groups.txt");
if (!Directory.Exists(path))
System.IO.Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
}
}
/// <summary>
/// Adds group with name and permissions if it does not exist.
/// </summary>
/// <param name="name">name of group</param>
/// <param name="commands">permissions</param>
public void AddGroup(string name, string commands)
{
using (var com = database.CreateCommand())
{
if (TShock.Config.StorageType.ToLower() == "sqlite")
com.CommandText =
"INSERT OR IGNORE INTO GroupList (GroupName, Commands, OrderBy) VALUES (@groupname, @commands, @order);";
else if (TShock.Config.StorageType.ToLower() == "mysql")
com.CommandText =
"INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands, OrderBy=@order;";
com.AddParameter("@groupname", name);
com.AddParameter("@commands", commands);
com.AddParameter("@order", "0");
com.ExecuteNonQuery();
}
}
@ -236,11 +218,6 @@ namespace TShockAPI.DB
groups = new List<Group>();
groups.Add(new SuperAdminGroup());
if (TShock.Users == null)
{
TShock.Users = new UserManager(TShock.DB);
}
try
{
using (var com = database.CreateCommand())
@ -256,7 +233,7 @@ namespace TShockAPI.DB
//Inherit Given commands
String[] commands = reader.Get<String>("Commands").Split(',');
for( int i = 0; i < commands.Length; i++ )
for (int i = 0; i < commands.Length; i++)
{
group.AddPermission(commands[i].Trim());
}

View file

@ -74,7 +74,7 @@ namespace TShockAPI.DB
switch (reader.NodeType)
{
case XmlNodeType.Element:
switch( reader.Name )
switch (reader.Name)
{
case "ProtectedRegion":
name = "";
@ -96,22 +96,22 @@ namespace TShockAPI.DB
case "Point1X":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
int.TryParse( reader.Value, out x1 );
int.TryParse(reader.Value, out x1);
break;
case "Point1Y":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
int.TryParse(reader.Value, out y1);
int.TryParse(reader.Value, out y1);
break;
case "Point2X":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
int.TryParse(reader.Value, out x2);
int.TryParse(reader.Value, out x2);
break;
case "Point2Y":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
int.TryParse(reader.Value, out y2);
int.TryParse(reader.Value, out y2);
break;
case "Protected":
while (reader.NodeType != XmlNodeType.Text)
@ -120,10 +120,11 @@ namespace TShockAPI.DB
{
prot = 0;
}
else{
else
{
prot = 1;
}
break;
break;
case "WorldName":
while (reader.NodeType != XmlNodeType.Text)
reader.Read();
@ -144,18 +145,19 @@ namespace TShockAPI.DB
ips[i] = reader.Value;
}
ipstr = "";
for( int i = 0; i < ips.Length; i++ )
for (int i = 0; i < ips.Length; i++)
{
try
{
if (ipstr != "")
ipstr += ",";
ipstr += TShock.Users.GetUserID(ips[i]);
} catch (Exception e)
}
catch (Exception)
{
Log.Error("An IP address failed to import. It wasn't a user in the new user system.");
}
}
}
@ -166,7 +168,7 @@ namespace TShockAPI.DB
com.AddParameter("@tx", x1);
com.AddParameter("@ty", y1);
com.AddParameter("@width", x2);
com.AddParameter("@height",y2);
com.AddParameter("@height", y2);
com.AddParameter("@name", name);
com.AddParameter("@worldid", world);
com.AddParameter("@userids", ipstr);
@ -199,8 +201,8 @@ namespace TShockAPI.DB
File.Delete(file2);
//File.Move(file, file2);
}
ReloadAllRegions();
if (updates > 0)
ReloadAllRegions();
}
}
@ -224,7 +226,7 @@ namespace TShockAPI.DB
{
Log.Error(ex.ToString());
}
}
}
public void ReloadAllRegions()
{
@ -248,8 +250,8 @@ namespace TShockAPI.DB
string name = DbExt.Get<string>(reader, "RegionName");
System.Console.WriteLine(MergedIDs);
string[] SplitIDs = MergedIDs.Split(',');
System.Console.WriteLine(SplitIDs.Length);
Region r = new Region(new Rectangle(X1, Y1, width, height), name, Protected, Main.worldName);
Region r = new Region(new Rectangle(X1, Y1, width, height), name, Protected, Main.worldID.ToString());
r.RegionAllowedIDs = new int[SplitIDs.Length];
try
{
@ -262,7 +264,8 @@ namespace TShockAPI.DB
//System.Console.WriteLine(SplitIDs[i]);
r.RegionAllowedIDs[i] = Convert.ToInt32(SplitIDs[i]);
}
} catch (Exception e)
}
catch (Exception e)
{
Log.Error("Your database contains invalid UserIDs (they should be ints).");
Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
@ -321,7 +324,7 @@ namespace TShockAPI.DB
{
com.CommandText = "DELETE FROM Regions WHERE RegionName=@name AND WorldID=@worldid";
com.AddParameter("@name", name.ToLower());
com.AddParameter("@worldid", Main.worldName);
com.AddParameter("@worldid", Main.worldID.ToString());
com.ExecuteNonQuery();
ReloadAllRegions();
return true;
@ -343,7 +346,7 @@ namespace TShockAPI.DB
com.CommandText = "UPDATE Regions SET Protected=@bool WHERE RegionName=@name AND WorldID=@worldid";
com.AddParameter("@name", name);
com.AddParameter("@bool", state ? 1 : 0);
com.AddParameter("@worldid", Main.worldName);
com.AddParameter("@worldid", Main.worldID.ToString());
int q = com.ExecuteNonQuery();
ReloadAllRegions();
return (q > 0);
@ -374,7 +377,7 @@ namespace TShockAPI.DB
public bool InArea(int x, int y)
{
foreach(Region region in Regions)
foreach (Region region in Regions)
{
if (x >= region.RegionArea.Left && x <= region.RegionArea.Right &&
y >= region.RegionArea.Top && y <= region.RegionArea.Bottom &&
@ -417,7 +420,7 @@ namespace TShockAPI.DB
{
com.CommandText = "SELECT * FROM Regions WHERE RegionName=@name AND WorldID=@worldid";
com.AddParameter("@name", regionName);
com.AddParameter("@worldid", Main.worldName);
com.AddParameter("@worldid", Main.worldID.ToString());
string MergedIDs = string.Empty;
using (var reader = com.ExecuteReader())
{
@ -433,12 +436,13 @@ namespace TShockAPI.DB
com.CommandText = "UPDATE Regions SET UserIds=@ids WHERE RegionName=@name AND WorldID=@worldid";
com.AddParameter("@ids", MergedIDs);
com.AddParameter("@name", regionName);
com.AddParameter("@worldid", Main.worldName);
com.AddParameter("@worldid", Main.worldID.ToString());
if (com.ExecuteNonQuery() > 0)
{
ReloadAllRegions();
return true;
} else
}
else
{
return false;
}
@ -451,19 +455,24 @@ namespace TShockAPI.DB
}
}
public List<Region> ListAllRegions()
/// <summary>
/// Gets all the regions names from world
/// </summary>
/// <param name="worldid">World name to get regions from</param>
/// <returns>List of regions with only their names</returns>
public List<Region> ListAllRegions(string worldid)
{
List<Region> Regions = new List<Region>();
var regions = new List<Region>();
try
{
using (var com = database.CreateCommand())
{
com.CommandText = "SELECT * FROM Regions";
com.CommandText = "SELECT RegionName FROM Regions WHERE WorldID=@worldid";
com.AddParameter("@worldid", worldid);
using (var reader = com.ExecuteReader())
{
while (reader.Read())
Regions.Add(new Region(new Rectangle(reader.Get<int>("X1"), reader.Get<int>("Y1"), reader.Get<int>("height"), reader.Get<int>("width")), reader.Get<string>("RegionName"), reader.Get<int>("Protected"), reader.Get<string>("WorldID")));
reader.Close();
regions.Add(new Region { RegionName = reader.Get<string>("RegionName") });
}
}
}
@ -471,7 +480,7 @@ namespace TShockAPI.DB
{
Log.Error(ex.ToString());
}
return Regions;
return regions;
}
}

View file

@ -116,7 +116,7 @@ namespace TShockAPI.DB
break;
}
}
}
reader.Close();
String path = Path.Combine(TShock.SavePath, "old_configs");
@ -145,7 +145,7 @@ namespace TShockAPI.DB
{
Log.Error(ex.ToString());
}
}
}
public bool AddWarp(int x, int y, string name, string worldid)
{
@ -177,7 +177,7 @@ namespace TShockAPI.DB
{
com.CommandText = "DELETE FROM Warps WHERE WarpName=@name AND WorldID=@worldid";
com.AddParameter("@name", name.ToLower());
com.AddParameter("@worldid", Main.worldName);
com.AddParameter("@worldid", Main.worldID.ToString());
com.ExecuteNonQuery();
return true;
}
@ -196,13 +196,13 @@ namespace TShockAPI.DB
using (var com = database.CreateCommand())
{
com.CommandText = "SELECT * FROM Warps WHERE WarpName=@name AND WorldID=@worldid";
com.AddParameter("@name", name.ToLower());
com.AddParameter("@worldid", Main.worldName);
com.AddParameter("@name", name);
com.AddParameter("@worldid", Main.worldID.ToString());
using (var reader = com.ExecuteReader())
{
if (reader.Read())
{
return new Warp(new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID"));
return new Warp(new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID"));
}
reader.Close();
}
@ -215,20 +215,24 @@ namespace TShockAPI.DB
return new Warp();
}
public List<Warp> ListAllWarps()
/// <summary>
/// Gets all the warps names from world
/// </summary>
/// <param name="worldid">World name to get warps from</param>
/// <returns>List of warps with only their names</returns>
public List<Warp> ListAllWarps(string worldid)
{
List<Warp> Warps = new List<Warp>();
var warps = new List<Warp>();
try
{
using (var com = database.CreateCommand())
{
com.CommandText = "SELECT * FROM Warps";
com.CommandText = "SELECT WarpName FROM Warps WHERE WorldID=@worldid";
com.AddParameter("@worldid", worldid);
using (var reader = com.ExecuteReader())
{
while (reader.Read())
Warps.Add(new Warp(new Vector2(reader.Get<int>("X"), reader.Get<int>("Y")), reader.Get<string>("WarpName"), reader.Get<string>("WorldID")));
reader.Close();
warps.Add(new Warp { WarpName = reader.Get<string>("WarpName") });
}
}
}
@ -236,7 +240,7 @@ namespace TShockAPI.DB
{
Log.Error(ex.ToString());
}
return Warps;
return warps;
}
}

View file

@ -35,5 +35,6 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.2.0723")]
[assembly: AssemblyFileVersion("3.0.2.0723")]
[assembly: AssemblyVersion("3.1.3.0723")]
[assembly: AssemblyFileVersion("3.1.3.0723")]

View file

@ -101,22 +101,7 @@ namespace TShockAPI
public override void Initialize()
{
if (!Directory.Exists(SavePath))
{
Directory.CreateDirectory(SavePath);
}
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
{
Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
File.Delete(Path.Combine(SavePath, "tshock.pid"));
}
TShockProcess = Process.GetCurrentProcess();
int pid = TShockProcess.Id;
TextWriter tw = new StreamWriter(Path.Combine(SavePath, "tshock.pid"));
tw.Write(pid);
tw.Close();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#if DEBUG
Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false);
@ -125,17 +110,19 @@ namespace TShockAPI
#endif
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
{
Log.ConsoleInfo("TShock was improperly shut down. Deleting invalid pid file...");
File.Delete(Path.Combine(SavePath, "tshock.pid"));
}
File.WriteAllText(Path.Combine(SavePath, "tshock.pid"), Process.GetCurrentProcess().Id.ToString());
ConfigFile.ConfigRead += OnConfigRead;
FileTools.SetupConfig();
HandleCommandLine(Environment.GetCommandLineArgs());
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
FileTools.SetupConfig();
if (Config.StorageType.ToLower() == "sqlite")
{
string sql = Path.Combine(SavePath, "tshock.sqlite");
@ -168,6 +155,9 @@ namespace TShockAPI
throw new Exception("Invalid storage type");
}
Backups = new BackupManager(Path.Combine(SavePath, "backups"));
Backups.KeepFor = Config.BackupKeepFor;
Backups.Interval = Config.BackupInterval;
Bans = new BanManager(DB);
Warps = new WarpManager(DB);
Users = new UserManager(DB);
@ -727,8 +717,11 @@ namespace TShockAPI
NPC.defaultSpawnRate = file.DefaultSpawnRate;
Main.autoSave = file.AutoSave;
Backups.KeepFor = file.BackupKeepFor;
Backups.Interval = file.BackupInterval;
if (Backups != null)
{
Backups.KeepFor = file.BackupKeepFor;
Backups.Interval = file.BackupInterval;
}
if (!OverridePort)
{
Netplay.serverPort = file.ServerPort;

View file

@ -48,19 +48,22 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Community.CsharpSqlite.SQLiteClient">
<HintPath>SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
<Reference Include="Community.CsharpSqlite.SQLiteClient, Version=3.7.5.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>SqlBins\MySql.Data.dll</HintPath>
<HintPath>..\SqlBins\MySql.Data.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>SqlBins\MySql.Web.dll</HintPath>
<HintPath>..\SqlBins\MySql.Web.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>.\Newtonsoft.Json.dll</HintPath>
@ -72,14 +75,19 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TerrariaServer">
<HintPath>TerrariaServerBins\TerrariaServer.exe</HintPath>
<Reference Include="TerrariaServer, Version=1.0.4.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<ExecutableExtension>.exe</ExecutableExtension>
<HintPath>..\TerrariaServerBins\TerrariaServer.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="TerrariaServerAPI">
<HintPath>TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
<Reference Include="TerrariaServerAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
</Reference>
<Reference Include="XNAHelpers">
<HintPath>TerrariaServerBins\XNAHelpers.dll</HintPath>
<Reference Include="XNAHelpers, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TerrariaServerBins\XNAHelpers.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View file

@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockDBEditor", "DBEditor\TShockDBEditor.csproj", "{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{F3742F51-D7BF-4754-A68A-CD944D2A21FF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}"
@ -35,16 +37,16 @@ Global
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Debug|x86.ActiveCfg = Debug|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Any CPU.Build.0 = Release|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F3742F51-D7BF-4754-A68A-CD944D2A21FF}.Release|x86.ActiveCfg = Release|Any CPU
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|Any CPU.ActiveCfg = Debug|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|Mixed Platforms.Build.0 = Debug|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|x86.ActiveCfg = Debug|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|x86.Build.0 = Debug|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|Any CPU.ActiveCfg = Release|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|Mixed Platforms.ActiveCfg = Release|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|Mixed Platforms.Build.0 = Release|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|x86.ActiveCfg = Release|x86
{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -14,6 +14,21 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -34,10 +49,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Community.CsharpSqlite">
<HintPath>..\TShockAPI\SqlBins\Community.CsharpSqlite.dll</HintPath>
<HintPath>..\SqlBins\Community.CsharpSqlite.dll</HintPath>
</Reference>
<Reference Include="Community.CsharpSqlite.SQLiteClient">
<HintPath>..\TShockAPI\SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
<HintPath>..\SqlBins\Community.CsharpSqlite.SQLiteClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
@ -45,10 +60,10 @@
<HintPath>..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\Microsoft.Xna.Framework\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\TShockAPI\SqlBins\MySql.Data.dll</HintPath>
<HintPath>..\SqlBins\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="MySql.Web">
<HintPath>..\TShockAPI\SqlBins\MySql.Web.dll</HintPath>
<HintPath>..\SqlBins\MySql.Web.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
@ -58,11 +73,11 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="TerrariaServerAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TShockAPI\TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
<HintPath>..\TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
</Reference>
<Reference Include="XNAHelpers, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\TShockAPI\TerrariaServerBins\XNAHelpers.dll</HintPath>
<HintPath>..\TerrariaServerBins\XNAHelpers.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -93,6 +108,28 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.