Add support for prefixes in /item and /give
This commit is contained in:
parent
3f0d82e5be
commit
a2a1486ea1
3 changed files with 73 additions and 20 deletions
|
|
@ -309,10 +309,12 @@ namespace TShockAPI
|
|||
{
|
||||
return (id > 0 && id < Main.maxBuffs) ? Main.buffName[id] : "null";
|
||||
}
|
||||
|
||||
public string GetBuffDescription(int id)
|
||||
{
|
||||
return (id > 0 && id < Main.maxBuffs) ? Main.buffTip[id] : "null";
|
||||
}
|
||||
|
||||
public List<int> GetBuffByName(string name)
|
||||
{
|
||||
for (int i = 1; i < Main.maxBuffs; i++)
|
||||
|
|
@ -329,6 +331,51 @@ namespace TShockAPI
|
|||
return found;
|
||||
}
|
||||
|
||||
public string GetPrefixById(int id)
|
||||
{
|
||||
var item = new Item();
|
||||
item.SetDefaults(0);
|
||||
item.prefix = (byte)id;
|
||||
item.AffixName();
|
||||
return item.name.Trim();
|
||||
}
|
||||
|
||||
public List<int> GetPrefixByName(string name)
|
||||
{
|
||||
Item item = new Item();
|
||||
for (int i = 1; i < 83; i++)
|
||||
{
|
||||
item.prefix = (byte) i;
|
||||
item.AffixName();
|
||||
if (item.name.Trim() == name)
|
||||
return new List<int> { i };
|
||||
}
|
||||
var found = new List<int>();
|
||||
for (int i = 1; i < 83; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
item.prefix = (byte) i;
|
||||
if (item.name.Trim().ToLower() == name.ToLower())
|
||||
return new List<int> { i };
|
||||
if (item.name.Trim().ToLower().StartsWith(name.ToLower()))
|
||||
found.Add(i);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public List<int> GetPrefixByIdOrName(string idOrName)
|
||||
{
|
||||
int type = -1;
|
||||
if (int.TryParse(idOrName, out type) && type > 0 && type < 84)
|
||||
{
|
||||
return new List<int> {type};
|
||||
}
|
||||
return GetPrefixByName(idOrName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kicks all player from the server without checking for immunetokick permission.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue