I hereby claim:
- I am John-Paul-R on github.
- I am john_paul_r (https://keybase.io/john_paul_r) on keybase.
- I have a public key whose fingerprint is 522F F5DE A709 6C4A AD1A 3BEC 7B98 1822 047F E953
To claim this, I am signing this object:
| import re | |
| def time_str_to_time_delta(stime: str): | |
| match_days = re.search('([0-9]+)d', stime) | |
| match_hrs = re.search('([0-9]+)h', stime) | |
| match_mins = re.search('([0-9]+)m', stime) | |
| match_secs = re.search('([0-9]+)s', stime) | |
| def int_from_match(match) -> int: | |
| out = 0 |
| package com.fibermc.essentialcommands; | |
| import net.minecraft.entity.Entity; | |
| import net.minecraft.entity.LivingEntity; | |
| import net.minecraft.entity.effect.StatusEffect; | |
| import net.minecraft.entity.effect.StatusEffectInstance; | |
| import net.minecraft.entity.effect.StatusEffectType; | |
| import net.minecraft.entity.passive.SquidEntity; | |
| import net.minecraft.potion.Potion; | |
| import net.minecraft.util.Identifier; |
| package com.packagename.access; | |
| import net.minecraft.client.gui.ClientChatListener; | |
| import net.minecraft.network.MessageType; | |
| public interface InGameHudAccess { | |
| void registerChatListener(MessageType messageType, ClientChatListener listener); | |
| } |
| public class TopCommand implements Command<ServerCommandSource> { | |
| @Override | |
| public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { | |
| ServerCommandSource source = context.getSource(); | |
| ServerPlayerEntity player = source.getPlayer(); | |
| World world = source.getWorld(); | |
| Vec3d playerPos = player.getPos(); | |
| int new_y; | |
| double new_x = playerPos.x; |
| using System; | |
| using System.Collections.Concurrent; | |
| using System.Collections.Generic; | |
| using System.Collections.Immutable; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Engines; | |
| using BenchmarkDotNet.Running; | |
| namespace Bench_Dictionaries | |
| { |
| using System; | |
| using System.Collections; | |
| using System.Collections.Concurrent; | |
| using System.Collections.Generic; | |
| using System.Collections.Immutable; | |
| using System.Collections.ObjectModel; | |
| using BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Engines; | |
| using BenchmarkDotNet.Jobs; | |
| using BenchmarkDotNet.Running; |
| type FilteredKeys<T, U> = { [P in keyof T]: T[P] extends U ? P : never }[keyof T]; | |
| enum Color { | |
| Red, Green, Blue, | |
| } | |
| type PropsOfType<T, U> = { | |
| [K in FilteredKeys<T, U>]: T[K] | |
| }; |
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <OutputType>Exe</OutputType> | |
| <TargetFramework>net7.0</TargetFramework> | |
| <ImplicitUsings>enable</ImplicitUsings> | |
| <Nullable>enable</Nullable> | |
| </PropertyGroup> | |
| <ItemGroup> |
I hereby claim:
To claim this, I am signing this object:
I think what might clarify is how events work. (Note, this is a long answer, tailored to your example. For something shorter, but less specific, see https://stackoverflow.com/a/33964976/8105643)
The event keyword is really just a nice syntax for setting up an EventHandler Delegate.
Now we understand that events are just special syntax delegates, we can explain how subscribing to an event actually works, and show how the two examples you gave are actually quite similar:
In your first example, you have essentially this situation:
public class DelegateCombineExample {