Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
3.3.1
Browse files Browse the repository at this point in the history
머더 미스터리 Beta 해제
플러그인 외부에서 머더 미스터리 직업을 등록할 수 있도록 수정

Signed-off-by: Daybreak365 <malang365@naver.com>
  • Loading branch information
Daybreak365 committed Dec 21, 2022
1 parent efc9aec commit 6ac6dd9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package daybreak.abilitywar.game.list.murdermystery;

public enum CharacterType {
INNOCENT, MURDER
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import daybreak.abilitywar.ability.AbilityFactory.AbilityRegistration;
import daybreak.abilitywar.ability.AbilityFactory.AbilityRegistration.Flag;
import daybreak.abilitywar.config.Configuration.Settings.DeveloperSettings;
import daybreak.abilitywar.game.list.changeability.ChangeAbilityWar;
import daybreak.abilitywar.game.list.murdermystery.ability.Detective;
import daybreak.abilitywar.game.list.murdermystery.ability.Innocent;
import daybreak.abilitywar.game.list.murdermystery.ability.Murderer;
Expand All @@ -14,7 +13,6 @@
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.murderer.AssassinMurderer;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.murderer.BlackMurderer;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.murderer.SniperMurderer;
import daybreak.abilitywar.game.list.standard.StandardGame;
import daybreak.abilitywar.utils.base.logging.Logger;

import java.util.Collection;
Expand All @@ -24,9 +22,6 @@
import java.util.Set;
import java.util.TreeMap;

/**
* {@link StandardGame}, {@link ChangeAbilityWar} 등에서 사용하는 능력자 플러그인의 기본적인 능력 목록을 관리하는 클래스입니다.
*/
public class JobList {

private JobList() {
Expand All @@ -45,16 +40,6 @@ public static boolean isRegistered(AbilityRegistration registration) {
return registered.contains(registration);
}

/**
* 능력을 등록합니다.
* <p>
* 능력을 등록하기 전, AbilityManifest 어노테이션이 클래스에 존재하는지,
* 겹치는 이름은 없는지, 생성자는 올바른지 확인해주시길 바랍니다.
* <p>
* 이미 등록된 능력일 경우 다시 등록이 되지 않습니다.
*
* @param abilityClass 능력 클래스
*/
private static void registerJob(final Class<? extends AbilityBase> abilityClass, final String name) {
final AbilityRegistration registration = AbilityFactory.getRegistration(abilityClass);
if (registration != null) {
Expand All @@ -70,28 +55,37 @@ private static void registerJob(final Class<? extends AbilityBase> abilityClass,
}
}

public static void registerJob(final Class<? extends AbilityBase> abilityClass, final String name, CharacterType type) {
final AbilityRegistration registration = AbilityFactory.getRegistration(abilityClass);
if (registration != null) {
if (!jobs.containsKey(name)) {
if (registration.hasFlag(Flag.BETA) && !DeveloperSettings.isEnabled()) return;
jobs.put(name, registration);
registered.add(registration);
(type == CharacterType.INNOCENT ? MurderMystery.JOB_ABILITIES : MurderMystery.MURDER_JOB_ABILITIES).add(registration);
} else {
logger.debug("§e" + abilityClass.getName() + " §f능력은 겹치는 이름이 있어 등록되지 않았습니다.");
}
} else {
logger.debug("§e" + abilityClass.getName() + " §f능력은 AbilityFactory에 등록되지 않은 능력입니다.");
}
}

static {
registerJob(Murderer.class, "머더");
registerJob(Innocent.class, "시민");
registerJob(Detective.class, "탐정");
registerJob(Police.class, "경찰");
registerJob(Doctor.class, "의사");
registerJob(AssassinMurderer.class, "암살자");
registerJob(BlackMurderer.class, "블랙");
registerJob(SniperMurderer.class, "스나이퍼");
registerJob(Police.class, "경찰", CharacterType.INNOCENT);
registerJob(Doctor.class, "의사", CharacterType.INNOCENT);
registerJob(AssassinMurderer.class, "암살자", CharacterType.MURDER);
registerJob(BlackMurderer.class, "블랙", CharacterType.MURDER);
registerJob(SniperMurderer.class, "스나이퍼", CharacterType.MURDER);
}

public static Collection<AbilityRegistration> values() {
return Collections.unmodifiableCollection(jobs.values());
}

/**
* 등록된 능력 중 해당 이름의 능력을 반환합니다.
* AbilityManifest가 존재하지 않는 능력이거나 존재하지 않는 능력일 경우 null을 반환합니다.
*
* @param name 능력의 이름
* @return 능력 Class
*/
public static Class<? extends AbilityBase> getByString(String name) {
return jobs.get(name).getAbilityClass();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package daybreak.abilitywar.game.list.murdermystery;

import com.google.common.collect.ImmutableList;
import daybreak.abilitywar.AbilityWar;
import daybreak.abilitywar.ability.AbilityBase;
import daybreak.abilitywar.ability.AbilityFactory.AbilityRegistration;
Expand All @@ -20,12 +19,6 @@
import daybreak.abilitywar.game.list.murdermystery.ability.Detective;
import daybreak.abilitywar.game.list.murdermystery.ability.Innocent;
import daybreak.abilitywar.game.list.murdermystery.ability.Murderer;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.innocent.Doctor;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.innocent.Police;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.murderer.AssassinMurderer;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.murderer.BlackMurderer;
import daybreak.abilitywar.game.list.murdermystery.ability.jobs.murderer.SniperMurderer;
import daybreak.abilitywar.utils.annotations.Beta;
import daybreak.abilitywar.utils.base.Formatter;
import daybreak.abilitywar.utils.base.Messager;
import daybreak.abilitywar.utils.base.concurrent.SimpleTimer;
Expand Down Expand Up @@ -91,19 +84,11 @@

})
@Category(GameCategory.MINIGAME)
@Beta
public class MurderMystery extends AbstractGame implements Observer, Winnable {

public static final List<Class<? extends AbilityBase>> JOB_ABILITIES = ImmutableList.<Class<? extends AbilityBase>>builder()
.add(Police.class)
.add(Doctor.class)
.build();
static final List<AbilityRegistration> JOB_ABILITIES = new ArrayList<>();
static final List<AbilityRegistration> MURDER_JOB_ABILITIES = new ArrayList<>();

public static final List<Class<? extends AbilityBase>> MURDER_JOB_ABILITIES = ImmutableList.<Class<? extends AbilityBase>>builder()
.add(AssassinMurderer.class)
.add(BlackMurderer.class)
.add(SniperMurderer.class)
.build();
private static final Random random = new Random();
private static final ItemStack AIR = new ItemStack(Material.AIR);
private final Set<UUID> deadPlayers = new HashSet<>();
Expand All @@ -122,11 +107,11 @@ public boolean isDead(final UUID uniqueId) {
return deadPlayers.contains(uniqueId);
}

public static Class<? extends AbilityBase> getRandomJob() {
public static AbilityRegistration getRandomJob() {
return JOB_ABILITIES.get(random.nextInt(JOB_ABILITIES.size()));
}

public static Class<? extends AbilityBase> getRandomMurderJob() {
public static AbilityRegistration getRandomMurderJob() {
return MURDER_JOB_ABILITIES.get(random.nextInt(MURDER_JOB_ABILITIES.size()));
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<revision>3.3.0</revision>
<revision>3.3.1</revision>
<bukkit-api.version>1.15.2-R0.1-SNAPSHOT</bukkit-api.version>
<guava.version>30.1-jre</guava.version>
<kotlin.version>1.5.20</kotlin.version>
Expand Down

0 comments on commit 6ac6dd9

Please sign in to comment.