The-Fireplace-Minecraft-Mods / Clans

A Minecraft land protection and PVP mod
https://www.curseforge.com/minecraft/mc-mods/clans
GNU General Public License v3.0
5 stars 10 forks source link

API event acquisition #233

Closed mcqwy closed 4 years ago

mcqwy commented 4 years ago

Hello, how can I use the clanapi to get the event of player entering town? Events after a player leaves town and enters the wilderness Players join the raid event A raid on an impending event

The-Fireplace commented 4 years ago

There isn't currently an easy way to do this. If you make a PR adding an event, I'll merge it and make a build.

On Tue, Jul 28, 2020, 6:06 AM Mon_lh notifications@github.com wrote:

Hello, how can I use the clanapi to get the event of player entering town? Leave town and enter wilderness with players?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/The-Fireplace-Minecraft-Mods/Clans/issues/233, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABND5LHPAXKLFZTY7EAB6Y3R52WLDANCNFSM4PKMZFAA .

mcqwy commented 4 years ago

Hi! I spent some time defining a few events. First create event class' ClanModEvent.java ' ClanModEvent.java.txt

on stay 'Clans.java' register Register in public void init(FMLInitializationEvent event) method new ClanModEvent(); You can publish any custom events to forge through forge method, and others can handle things directly by listening to events when developing attached mod. Example of publishing event: MinecraftForge.EVENT_BUS.post(event);

Calling methods and publishing events. There are players forming a new raid team event. CommandJoinRaid.java.txt

Start the raid Event. CommandStartRaid.java.txt

End Raid Event. RaidingParties.java.txt

handleTerritoryChangedMessageEvent. TimerLogic.java.txt

The above are some of the events and ideas I provided. More custom events you can refer to my ideas to write code. The above code I only tested part of the event, maybe there will be bugs, maybe there will be a better place to write. You can change it as you like.