generated from Ekwav/SkyBase
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,547 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class ChatPart | ||
{ | ||
public string text; | ||
public string onClick; | ||
public string hover; | ||
|
||
public ChatPart() | ||
{ | ||
} | ||
|
||
public ChatPart(string text, string onClick = null, string hover = null) | ||
{ | ||
this.text = text; | ||
this.onClick = onClick; | ||
this.hover = hover; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using hypixel; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class FirstModVersionAdapter : IModVersionAdapter | ||
{ | ||
MinecraftSocket socket; | ||
|
||
public FirstModVersionAdapter(MinecraftSocket socket) | ||
{ | ||
this.socket = socket; | ||
SendUpdateMessage(); | ||
} | ||
|
||
private void SendUpdateMessage() | ||
{ | ||
socket.SendMessage(MinecraftSocket.COFLNET + McColorCodes.RED + "There is a newer mod version. click this to open discord and download it", "https://discord.com/channels/267680588666896385/890682907889373257/898974585318416395"); | ||
} | ||
|
||
public Task<bool> SendFlip(FlipInstance flip) | ||
{ | ||
socket.SendMessage(socket.GetFlipMsg(flip), "/viewauction " + flip.Auction.Uuid, "UPDATE"); | ||
SendUpdateMessage(); | ||
return Task.FromResult(true); | ||
} | ||
|
||
public void SendMessage(params ChatPart[] parts) | ||
{ | ||
var part = parts.FirstOrDefault(); | ||
socket.SendMessage(part.text, part.onClick, part.hover); | ||
SendUpdateMessage(); | ||
} | ||
|
||
public void SendSound(string name, float pitch = 1f) | ||
{ | ||
// no support | ||
SendUpdateMessage(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
using hypixel; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public interface IModVersionAdapter | ||
{ | ||
Task<bool> SendFlip(FlipInstance flip); | ||
void SendSound(string name, float pitch = 1); | ||
void SendMessage(params ChatPart[] parts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Threading.Tasks; | ||
using Coflnet.Sky.Commands.Shared; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class BlacklistCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
var tag = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(arguments); | ||
await socket.UpdateSettings(settings => | ||
{ | ||
if (settings.Settings.BlackList == null) | ||
settings.Settings.BlackList = new System.Collections.Generic.List<ListEntry>(); | ||
settings.Settings.BlackList.Add(new ListEntry() { ItemTag = tag }); | ||
return settings; | ||
}); | ||
socket.SendMessage(COFLNET + $"You blacklisted all {arguments} from appearing"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class BlockedCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
if (socket.TopBlocked.Count == 0) | ||
{ | ||
socket.SendMessage(COFLNET + "No blocked flips found, make sure you don't click this shortly after the 'flips in 10 seconds' message. (the list gets reset when that message appears)"); | ||
return; | ||
} | ||
var r = new Random(); | ||
socket.SendMessage(socket.TopBlocked.OrderBy(e=>r.Next()).Take(5).Select(b => | ||
{ | ||
socket.Settings.GetPrice(hypixel.FlipperService.LowPriceToFlip(b.Flip), out long targetPrice, out long profit); | ||
return new ChatPart( | ||
$"{b.Flip.Auction.ItemName} (+{socket.FormatPrice(profit)}) got blocked because {b.Reason.Replace("SNIPER", "experimental flip finder")}\n", | ||
"https://sky.coflnet.com/auction/" + b.Flip.Auction.Uuid, | ||
"Click to open"); | ||
}) | ||
.Append(new ChatPart() { text = COFLNET + "These are random examples of blocked flips.", onClick = "/cofl blocked", hover = "Execute again to get another sample" }).ToArray()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class ClickedCommand : McCommand | ||
{ | ||
public override Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class ExactCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
await socket.UpdateSettings(settings => | ||
{ | ||
settings.Settings.AllowedFinders = LowPricedAuction.FinderType.SNIPER | LowPricedAuction.FinderType.SNIPER_MEDIAN; | ||
return settings; | ||
}); | ||
socket.SendMessage(COFLNET + $"You enabled the exact flip mode, this is experimental"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class ExperimentalCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
await socket.UpdateSettings(settings => | ||
{ | ||
settings.Settings.AllowedFinders = LowPricedAuction.FinderType.FLIPPER | LowPricedAuction.FinderType.SNIPER_MEDIAN | LowPricedAuction.FinderType.SNIPER; | ||
return settings; | ||
}); | ||
socket.SendMessage(COFLNET + $"You opted in into experimental flips"); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public abstract class McCommand | ||
{ | ||
public string COFLNET => MinecraftSocket.COFLNET; | ||
public static string DEFAULT_COLOR => McColorCodes.GRAY; | ||
public abstract Task Execute(MinecraftSocket socket, string arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class NormalCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
await socket.UpdateSettings(settings => | ||
{ | ||
settings.Settings.AllowedFinders = LowPricedAuction.FinderType.FLIPPER; | ||
return settings; | ||
}); | ||
socket.SendMessage(COFLNET + $"You went back to normal flipper mode again"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class OnlineCommand : McCommand | ||
{ | ||
public override Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
socket.SendMessage(COFLNET + $"There are {hypixel.FlipperService.Instance.PremiumUserCount} users connected to this server"); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class PurchaseConfirmCommand : McCommand | ||
{ | ||
public override Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class PurchaseStartCommand : McCommand | ||
{ | ||
public override Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using hypixel; | ||
using Coflnet.Sky.Commands.Shared; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class RateCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
var args = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(arguments).Split(" "); | ||
var uuid = args[0]; | ||
var finder = args[1]; | ||
var rating = args[2]; | ||
using var span = socket.tracer.BuildSpan("vote").WithTag("type", rating).WithTag("finder", finder).WithTag("uuid", uuid).AsChildOf(socket.ConSpan).StartActive(); | ||
var bad = socket.GetFlip(uuid); | ||
span.Span.Log(JSON.Stringify(bad)); | ||
span.Span.Log(JSON.Stringify(bad?.AdditionalProps)); | ||
|
||
|
||
if (rating == "down") | ||
{ | ||
if(bad != null) | ||
Blacklist(socket, bad); | ||
socket.SendMessage(new ChatPart(COFLNET + "Thanks for your feedback, Please help us better understand why this flip is bad\n", null, "you can also send free text with /cofl report"), | ||
new ChatPart(" * Its overpriced\n", "/cofl report overpriced "), | ||
new ChatPart(" * This item sells slowly\n", "/cofl report slow sell"), | ||
new ChatPart(" * I blacklisted this before\n", "/cofl report blacklist broken"), | ||
new ChatPart(" * This item is manipulated\n", "/cofl report manipulated item"), | ||
new ChatPart(" * Reference auctions are wrong \n", "/cofl report reference auctions are wrong ", "please send /cofl report with further information")); | ||
await FlipTrackingService.Instance.DownVote(uuid, socket.McUuid); | ||
} | ||
else if (rating == "up") | ||
{ | ||
socket.SendMessage(new ChatPart(COFLNET + "Thanks for your feedback, Please help us better understand why this flip is good\n"), | ||
new ChatPart(" * it isn't I mis-clicked \n", "/cofl report misclicked "), | ||
new ChatPart(" * This item sells fast\n", "/cofl report fast sell"), | ||
new ChatPart(" * High profit\n", "/cofl report high profit"), | ||
new ChatPart(" * Something else \n", null, "please send /cofl report with further information")); | ||
await FlipTrackingService.Instance.UpVote(uuid, socket.McUuid); | ||
} | ||
else | ||
{ | ||
socket.SendMessage(COFLNET + $"Thanks for your feedback, you voted this flip " + rating, "/cofl undo", "We will try to improve the flips accordingly"); | ||
} | ||
await Task.Delay(3000); | ||
var based = await hypixel.CoreServer.ExecuteCommandWithCache<string, IEnumerable<BasedOnCommandResponse>>("flipBased", uuid); | ||
span.Span.Log(string.Join('\n', based.Select(b => $"{b.ItemName} {b.highestBid} {b.uuid}"))); | ||
} | ||
|
||
private static void Blacklist(MinecraftSocket socket, LowPricedAuction bad) | ||
{ | ||
if (socket.Settings.BlackList == null) | ||
socket.Settings.BlackList = new System.Collections.Generic.List<ListEntry>(); | ||
socket.Settings.BlackList.Add(new ListEntry() { ItemTag = bad.Auction.Tag }); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Coflnet.Sky.Commands.Shared; | ||
using hypixel; | ||
|
||
namespace Coflnet.Sky.Commands.MC | ||
{ | ||
public class ReferenceCommand : McCommand | ||
{ | ||
public override async Task Execute(MinecraftSocket socket, string arguments) | ||
{ | ||
Console.WriteLine(arguments); | ||
var uuid = arguments.Trim('"'); | ||
var flip = socket.GetFlip(uuid); | ||
if (flip.Finder.HasFlag(LowPricedAuction.FinderType.SNIPER)) | ||
{ | ||
await SniperReference(socket, uuid, flip, "sniping"); | ||
return; | ||
} | ||
if (flip.Finder.HasFlag(LowPricedAuction.FinderType.SNIPER_MEDIAN)) | ||
{ | ||
await SniperReference(socket, uuid, flip, "median sniper"); | ||
return; | ||
} | ||
socket.ModAdapter.SendMessage(new ChatPart("Caclulating references", "https://sky.coflnet.com/auction/" + uuid, "please give it a second")); | ||
var based = await CoreServer.ExecuteCommandWithCache<string, IEnumerable<BasedOnCommandResponse>>("flipBased", uuid); | ||
socket.ModAdapter.SendMessage(based | ||
.Select(b => new ChatPart( | ||
$"\n-> {b.ItemName} for {McColorCodes.AQUA}{socket.FormatPrice(b.highestBid)}{McColorCodes.GRAY} {b.end}", | ||
"https://sky.coflnet.com/auction/" + b.uuid, | ||
"Click to open this auction")) | ||
.ToArray()); | ||
await Task.Delay(200); | ||
socket.ModAdapter.SendMessage(new ChatPart(MinecraftSocket.COFLNET + "click this to open the auction on the website (in case you want to report an error or share it)", "https://sky.coflnet.com/auction/" + uuid, "please give it a second")); | ||
} | ||
|
||
private async Task SniperReference(MinecraftSocket socket, string uuid, LowPricedAuction flip, string algo) | ||
{ | ||
var reference = await AuctionService.Instance.GetAuctionAsync(flip.AdditionalProps["reference"]); | ||
Console.WriteLine(JSON.Stringify(flip.AdditionalProps)); | ||
Console.WriteLine(JSON.Stringify(reference)); | ||
socket.ModAdapter.SendMessage(new ChatPart($"{COFLNET}This flip was found by the {algo} algorithm\n", "https://sky.coflnet.com/auction/" + uuid, "click this to open the flip on website"), | ||
new ChatPart($"It was compared to {McColorCodes.AQUA} this auction {DEFAULT_COLOR}, open ah", $"/viewauction {reference.Uuid}", McColorCodes.GREEN + "open it on ah"), | ||
new ChatPart($"{McColorCodes.WHITE} open on website", $"https://sky.coflnet.com/auction/{reference.Uuid}", "open it on website")); | ||
} | ||
} | ||
} |
Oops, something went wrong.