001package fr.aumgn.dac2.config; 002 003import java.text.MessageFormat; 004import java.util.Locale; 005 006import org.bukkit.Material; 007 008import fr.aumgn.bukkitutils.timer.TimerConfig; 009import fr.aumgn.bukkitutils.util.Util; 010import fr.aumgn.dac2.shape.column.UniformPattern; 011import fr.aumgn.dac2.shape.column.ColumnPattern; 012import fr.aumgn.dac2.utils.DACUtil; 013 014public class DACConfig { 015 016 private String language = Locale.getDefault().toString(); 017 018 private PoolReset poolReset = PoolReset.START; 019 020 private String spectatorsMessage = "{yellow}[{0}]{1}"; 021 private transient MessageFormat spectatorsMessageFormat = null; 022 023 private String timerFormat = "%02d:%02d"; 024 private int timeOut = 60; 025 026 private boolean tpBeforeJump = true; 027 private int tpAfterJumpSuccessDelay = 0; 028 private int tpAfterJumpFailDelay = 3; 029 030 private double colonnisationSetupPercent = 5; 031 private Material neutralBlock = Material.OBSIDIAN; 032 private byte neutralData = 0; 033 034 public Locale getLocale() { 035 return Util.parseLocale(language); 036 } 037 038 public boolean getResetOnStart() { 039 return (poolReset.flag() & PoolReset.START.flag()) != 0; 040 } 041 042 public boolean getResetOnEnd() { 043 return (poolReset.flag() & PoolReset.END.flag()) != 0; 044 } 045 046 public MessageFormat getSpectatorsMsg() { 047 if (spectatorsMessageFormat == null) { 048 spectatorsMessageFormat = new MessageFormat( 049 Util.parseColorsMarkup(spectatorsMessage), 050 getLocale()); 051 } 052 053 return spectatorsMessageFormat; 054 } 055 056 public TimerConfig getTimerConfig() { 057 return new TimerConfig(timeOut / 2, timeOut / 4, timerFormat, ""); 058 } 059 060 public int getTimeOut() { 061 return timeOut; 062 } 063 064 public boolean getTpBeforeJump() { 065 return tpBeforeJump; 066 } 067 068 public int getTpAfterJumpSuccessDelay() { 069 return tpAfterJumpSuccessDelay * DACUtil.TICKS_PER_SECONDS; 070 } 071 072 public int getTpAfterJumpFailDelay() { 073 return tpAfterJumpFailDelay * DACUtil.TICKS_PER_SECONDS; 074 } 075 076 public double getColonnisationRatio() { 077 return ((double) colonnisationSetupPercent) / 100; 078 } 079 080 public ColumnPattern getNeutralPattern() { 081 return new UniformPattern(neutralBlock, neutralData); 082 } 083}