mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Fix being able to send opchat messages with no contents, prefer explicit delegates to Func
This commit is contained in:
parent
9c8c4fc72e
commit
3c26d97c07
@ -76,6 +76,8 @@ namespace MCGalaxy {
|
|||||||
string name = p == null ? "(console)" : p.name;
|
string name = p == null ? "(console)" : p.name;
|
||||||
string format = "To " + group + " &f-{0}&f- {1}";
|
string format = "To " + group + " &f-{0}&f- {1}";
|
||||||
|
|
||||||
|
if (message == "") { Player.Message(p, "No message to send."); return; }
|
||||||
|
|
||||||
Chat.MessageWhere(format,
|
Chat.MessageWhere(format,
|
||||||
pl => (p == pl || pl.Rank >= perm) && Chat.NotIgnoring(p, pl),
|
pl => (p == pl || pl.Rank >= perm) && Chat.NotIgnoring(p, pl),
|
||||||
displayName, message);
|
displayName, message);
|
||||||
|
@ -54,8 +54,8 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static Dictionary<string, Func<Player, string>> standardTokens
|
internal static Dictionary<string, StringFormatter<Player>> standardTokens
|
||||||
= new Dictionary<string, Func<Player, string>> {
|
= new Dictionary<string, StringFormatter<Player>> {
|
||||||
{ "$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 :
|
||||||
|
@ -133,8 +133,10 @@ namespace MCGalaxy.Commands.World {
|
|||||||
|
|
||||||
|
|
||||||
delegate void BoolSetter(ref BlockProps props);
|
delegate void BoolSetter(ref BlockProps props);
|
||||||
|
delegate bool BoolGetter(BlockProps props);
|
||||||
|
|
||||||
static void Toggle(Player p, BlockProps[] scope, ExtBlock block, string type,
|
static void Toggle(Player p, BlockProps[] scope, ExtBlock block, string type,
|
||||||
BoolSetter setter, Func<BlockProps, bool> getter) {
|
BoolSetter setter, BoolGetter getter) {
|
||||||
BlockProps props = scope[block.Index];
|
BlockProps props = scope[block.Index];
|
||||||
setter(ref props);
|
setter(ref props);
|
||||||
scope[block.Index] = props;
|
scope[block.Index] = props;
|
||||||
|
@ -20,15 +20,23 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace MCGalaxy.DB {
|
namespace MCGalaxy.DB {
|
||||||
|
|
||||||
|
/// <summary> Retrieves a title for a column. </summary>
|
||||||
|
/// <remarks> Title is displayed on a line before the values of that column. </remarks>
|
||||||
|
public delegate string TopStatTitle();
|
||||||
|
|
||||||
|
/// <summary> Formats a value in a column. </summary>
|
||||||
|
public delegate string TopStatFormatter(string input);
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Outputs ordered stats from a column in a database table. </summary>
|
/// <summary> Outputs ordered stats from a column in a database table. </summary>
|
||||||
public sealed class TopStat {
|
public sealed class TopStat {
|
||||||
|
|
||||||
public readonly string Identifier, Table, Column, OrderBy;
|
public readonly string Identifier, Table, Column, OrderBy;
|
||||||
public readonly Func<string> Title;
|
public readonly TopStatTitle Title;
|
||||||
public readonly Func<string, string> Formatter;
|
public readonly TopStatFormatter Formatter;
|
||||||
|
|
||||||
public TopStat(string identifier, string table, string col, Func<string> title,
|
public TopStat(string identifier, string table, string col, TopStatTitle title,
|
||||||
Func<string, string> formatter, bool ascending = false, string orderBy = null) {
|
TopStatFormatter formatter, bool ascending = false, string orderBy = null) {
|
||||||
Identifier = identifier;
|
Identifier = identifier;
|
||||||
Table = table;
|
Table = table;
|
||||||
Column = col;
|
Column = col;
|
||||||
|
@ -22,6 +22,8 @@ using MCGalaxy.Drawing.Ops;
|
|||||||
|
|
||||||
namespace MCGalaxy.Drawing {
|
namespace MCGalaxy.Drawing {
|
||||||
|
|
||||||
|
public delegate void PixelGetterCallback(Pixel pixel, DrawOpOutput output);
|
||||||
|
|
||||||
public sealed class PixelGetter : IDisposable {
|
public sealed class PixelGetter : IDisposable {
|
||||||
|
|
||||||
Bitmap bmp;
|
Bitmap bmp;
|
||||||
@ -41,14 +43,12 @@ namespace MCGalaxy.Drawing {
|
|||||||
data = bmp.LockBits(r, ImageLockMode.ReadOnly, bmp.PixelFormat);
|
data = bmp.LockBits(r, ImageLockMode.ReadOnly, bmp.PixelFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Iterate(DrawOpOutput output,
|
public void Iterate(DrawOpOutput output, PixelGetterCallback callback) {
|
||||||
Action<Pixel, DrawOpOutput> callback) {
|
|
||||||
if (data == null) IterateSlow(output, callback);
|
if (data == null) IterateSlow(output, callback);
|
||||||
else IterateFast(output, callback);
|
else IterateFast(output, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe void IterateFast(DrawOpOutput output,
|
unsafe void IterateFast(DrawOpOutput output, PixelGetterCallback callback) {
|
||||||
Action<Pixel, DrawOpOutput> callback) {
|
|
||||||
Pixel pixel;
|
Pixel pixel;
|
||||||
int width = bmp.Width, height = bmp.Height;
|
int width = bmp.Width, height = bmp.Height;
|
||||||
byte* scan0 = (byte*)data.Scan0;
|
byte* scan0 = (byte*)data.Scan0;
|
||||||
@ -69,8 +69,7 @@ namespace MCGalaxy.Drawing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IterateSlow(DrawOpOutput output,
|
void IterateSlow(DrawOpOutput output, PixelGetterCallback callback) {
|
||||||
Action<Pixel, DrawOpOutput> callback) {
|
|
||||||
Pixel pixel;
|
Pixel pixel;
|
||||||
int width = bmp.Width, height = bmp.Height;
|
int width = bmp.Width, height = bmp.Height;
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
|
@ -23,6 +23,8 @@ namespace MCGalaxy.Generator.Foliage {
|
|||||||
|
|
||||||
public delegate void TreeOutput(ushort x, ushort y, ushort z, byte block);
|
public delegate void TreeOutput(ushort x, ushort y, ushort z, byte block);
|
||||||
|
|
||||||
|
public delegate Tree TreeConstructor();
|
||||||
|
|
||||||
public abstract class Tree {
|
public abstract class Tree {
|
||||||
protected internal int height, size;
|
protected internal int height, size;
|
||||||
protected Random rnd;
|
protected Random rnd;
|
||||||
@ -60,8 +62,8 @@ namespace MCGalaxy.Generator.Foliage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Dictionary<string, Func<Tree>> TreeTypes =
|
public static Dictionary<string, TreeConstructor> TreeTypes =
|
||||||
new Dictionary<string, Func<Tree>>() {
|
new Dictionary<string, TreeConstructor>() {
|
||||||
{ "Fern", () => new NormalTree() }, { "Cactus", () => new CactusTree() },
|
{ "Fern", () => new NormalTree() }, { "Cactus", () => new CactusTree() },
|
||||||
{ "Notch", () => new ClassicTree() }, { "Swamp", () => new SwampTree() },
|
{ "Notch", () => new ClassicTree() }, { "Swamp", () => new SwampTree() },
|
||||||
{ "Bamboo", () => new BambooTree() }, { "Palm", () => new PalmTree() },
|
{ "Bamboo", () => new BambooTree() }, { "Palm", () => new PalmTree() },
|
||||||
|
@ -19,6 +19,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MCGalaxy.Generator {
|
namespace MCGalaxy.Generator {
|
||||||
|
|
||||||
|
public delegate ushort CalcLiquidLevel(ushort lvlHeight);
|
||||||
|
|
||||||
public sealed class RealisticGenParams {
|
public sealed class RealisticGenParams {
|
||||||
public float RangeLow = 0.2f;
|
public float RangeLow = 0.2f;
|
||||||
public float RangeHigh = 0.8f;
|
public float RangeHigh = 0.8f;
|
||||||
@ -26,7 +29,7 @@ namespace MCGalaxy.Generator {
|
|||||||
public bool FalloffEdges = false;
|
public bool FalloffEdges = false;
|
||||||
public bool UseLavaLiquid = false;
|
public bool UseLavaLiquid = false;
|
||||||
public bool GenerateOverlay2 = true;
|
public bool GenerateOverlay2 = true;
|
||||||
public Func<ushort, ushort> GetLiquidLevel = (height) => (ushort)(height / 2 + 2);
|
public CalcLiquidLevel GetLiquidLevel = (lvlHeight) => (ushort)(lvlHeight / 2 + 2);
|
||||||
|
|
||||||
// Decoration parameters
|
// Decoration parameters
|
||||||
public float TreeDens = 0.35f;
|
public float TreeDens = 0.35f;
|
||||||
|
@ -26,6 +26,8 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public delegate void OptionSetter(Player p, Level lvl, string value);
|
public delegate void OptionSetter(Player p, Level lvl, string value);
|
||||||
|
|
||||||
|
public delegate bool OptionIntValidator(Player p, int value);
|
||||||
|
|
||||||
public static Dictionary<string, OptionSetter> Options = new Dictionary<string, OptionSetter>() {
|
public static Dictionary<string, OptionSetter> Options = new Dictionary<string, OptionSetter>() {
|
||||||
{ "motd", SetMotd },
|
{ "motd", SetMotd },
|
||||||
{ "RealmOwner", SetRealmOwner },
|
{ "RealmOwner", SetRealmOwner },
|
||||||
@ -153,7 +155,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetInt(Player p, Level lvl, ref int target, string value, string name,
|
static void SetInt(Player p, Level lvl, ref int target, string value, string name,
|
||||||
Func<Player, int, bool> validator = null) {
|
OptionIntValidator validator = null) {
|
||||||
if (value == "") { Player.Message(p, "You must provide an integer."); return; }
|
if (value == "") { Player.Message(p, "You must provide an integer."); return; }
|
||||||
int raw = 0;
|
int raw = 0;
|
||||||
if (!CommandParser.GetInt(p, value, name, ref raw)) return;
|
if (!CommandParser.GetInt(p, value, name, ref raw)) return;
|
||||||
|
@ -25,15 +25,7 @@ namespace System.Runtime.CompilerServices {
|
|||||||
public sealed class ExtensionAttribute : Attribute {}
|
public sealed class ExtensionAttribute : Attribute {}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace System {
|
namespace System { public delegate void Action(); }
|
||||||
public delegate TReturn Func<TReturn>();
|
|
||||||
public delegate TReturn Func<T1, TReturn>(T1 arg1);
|
|
||||||
public delegate TReturn Func<T1, T2, TReturn>(T1 arg1, T2 arg2);
|
|
||||||
public delegate TReturn Func<T1, T2, T3, TReturn>(T1 arg1, T2 arg2, T3 arg3);
|
|
||||||
|
|
||||||
public delegate void Action();
|
|
||||||
public delegate void Action<T1, T2>(T1 arg1, T2 arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MCGalaxy.Util {
|
namespace MCGalaxy.Util {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user