Add welcoming message on player join event

This commit is contained in:
Barazok
2020-10-11 17:36:48 +02:00
parent 111364ca05
commit 8495826e11
2 changed files with 13 additions and 3 deletions

View File

@@ -12,13 +12,14 @@ import java.util.Collections;
public class ClassWrapper {
public static void reapplyRightClassEffects(Player player, boolean sendReminder) {
public static boolean reapplyRightClassEffects(Player player, boolean sendReminder) {
if (AppliedStatus.getInstance().isDwarf(player.getName()) || DwarfClass.is(player)) {
AppliedStatus.getInstance().setDwarf(player.getName(), true);
DwarfClass.reapplyEffects(player);
if (sendReminder) {
player.sendMessage("Reminder : You are a dwarf.");
}
return true;
}
if (AppliedStatus.getInstance().isElf(player.getName()) || ElfClass.is(player)) {
AppliedStatus.getInstance().setElf(player.getName(), true);
@@ -26,6 +27,7 @@ public class ClassWrapper {
if (sendReminder) {
player.sendMessage("Reminder : You are an elf.");
}
return true;
}
if (AppliedStatus.getInstance().isFireDwarf(player.getName()) || FireDwarfClass.is(player)) {
AppliedStatus.getInstance().setFireDwarf(player.getName(), true);
@@ -33,6 +35,7 @@ public class ClassWrapper {
if (sendReminder) {
player.sendMessage("Reminder : You are a fire dwarf.");
}
return true;
}
if (AppliedStatus.getInstance().isNaga(player.getName()) || NagaClass.is(player)) {
AppliedStatus.getInstance().setNaga(player.getName(), true);
@@ -40,7 +43,9 @@ public class ClassWrapper {
if (sendReminder) {
player.sendMessage("Reminder : You are a naga.");
}
return true;
}
return false;
}
public static void clearAllClassEffects(Player player) {

View File

@@ -37,7 +37,10 @@ public class MineClassListeners implements Listener {
@EventHandler
public void on(PlayerJoinEvent event) {
Player player = event.getPlayer();
ClassWrapper.reapplyRightClassEffects(player, true);
if (!ClassWrapper.reapplyRightClassEffects(player, true)) {
player.sendMessage(
"Hello ! The amazing MineClass mod is available on this server ! You can pick a class with the /class command.");
}
}
@EventHandler
@@ -136,7 +139,9 @@ public class MineClassListeners implements Listener {
.getItems()
.forEach(
item -> {
ItemStack smelted = SmeltingEngine.getInstance().smelt(player, event.getBlock().getLocation(), item.getItemStack());
ItemStack smelted =
SmeltingEngine.getInstance()
.smelt(player, event.getBlock().getLocation(), item.getItemStack());
if (smelted != null) {
item.setItemStack(smelted);
}