Skip to content

Commit

Permalink
added descriptions on event join
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicbo committed Sep 5, 2020
1 parent 895d109 commit 4ff9cb0
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/InvadedEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
import me.nicbo.invadedlandsevents.scoreboard.line.TrackLine;
import me.nicbo.invadedlandsevents.util.ConfigUtils;
import me.nicbo.invadedlandsevents.util.GeneralUtils;
import me.nicbo.invadedlandsevents.util.SpigotUtils;
import me.nicbo.invadedlandsevents.util.StringUtils;
import me.nicbo.invadedlandsevents.util.misc.CompositeUnmodifiableList;
Expand Down Expand Up @@ -483,6 +484,8 @@ public EventScoreboardManager getEventScoreboardManager() {
* @param player the player that is joining the event
*/
public void joinEvent(Player player) {
GeneralUtils.sendMessages(player, getDescriptionMessage());

Bukkit.broadcastMessage(Message.JOINED_EVENT_BROADCAST.get().replace("{player}", player.getName()));

players.add(player);
Expand All @@ -495,6 +498,8 @@ public void joinEvent(Player player) {
}
}

protected abstract List<String> getDescriptionMessage();

/**
* Removes player from the event
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.DuelEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand All @@ -18,6 +19,7 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;

/**
Expand Down Expand Up @@ -89,6 +91,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return BracketsSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.BRACKETS_DESCRIPTION.get();
}

@Override
protected Collection<Player> prepareRound() {
// Just in case, if the list size is one than the while loop while crash the server
Expand Down
16 changes: 15 additions & 1 deletion src/me/nicbo/invadedlandsevents/events/type/impl/KOTH.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.TimerEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -55,8 +56,10 @@ public final class KOTH extends TimerEvent {

private final int WIN_POINTS;

private final List<String> description;

public KOTH(InvadedLandsEvents plugin) {
super(plugin, "King Of The Hill", "koth");
super(plugin, "King of the Hill", "koth");

this.armour = new ItemStack[]{
new ItemBuilder(Material.IRON_BOOTS).setEnchants(new Enchant(Enchantment.PROTECTION_ENVIRONMENTAL, 2)).build(),
Expand Down Expand Up @@ -134,6 +137,12 @@ public void run() {
}
}
};

this.description = new ArrayList<>();

for (String message : ListMessage.KOTH_DESCRIPTION.get()) {
this.description.add(message.replace("{points}", String.valueOf(WIN_POINTS)));
}
}

@Override
Expand Down Expand Up @@ -167,6 +176,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return KOTHSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return description;
}

@Override
public void leaveEvent(Player player) {
super.leaveEvent(player);
Expand Down
6 changes: 6 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/impl/LMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.TimerEvent;
import me.nicbo.invadedlandsevents.events.util.MatchCountdown;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.TrackLine;
Expand Down Expand Up @@ -90,6 +91,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return LMSSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.LMS_DESCRIPTION.get();
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerHitLMS(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Expand Down
14 changes: 14 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/impl/OITC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.TimerEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -44,6 +45,8 @@ public final class OITC extends TimerEvent {

private final int WIN_POINTS;

private final List<String> description;

public OITC(InvadedLandsEvents plugin) {
super(plugin, "One in the Chamber", "oitc");

Expand All @@ -63,6 +66,12 @@ public OITC(InvadedLandsEvents plugin) {
this.respawningPlayers = new HashSet<>();

this.WIN_POINTS = getEventInteger("win-points");

this.description = new ArrayList<>();

for (String message : ListMessage.OITC_DESCRIPTION.get()) {
this.description.add(message.replace("{points}", String.valueOf(WIN_POINTS)));
}
}

@Override
Expand Down Expand Up @@ -92,6 +101,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return OITCSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return description;
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerHitOITC(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.RoundEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -100,6 +101,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return RedRoverSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.REDROVER_DESCRIPTION.get();
}

@Override
protected void newRound() {
side = Side.getNext(side);
Expand Down
7 changes: 7 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/impl/RoD.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.TimerEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.TrackLine;
import me.nicbo.invadedlandsevents.util.SpigotUtils;
Expand All @@ -18,6 +19,7 @@
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.List;
import java.util.function.Function;

/**
Expand Down Expand Up @@ -77,6 +79,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return RoDSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.ROD_DESCRIPTION.get();
}

@Override
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerHit(EntityDamageByEntityEvent event) {
Expand Down
6 changes: 6 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/impl/Spleef.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.TimerEvent;
import me.nicbo.invadedlandsevents.events.util.MatchCountdown;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.TrackLine;
Expand Down Expand Up @@ -130,6 +131,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return SpleefSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.SPLEEF_DESCRIPTION.get();
}

private void buildSnow(BlockVector pos1, BlockVector pos2) {
int minX = (int) Math.min(pos1.getX(), pos2.getX());
int minZ = (int) Math.min(pos1.getZ(), pos2.getZ());
Expand Down
6 changes: 6 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/impl/TDM.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.nicbo.invadedlandsevents.events.type.InvadedEvent;
import me.nicbo.invadedlandsevents.events.util.MatchCountdown;
import me.nicbo.invadedlandsevents.events.util.team.TDMTeam;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -87,6 +88,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return TDMSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.TDM_DESCRIPTION.get();
}

@Override
protected void checkPlayerCount() {
if (red.isEmpty()) {
Expand Down
6 changes: 6 additions & 0 deletions src/me/nicbo/invadedlandsevents/events/type/impl/TNTTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.RoundEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -93,6 +94,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return TNTTagSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.TNTTAG_DESCRIPTION.get();
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerHitTT(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.RoundEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -233,6 +234,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return WaterdropSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.WATERDROP_DESCRIPTION.get();
}

@Override
protected void newRound() {
broadcastEventMessage(Message.WATERDROP_ROUND_STARTING.get().replace("{round}", String.valueOf(getRound())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.events.type.RoundEvent;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;
import me.nicbo.invadedlandsevents.messages.impl.Message;
import me.nicbo.invadedlandsevents.scoreboard.EventScoreboard;
import me.nicbo.invadedlandsevents.scoreboard.line.Line;
Expand Down Expand Up @@ -86,6 +87,11 @@ protected Function<Player, EventScoreboard> getScoreboardFactory() {
return WoolShuffleSB::new;
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.WOOLSHUFFLE.get();
}

@Override
protected void newRound() {
broadcastEventMessage(Message.WOOLSHUFFLE_ROUND_STARTING.get().replace("{round}", String.valueOf(getRound())));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package me.nicbo.invadedlandsevents.events.type.impl.sumo;

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;

import java.util.List;

/**
* Represents sumo event with teams of 1
Expand All @@ -12,4 +15,9 @@ public final class Sumo1v1 extends Sumo {
public Sumo1v1(InvadedLandsEvents plugin) {
super(plugin, "1v1 Sumo", "sumo1v1", 1);
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.SUMO1V1_DESCRIPTION.get();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package me.nicbo.invadedlandsevents.events.type.impl.sumo;

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;

import java.util.List;

/**
* Represents sumo event with teams of 2
Expand All @@ -12,4 +15,9 @@ public final class Sumo2v2 extends Sumo {
public Sumo2v2(InvadedLandsEvents plugin) {
super(plugin, "2v2 Sumo", "sumo2v2", 2);
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.SUMO2V2_DESCRIPTION.get();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package me.nicbo.invadedlandsevents.events.type.impl.sumo;

import me.nicbo.invadedlandsevents.InvadedLandsEvents;
import me.nicbo.invadedlandsevents.messages.impl.ListMessage;

import java.util.List;

/**
* Represents sumo event with teams of 3
Expand All @@ -12,4 +15,9 @@ public final class Sumo3v3 extends Sumo {
public Sumo3v3(InvadedLandsEvents plugin) {
super(plugin, "3v3 Sumo", "sumo3v3", 3);
}

@Override
protected List<String> getDescriptionMessage() {
return ListMessage.SUMO3V3_DESCRIPTION.get();
}
}
17 changes: 16 additions & 1 deletion src/me/nicbo/invadedlandsevents/messages/impl/ListMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ public enum ListMessage implements IMessage<List<String>> {
INFO_MESSAGES("event.INFO_MESSAGES"),
USAGE_MESSAGES("event.USAGE_MESSAGES"),
WIN_MESSAGES("event.WIN_MESSAGES"),
TDM_WINNERS("tdm.WINNERS");
TDM_WINNERS("tdm.WINNERS"),

SUMO1V1_DESCRIPTION("description.SUMO1V1"),
SUMO2V2_DESCRIPTION("description.SUMO2V2"),
SUMO3V3_DESCRIPTION("description.SUMO3V3"),
BRACKETS_DESCRIPTION("description.BRACKETS"),
KOTH_DESCRIPTION("description.KOTH"),
LMS_DESCRIPTION("description.LMS"),
OITC_DESCRIPTION("description.OITC"),
REDROVER_DESCRIPTION("description.REDROVER"),
ROD_DESCRIPTION("description.ROD"),
SPLEEF_DESCRIPTION("description.SPLEEF"),
TDM_DESCRIPTION("description.TDM"),
TNTTAG_DESCRIPTION("description.TNTTAG"),
WATERDROP_DESCRIPTION("description.WATERDROP"),
WOOLSHUFFLE("description.WOOLSHUFFLE");

private final String path;
private List<String> messages;
Expand Down

0 comments on commit 4ff9cb0

Please sign in to comment.