Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Use Option for nullable fields in events, and remove deprecated events and methods * Super fancy cool javadocs which everyone will ready I'm 100% convinced * Add GuildChatEvent and GuildPreChatEvent * Fix checkstyle * Fix checkstyle Co-authored-by: Kamilkime <kamilkime@pm.me>
- Loading branch information
Showing
3 changed files
with
158 additions
and
30 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
plugin/src/main/java/net/dzikoysk/funnyguilds/event/guild/GuildChatEvent.java
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 @@ | ||
package net.dzikoysk.funnyguilds.event.guild; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
import net.dzikoysk.funnyguilds.guild.Guild; | ||
import net.dzikoysk.funnyguilds.user.User; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class GuildChatEvent extends GuildEvent { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
private final Type type; | ||
private final Set<Guild> receivers; | ||
private final String message; | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public GuildChatEvent(EventCause eventCause, @Nullable User doer, Guild guild, Type type, Set<Guild> receivers, String message) { | ||
super(eventCause, doer, guild); | ||
this.type = type; | ||
this.receivers = Collections.unmodifiableSet(receivers); | ||
this.message = message; | ||
} | ||
|
||
public Type getType() { | ||
return this.type; | ||
} | ||
|
||
public Set<Guild> getReceivers() { | ||
return this.receivers; | ||
} | ||
|
||
public String getMessage() { | ||
return this.message; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancelled) { | ||
throw new UnsupportedOperationException("GuildChatEvent cannot be cancelled, use GuildPreChatEvent"); | ||
} | ||
|
||
@Override | ||
public String getDefaultCancelMessage() { | ||
throw new UnsupportedOperationException("GuildChatEvent cannot be cancelled, use GuildPreChatEvent"); | ||
} | ||
|
||
public static enum Type { | ||
PRIVATE, | ||
ALLY, | ||
ALL | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
plugin/src/main/java/net/dzikoysk/funnyguilds/event/guild/GuildPreChatEvent.java
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,55 @@ | ||
package net.dzikoysk.funnyguilds.event.guild; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import net.dzikoysk.funnyguilds.guild.Guild; | ||
import net.dzikoysk.funnyguilds.user.User; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class GuildPreChatEvent extends GuildEvent { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
private final GuildChatEvent.Type type; | ||
private final Set<Guild> receivers; | ||
private String message; | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public GuildPreChatEvent(EventCause eventCause, @Nullable User doer, Guild guild, GuildChatEvent.Type type, Set<Guild> receivers, String message) { | ||
super(eventCause, doer, guild); | ||
this.type = type; | ||
this.receivers = new HashSet<>(receivers); | ||
this.message = message; | ||
} | ||
|
||
public GuildChatEvent.Type getType() { | ||
return this.type; | ||
} | ||
|
||
public Set<Guild> getReceivers() { | ||
return this.receivers; | ||
} | ||
|
||
public String getMessage() { | ||
return this.message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public String getDefaultCancelMessage() { | ||
return "[FunnyGuilds] Guild chat event has been cancelled by the server!"; | ||
} | ||
|
||
} |
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