From 6709363f99f1bdbb9e91ec2a89af7e5cb1b1299c Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 15 Oct 2014 12:05:16 +0200 Subject: [PATCH] Added MOTD event --- .gitignore | 5 ++- media/Thumbs.db | Bin 43520 -> 43520 bytes .../factions/cmd/CmdFactionsFaction.java | 2 +- .../factions/cmd/CmdFactionsMotd.java | 7 +++ .../event/EventFactionsMotdChange.java | 40 ++++++++++++++++++ 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/event/EventFactionsMotdChange.java diff --git a/.gitignore b/.gitignore index 6fa8deb6..1b3e1bae 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,8 @@ /dist /manifest.mf -# Mac filesystem dust +# Mac Filesystem Dust .DS_Store + +# Windows Filesystem Dust +Thumbs.db diff --git a/media/Thumbs.db b/media/Thumbs.db index 7d9e784dbc8dbf80fc0281e63e0cfde3f00c6a67..d735521ac152306accabf7d220f54b6f0307b778 100644 GIT binary patch delta 31 mcmZp;!qjkuX+sVR+k=C@6XRcOE@GKw&hj4!HVfE%$OQoSa}aF+ delta 31 lcmZp;!qjkuX+sVR8^b3y*K6lC7qQGTXJG(>%>p(basj?23l0DP diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java index 8f2df0e1..0cac08c7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java @@ -62,7 +62,7 @@ public class CmdFactionsFaction extends FactionsCommand // INFO: Id (admin mode output only) if (msender.isUsingAdminMode()) { - msg("ID: %s", faction.getId()); + msg("ID: %s", faction.getId()); } // INFO: Description diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMotd.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMotd.java index 551b9cb9..e3c7c159 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMotd.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMotd.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.factions.event.EventFactionsMotdChange; import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.mixin.Mixin; @@ -74,6 +75,12 @@ public class CmdFactionsMotd extends FactionsCommand return; } + // Event + EventFactionsMotdChange event = new EventFactionsMotdChange(sender, msenderFaction, target); + event.run(); + if (event.isCancelled()) return; + target = event.getNewMotd(); + // Apply msenderFaction.setMotd(target); diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsMotdChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsMotdChange.java new file mode 100644 index 00000000..e68858c0 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsMotdChange.java @@ -0,0 +1,40 @@ +package com.massivecraft.factions.event; + +import org.bukkit.command.CommandSender; +import org.bukkit.event.HandlerList; + +import com.massivecraft.factions.entity.Faction; + +public class EventFactionsMotdChange extends EventFactionsAbstractSender +{ + // -------------------------------------------- // + // REQUIRED EVENT CODE + // -------------------------------------------- // + + private static final HandlerList handlers = new HandlerList(); + @Override public HandlerList getHandlers() { return handlers; } + public static HandlerList getHandlerList() { return handlers; } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private final Faction faction; + public Faction getFaction() { return this.faction; } + + private String newMotd; + public String getNewMotd() { return this.newMotd; } + public void setNewMotd(String newMotd) { this.newMotd = newMotd; } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public EventFactionsMotdChange(CommandSender sender, Faction faction, String newMotd) + { + super(sender); + this.faction = faction; + this.newMotd = newMotd; + } + +}