improved map detection, quickjoin prison
This commit is contained in:
parent
7b747eb291
commit
d135b38708
4 changed files with 77 additions and 38 deletions
|
@ -20,13 +20,13 @@ public class QuickZombiesCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandUsage(ICommandSender sender) {
|
public String getCommandUsage(ICommandSender sender) {
|
||||||
return "/qz <de|bb|aa>";
|
return "/qz <de|bb|aa|p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processCommand(ICommandSender sender, String @NotNull [] args) throws CommandException {
|
public void processCommand(ICommandSender sender, String @NotNull [] args) throws CommandException {
|
||||||
if (args.length == 0) throw new WrongUsageException(
|
if (args.length == 0) throw new WrongUsageException(
|
||||||
"[Missing option] options: de, bb, aa");
|
"[Missing option] options: de, bb, aa, p");
|
||||||
else switch (args[0]) {
|
else switch (args[0]) {
|
||||||
case "de":
|
case "de":
|
||||||
Minecraft.getMinecraft().thePlayer.sendChatMessage("/play arcade_zombies_dead_end");
|
Minecraft.getMinecraft().thePlayer.sendChatMessage("/play arcade_zombies_dead_end");
|
||||||
|
@ -37,9 +37,12 @@ public class QuickZombiesCommand extends CommandBase {
|
||||||
case "aa":
|
case "aa":
|
||||||
Minecraft.getMinecraft().thePlayer.sendChatMessage("/play arcade_zombies_alien_arcadium");
|
Minecraft.getMinecraft().thePlayer.sendChatMessage("/play arcade_zombies_alien_arcadium");
|
||||||
break;
|
break;
|
||||||
|
case "p":
|
||||||
|
Minecraft.getMinecraft().thePlayer.sendChatMessage("/play arcade_zombies_prison");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new WrongUsageException(
|
throw new WrongUsageException(
|
||||||
"[Invalid option] options: de, bb, aa", args[0]);
|
"[Invalid option] options: de, bb, aa, p", args[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,30 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.game.enums;
|
package com.github.stachelbeere1248.zombiesutils.game.enums;
|
||||||
|
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public enum Map {
|
public enum Map {
|
||||||
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON
|
DEAD_END, BAD_BLOOD, ALIEN_ARCADIUM, PRISON;
|
||||||
|
|
||||||
|
public static Optional<Map> getMap() {
|
||||||
|
World world = Minecraft.getMinecraft().theWorld;
|
||||||
|
BlockPos pos = new BlockPos(44,71,0);
|
||||||
|
if (!world.isBlockLoaded(pos) || Scoreboard.isNotZombies()) return Optional.empty();
|
||||||
|
Block block = world.getBlockState(pos).getBlock();
|
||||||
|
if (block.equals(Blocks.air)) {
|
||||||
|
return Optional.of(Map.DEAD_END);
|
||||||
|
} else if (block.equals(Blocks.wool)) {
|
||||||
|
return Optional.of(Map.BAD_BLOOD);
|
||||||
|
} else if (block.equals(Blocks.stone_slab)) {
|
||||||
|
return Optional.of(Map.ALIEN_ARCADIUM);
|
||||||
|
} else if (block.equals(Blocks.wooden_slab)) {
|
||||||
|
return Optional.of(Map.PRISON);
|
||||||
|
} else return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.mixin;
|
package com.github.stachelbeere1248.zombiesutils.mixin;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
|
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
import com.github.stachelbeere1248.zombiesutils.timer.Timer;
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport;
|
import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport;
|
||||||
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard;
|
||||||
|
@ -41,30 +42,41 @@ public class MixinNetHandlerPlayClient {
|
||||||
)) return;
|
)) return;
|
||||||
zombies_utils$alienUfoOpened = soundEffect.equals("mob.guardian.curse");
|
zombies_utils$alienUfoOpened = soundEffect.equals("mob.guardian.curse");
|
||||||
try {
|
try {
|
||||||
if (Timer.getInstance().isPresent()) {
|
|
||||||
|
if (!Timer.getInstance().isPresent()) {
|
||||||
|
Timer.instance = new Timer(
|
||||||
|
Scoreboard.getServerNumber().orElseThrow(Timer.TimerException.ServerNumberException::new),
|
||||||
|
Map.getMap().orElseThrow(Timer.TimerException.MapException::new),
|
||||||
|
Scoreboard.getRound()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final Timer running = Timer.getInstance().get();
|
final Timer running = Timer.getInstance().get();
|
||||||
final byte round = Scoreboard.getRound();
|
final byte round = Scoreboard.getRound();
|
||||||
|
|
||||||
if (round == 0) {
|
if (round == 0) {
|
||||||
if (Scoreboard.getLineCount() < 13) Timer.instance = new Timer(
|
if (Scoreboard.getLineCount() < 13) Timer.instance = new Timer(
|
||||||
Scoreboard.getServerNumber().orElseThrow(Timer.TimerException.ServerNumberException::new),
|
Scoreboard.getServerNumber().orElseThrow(Timer.TimerException.ServerNumberException::new),
|
||||||
Scoreboard.getMap().orElseThrow(Timer.TimerException.MapException::new),
|
Map.getMap().orElseThrow(Timer.TimerException.MapException::new),
|
||||||
round
|
round
|
||||||
);
|
);
|
||||||
} else if (!running.equalsServerOrNull(Scoreboard.getServerNumber().orElse(null))) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!running.equalsServerOrNull(Scoreboard.getServerNumber().orElse(null))) {
|
||||||
Timer.instance = new Timer(
|
Timer.instance = new Timer(
|
||||||
Scoreboard.getServerNumber().orElseThrow(Timer.TimerException.ServerNumberException::new),
|
Scoreboard.getServerNumber().orElseThrow(Timer.TimerException.ServerNumberException::new),
|
||||||
Scoreboard.getMap().orElseThrow(Timer.TimerException.MapException::new),
|
Map.getMap().orElseThrow(Timer.TimerException.MapException::new),
|
||||||
round
|
round
|
||||||
);
|
);
|
||||||
} else running.split(round);
|
return;
|
||||||
} else Timer.instance = new Timer(
|
}
|
||||||
Scoreboard.getServerNumber().orElseThrow(Timer.TimerException.ServerNumberException::new),
|
|
||||||
Scoreboard.getMap().orElseThrow(Timer.TimerException.MapException::new),
|
running.split(round);
|
||||||
Scoreboard.getRound()
|
|
||||||
);
|
|
||||||
} catch (Timer.TimerException e) {
|
} catch (Timer.TimerException e) {
|
||||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§cFailed to start or split timer.\nData parsing error. Blame scoreboard."));
|
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§cFailed to start or split timer. Please send a log to Stachelbeere1248."));
|
||||||
ZombiesUtils.getInstance().getLogger().warn(e);
|
ZombiesUtils.getInstance().getLogger().warn(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +93,7 @@ public class MixinNetHandlerPlayClient {
|
||||||
switch (timer.getGameMode().getMap()) {
|
switch (timer.getGameMode().getMap()) {
|
||||||
case DEAD_END:
|
case DEAD_END:
|
||||||
case BAD_BLOOD:
|
case BAD_BLOOD:
|
||||||
case PRISON:
|
case PRISON: //TODO: Escape
|
||||||
timer.split((byte) 30);
|
timer.split((byte) 30);
|
||||||
Timer.dropInstances();
|
Timer.dropInstances();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.github.stachelbeere1248.zombiesutils.utils;
|
package com.github.stachelbeere1248.zombiesutils.utils;
|
||||||
|
|
||||||
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
import com.github.stachelbeere1248.zombiesutils.ZombiesUtils;
|
||||||
import com.github.stachelbeere1248.zombiesutils.game.enums.Map;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -42,17 +41,16 @@ public class Scoreboard {
|
||||||
// get
|
// get
|
||||||
title = STRIP_COLOR_PATTERN.matcher(sidebar.getDisplayName().trim()).replaceAll("");
|
title = STRIP_COLOR_PATTERN.matcher(sidebar.getDisplayName().trim()).replaceAll("");
|
||||||
Collection<Score> scoreCollection = scoreboard.getSortedScores(sidebar);
|
Collection<Score> scoreCollection = scoreboard.getSortedScores(sidebar);
|
||||||
List<Score> filteredScores = scoreCollection.stream().filter(input -> input.getPlayerName() != null && !input.getPlayerName().startsWith("#")).collect(Collectors.toList());
|
List<Score> filteredScores = scoreCollection
|
||||||
|
.stream()
|
||||||
|
.filter(input -> input.getPlayerName() != null && !input.getPlayerName().startsWith("#"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
List<Score> scores;
|
List<Score> scores = (filteredScores.size() > 15) ? Lists.newArrayList(Iterables.skip(filteredScores, scoreCollection.size() - 15)) : filteredScores;
|
||||||
if (filteredScores.size() > 15)
|
|
||||||
scores = Lists.newArrayList(Iterables.skip(filteredScores, scoreCollection.size() - 15));
|
|
||||||
else scores = filteredScores;
|
|
||||||
scores = Lists.reverse(scores);
|
scores = Lists.reverse(scores);
|
||||||
|
|
||||||
lines = new ArrayList<>();
|
lines = new ArrayList<>(scores.size());
|
||||||
for (Score score : scores
|
for (Score score : scores) {
|
||||||
) {
|
|
||||||
ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
|
ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
|
||||||
String scoreboardLine = ScorePlayerTeam.formatPlayerName(team, score.getPlayerName()).trim();
|
String scoreboardLine = ScorePlayerTeam.formatPlayerName(team, score.getPlayerName()).trim();
|
||||||
lines.add(STRIP_COLOR_PATTERN.matcher(SIDEBAR_EMOJI_PATTERN.matcher(scoreboardLine).replaceAll("")).replaceAll(""));
|
lines.add(STRIP_COLOR_PATTERN.matcher(SIDEBAR_EMOJI_PATTERN.matcher(scoreboardLine).replaceAll("")).replaceAll(""));
|
||||||
|
@ -93,10 +91,11 @@ public class Scoreboard {
|
||||||
return Optional.ofNullable(string);
|
return Optional.ofNullable(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Outdated
|
||||||
public static Optional<Map> getMap() {
|
public static Optional<Map> getMap() {
|
||||||
String line;
|
String line;
|
||||||
try {
|
try {
|
||||||
line = lines.get(12); //TODO: This was changed!
|
line = lines.get(12); //This was changed!
|
||||||
} catch (Exception couldBePregame) {
|
} catch (Exception couldBePregame) {
|
||||||
try {
|
try {
|
||||||
line = lines.get(2);
|
line = lines.get(2);
|
||||||
|
@ -118,8 +117,8 @@ public class Scoreboard {
|
||||||
default:
|
default:
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public static int getLineCount() {
|
public static int getLineCount() {
|
||||||
return lines.size();
|
return lines.size();
|
||||||
|
|
Loading…
Add table
Reference in a new issue