mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
Style: less var
This commit is contained in:
parent
1847c0d553
commit
d60092502b
@ -33,7 +33,7 @@ namespace MCGalaxy.Bots {
|
|||||||
if (!File.Exists("extra/bots.json")) return;
|
if (!File.Exists("extra/bots.json")) return;
|
||||||
lock (locker) {
|
lock (locker) {
|
||||||
string json = File.ReadAllText("extra/bots.json");
|
string json = File.ReadAllText("extra/bots.json");
|
||||||
var bots = JsonConvert.DeserializeObject<BotProperties[]>(json);
|
BotProperties[] bots = JsonConvert.DeserializeObject<BotProperties[]>(json);
|
||||||
SavedBots = new List<BotProperties>(bots);
|
SavedBots = new List<BotProperties>(bots);
|
||||||
|
|
||||||
foreach (BotProperties bot in SavedBots) {
|
foreach (BotProperties bot in SavedBots) {
|
||||||
|
@ -58,7 +58,7 @@ namespace MCGalaxy.Bots {
|
|||||||
Player.Message(p, "Could not find instruction \"" + action + "\""); return;
|
Player.Message(p, "Could not find instruction \"" + action + "\""); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var perms = CommandOtherPerms.Find("botset");
|
CommandOtherPerms.OtherPerms perms = CommandOtherPerms.Find("botset");
|
||||||
LevelPermission killPerm = (LevelPermission)perms.Permission;
|
LevelPermission killPerm = (LevelPermission)perms.Permission;
|
||||||
if (ins.Name.CaselessEq("kill") && p.Rank < killPerm) {
|
if (ins.Name.CaselessEq("kill") && p.Rank < killPerm) {
|
||||||
Formatter.MessageNeedMinPerm(p, "toggle a bot's killer instinct.", killPerm);
|
Formatter.MessageNeedMinPerm(p, "toggle a bot's killer instinct.", killPerm);
|
||||||
|
@ -16,7 +16,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TokenParser = System.Func<MCGalaxy.Player, string>;
|
|
||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
public static class ChatTokens {
|
public static class ChatTokens {
|
||||||
@ -54,7 +53,8 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static Dictionary<string, TokenParser> standardTokens = new Dictionary<string, TokenParser> {
|
internal static Dictionary<string, Func<Player, string>> standardTokens
|
||||||
|
= new Dictionary<string, Func<Player, string>> {
|
||||||
{ "$name", p => p.DisplayName == null ? null :
|
{ "$name", p => p.DisplayName == null ? null :
|
||||||
(Server.dollarNames ? "$" : "") + Colors.StripColors(p.DisplayName) },
|
(Server.dollarNames ? "$" : "") + Colors.StripColors(p.DisplayName) },
|
||||||
{ "$truename", p => p.truename == null ? null :
|
{ "$truename", p => p.truename == null ? null :
|
||||||
|
@ -112,10 +112,13 @@ namespace MCGalaxy {
|
|||||||
input = IrcTwoColorCode.Replace(input, "$1");
|
input = IrcTwoColorCode.Replace(input, "$1");
|
||||||
StringBuilder sb = new StringBuilder(input);
|
StringBuilder sb = new StringBuilder(input);
|
||||||
|
|
||||||
foreach (var kvp in ircColors)
|
foreach (KeyValuePair<string, string> kvp in ircColors) {
|
||||||
sb.Replace(kvp.Value, kvp.Key);
|
sb.Replace(kvp.Value, kvp.Key);
|
||||||
foreach (var kvp in ircSingleColors)
|
}
|
||||||
|
foreach (KeyValuePair<string, string> kvp in ircSingleColors) {
|
||||||
sb.Replace(kvp.Value, kvp.Key);
|
sb.Replace(kvp.Value, kvp.Key);
|
||||||
|
}
|
||||||
|
|
||||||
sb.Replace("\u0003", white); // color reset
|
sb.Replace("\u0003", white); // color reset
|
||||||
sb.Replace("\u000f", white); // reset
|
sb.Replace("\u000f", white); // reset
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
@ -132,8 +135,9 @@ namespace MCGalaxy {
|
|||||||
sb.Replace("&" + col.Code, "&" + col.Fallback);
|
sb.Replace("&" + col.Code, "&" + col.Fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var kvp in ircColors)
|
foreach (KeyValuePair<string, string> kvp in ircColors) {
|
||||||
sb.Replace(kvp.Key, kvp.Value);
|
sb.Replace(kvp.Key, kvp.Value);
|
||||||
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<string> commandNames() {
|
public List<string> commandNames() {
|
||||||
var tempList = new List<string>(commands.Count);
|
List<string> tempList = new List<string>(commands.Count);
|
||||||
commands.ForEach(cmd => tempList.Add(cmd.name));
|
commands.ForEach(cmd => tempList.Add(cmd.name));
|
||||||
return tempList;
|
return tempList;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ namespace fNbt {
|
|||||||
|
|
||||||
static int Swap(int v) {
|
static int Swap(int v) {
|
||||||
unchecked {
|
unchecked {
|
||||||
var v2 = (uint)v;
|
uint v2 = (uint)v;
|
||||||
return
|
return
|
||||||
(int)
|
(int)
|
||||||
((v2 >> 24) & 0x000000FF | (v2 >> 8) & 0x0000FF00 | (v2 << 8) & 0x00FF0000 |
|
((v2 >> 24) & 0x000000FF | (v2 >> 8) & 0x0000FF00 | (v2 << 8) & 0x00FF0000 |
|
||||||
@ -446,8 +446,8 @@ namespace fNbt {
|
|||||||
if (header != (int)NbtTagType.Compound)
|
if (header != (int)NbtTagType.Compound)
|
||||||
throw new NbtFormatException("Given NBT stream does not start with a TAG_Compound");
|
throw new NbtFormatException("Given NBT stream does not start with a TAG_Compound");
|
||||||
|
|
||||||
var reader = new NbtBinaryReader(buffered, true);
|
NbtBinaryReader reader = new NbtBinaryReader(buffered, true);
|
||||||
var rootCompound = new NbtCompound(reader.ReadString());
|
NbtCompound rootCompound = new NbtCompound(reader.ReadString());
|
||||||
rootCompound.ReadTag(reader);
|
rootCompound.ReadTag(reader);
|
||||||
RootTag = rootCompound;
|
RootTag = rootCompound;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
for (int i = 0; i < MAX_RETRIES; i++) {
|
for (int i = 0; i < MAX_RETRIES; i++) {
|
||||||
try {
|
try {
|
||||||
var req = WebRequest.Create(beat.URL) as HttpWebRequest;
|
HttpWebRequest req = WebRequest.Create(beat.URL) as HttpWebRequest;
|
||||||
req.Method = "POST";
|
req.Method = "POST";
|
||||||
req.ContentType = "application/x-www-form-urlencoded";
|
req.ContentType = "application/x-www-form-urlencoded";
|
||||||
req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
|
req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
|
||||||
@ -84,12 +84,12 @@ namespace MCGalaxy {
|
|||||||
req.ContentLength = data.Length;
|
req.ContentLength = data.Length;
|
||||||
beat.OnRequest(req);
|
beat.OnRequest(req);
|
||||||
|
|
||||||
using (var w = req.GetRequestStream()) {
|
using (Stream w = req.GetRequestStream()) {
|
||||||
w.Write(data, 0, data.Length);
|
w.Write(data, 0, data.Length);
|
||||||
if (Server.logbeat) Server.s.Log("Beat " + beat + " was sent");
|
if (Server.logbeat) Server.s.Log("Beat " + beat + " was sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var r = new StreamReader(req.GetResponse().GetResponseStream())) {
|
using (StreamReader r = new StreamReader(req.GetResponse().GetResponseStream())) {
|
||||||
string read = r.ReadToEnd().Trim();
|
string read = r.ReadToEnd().Trim();
|
||||||
beat.OnResponse(read);
|
beat.OnResponse(read);
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ namespace MCGalaxy {
|
|||||||
void HandlePlayerClicked(byte[] packet) {
|
void HandlePlayerClicked(byte[] packet) {
|
||||||
if (OnPlayerClick == null) return;
|
if (OnPlayerClick == null) return;
|
||||||
|
|
||||||
var Button = (MouseButton)packet[1];
|
MouseButton Button = (MouseButton)packet[1];
|
||||||
var Action = (MouseAction)packet[2];
|
MouseAction Action = (MouseAction)packet[2];
|
||||||
ushort Yaw = NetUtils.ReadU16(packet, 3);
|
ushort Yaw = NetUtils.ReadU16(packet, 3);
|
||||||
ushort Pitch = NetUtils.ReadU16(packet, 5);
|
ushort Pitch = NetUtils.ReadU16(packet, 5);
|
||||||
byte EntityID = packet[7];
|
byte EntityID = packet[7];
|
||||||
@ -91,7 +91,7 @@ namespace MCGalaxy {
|
|||||||
ushort Z = NetUtils.ReadU16(packet, 12);
|
ushort Z = NetUtils.ReadU16(packet, 12);
|
||||||
byte Face = packet[14];
|
byte Face = packet[14];
|
||||||
|
|
||||||
var face = TargetBlockFace.None;
|
TargetBlockFace face = TargetBlockFace.None;
|
||||||
if (Face < (byte)face)
|
if (Face < (byte)face)
|
||||||
face = (TargetBlockFace)Face;
|
face = (TargetBlockFace)Face;
|
||||||
OnPlayerClick(this, Button, Action, Yaw, Pitch, EntityID, X, Y, Z, face);
|
OnPlayerClick(this, Button, Action, Yaw, Pitch, EntityID, X, Y, Z, face);
|
||||||
|
@ -150,7 +150,7 @@ namespace MCGalaxy {
|
|||||||
public static void SendChatFrom(Player from, string message, bool showname) {
|
public static void SendChatFrom(Player from, string message, bool showname) {
|
||||||
if (from == null) return;
|
if (from == null) return;
|
||||||
if (Last50Chat.Count == 50) Last50Chat.RemoveAt(0);
|
if (Last50Chat.Count == 50) Last50Chat.RemoveAt(0);
|
||||||
var chatmessage = new ChatMessage();
|
ChatMessage chatmessage = new ChatMessage();
|
||||||
chatmessage.text = message;
|
chatmessage.text = message;
|
||||||
chatmessage.username = from.color + from.name;
|
chatmessage.username = from.color + from.name;
|
||||||
chatmessage.time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
|
chatmessage.time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");
|
||||||
|
@ -68,7 +68,7 @@ namespace MCGalaxy {
|
|||||||
syntax = String.Format(syntax, cmdName.Capitalize(), cmdName);
|
syntax = String.Format(syntax, cmdName.Capitalize(), cmdName);
|
||||||
|
|
||||||
string path = SourceDir + "Cmd" + cmdName + Ext;
|
string path = SourceDir + "Cmd" + cmdName + Ext;
|
||||||
using (var sw = new StreamWriter(path))
|
using (StreamWriter sw = new StreamWriter(path))
|
||||||
sw.WriteLine(syntax);
|
sw.WriteLine(syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace MCGalaxy.Core {
|
|||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
XmlDocument desc = new XmlDocument();
|
XmlDocument desc = new XmlDocument();
|
||||||
var request = WebRequest.CreateDefault(new Uri(resp));
|
WebRequest request = WebRequest.CreateDefault(new Uri(resp));
|
||||||
desc.Load(request.GetResponse().GetResponseStream());
|
desc.Load(request.GetResponse().GetResponseStream());
|
||||||
XmlNamespaceManager nsMgr = new XmlNamespaceManager(desc.NameTable);
|
XmlNamespaceManager nsMgr = new XmlNamespaceManager(desc.NameTable);
|
||||||
nsMgr.AddNamespace("tns", "urn:schemas-upnp-org:device-1-0");
|
nsMgr.AddNamespace("tns", "urn:schemas-upnp-org:device-1-0");
|
||||||
|
@ -189,7 +189,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void FixupOldPerms() {
|
static void FixupOldPerms() {
|
||||||
var perms = SrvProperties.oldPerms;
|
SrvProperties.OldPerms perms = SrvProperties.oldPerms;
|
||||||
Server.opchatperm = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator);
|
Server.opchatperm = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator);
|
||||||
Server.adminchatperm = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin);
|
Server.adminchatperm = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin);
|
||||||
if (perms.clearPerm == -1 && perms.nextPerm == -1 && perms.viewPerm == -1
|
if (perms.clearPerm == -1 && perms.nextPerm == -1 && perms.viewPerm == -1
|
||||||
|
@ -57,7 +57,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
Player.Message(p, "%TExtra permissions:");
|
Player.Message(p, "%TExtra permissions:");
|
||||||
for (int i = 0; i < addPerms.Length; i++) {
|
for (int i = 0; i < addPerms.Length; i++) {
|
||||||
var extra = CommandOtherPerms.Find(cmd, i + 1);
|
CommandOtherPerms.OtherPerms extra = CommandOtherPerms.Find(cmd, i + 1);
|
||||||
LevelPermission perm = (LevelPermission)extra.Permission;
|
LevelPermission perm = (LevelPermission)extra.Permission;
|
||||||
Player.Message(p, "{0}) {1}%S{2}", i + 1, Group.GetColoredName(perm), extra.Description);
|
Player.Message(p, "{0}) {1}%S{2}", i + 1, Group.GetColoredName(perm), extra.Description);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user