Merge 40f0711a05
into 15a79bdd7e
This commit is contained in:
commit
a5c1c415a9
|
@ -15,7 +15,7 @@ jobs:
|
|||
- name: 'Set up JDK'
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '11'
|
||||
java-version: '16'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: 'Cache dependencies'
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
# OS Files
|
||||
.DS_Store
|
||||
|
||||
# IDE Files
|
||||
.vscode/
|
||||
|
||||
# Java
|
||||
*.class
|
||||
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -15,14 +15,14 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Use Java 8 for compilation -->
|
||||
<!-- Use Java 16 for compilation -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
|
|
|
@ -174,8 +174,6 @@ public class ArenaClass
|
|||
* @param p a player
|
||||
*/
|
||||
public void grantItems(Player p) {
|
||||
PlayerInventory inv = p.getInventory();
|
||||
|
||||
// Fork over the items.
|
||||
items.forEach(item -> item.giveTo(p));
|
||||
|
||||
|
@ -294,8 +292,9 @@ public class ArenaClass
|
|||
case ENDER_CHEST:
|
||||
case SHULKER_SHELL:
|
||||
return true;
|
||||
default:
|
||||
return type.name().endsWith("SHULKER_BOX");
|
||||
}
|
||||
return type.name().endsWith("SHULKER_BOX");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ import java.util.Collections;
|
|||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -87,7 +88,7 @@ public class ArenaImpl implements Arena
|
|||
private ConfigurationSection settings;
|
||||
|
||||
// Run-time settings and critical config settings
|
||||
private boolean enabled, protect, running, edit;
|
||||
private boolean enabled, protect, running, edit, rejoin;
|
||||
|
||||
// World stuff
|
||||
private boolean allowMonsters, allowAnimals;
|
||||
|
@ -165,6 +166,7 @@ public class ArenaImpl implements Arena
|
|||
|
||||
this.enabled = settings.getBoolean("enabled", false);
|
||||
this.protect = settings.getBoolean("protect", true);
|
||||
this.rejoin = settings.getBoolean("rejoin", false);
|
||||
this.running = false;
|
||||
this.edit = false;
|
||||
|
||||
|
@ -487,9 +489,62 @@ public class ArenaImpl implements Arena
|
|||
announce(msg.toString());
|
||||
}
|
||||
|
||||
private boolean addReadyPlayers() {
|
||||
for (Player p : readyPlayers) {
|
||||
lobbyPlayers.remove(p);
|
||||
arenaPlayers.add(p);
|
||||
readyPlayers.remove(p);
|
||||
|
||||
// Teleport player, give full health, initialize map
|
||||
// Remove player from spec list to avoid invincibility issues
|
||||
if (inSpec(p)) {
|
||||
specPlayers.remove(p);
|
||||
System.out.println("[MobArena] Player " + p.getName() + " joined the arena from the spec area!");
|
||||
System.out.println("[MobArena] Invincibility glitch attempt stopped!");
|
||||
}
|
||||
|
||||
movingPlayers.add(p);
|
||||
if (arenaWarpOffset > 0.01) {
|
||||
Location warp = region.getArenaWarp();
|
||||
double x = warp.getX() + (arenaWarpOffset * 2 * (Math.random() - 0.5));
|
||||
double y = warp.getY();
|
||||
double z = warp.getZ() + (arenaWarpOffset * 2 * (Math.random() - 0.5));
|
||||
Location offset = new Location(warp.getWorld(), x, y, z);
|
||||
p.teleport(offset);
|
||||
} else {
|
||||
p.teleport(region.getArenaWarp());
|
||||
}
|
||||
movingPlayers.remove(p);
|
||||
|
||||
addClassPermissions(p);
|
||||
arenaPlayerMap.get(p).resetStats();
|
||||
|
||||
Thing price = arenaPlayerMap.get(p).getArenaClass().getPrice();
|
||||
if (price != null) {
|
||||
price.takeFrom(p);
|
||||
}
|
||||
|
||||
monsterManager.getBossMonsters().forEach(entity -> {
|
||||
MABoss boss = monsterManager.getBoss(entity);
|
||||
if (boss != null) {
|
||||
boss.getHealthBar().addPlayer(p);
|
||||
}
|
||||
});
|
||||
|
||||
scoreboard.removePlayer(p);
|
||||
scoreboard.addPlayer(p);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startArena() {
|
||||
// Sanity-checks
|
||||
if (running && rejoin) {
|
||||
return addReadyPlayers();
|
||||
}
|
||||
|
||||
if (running || lobbyPlayers.isEmpty() || !readyPlayers.containsAll(lobbyPlayers)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1402,6 +1457,8 @@ public class ArenaImpl implements Arena
|
|||
case PRIMED_TNT:
|
||||
case SHULKER_BULLET:
|
||||
e.remove();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1459,6 +1516,11 @@ public class ArenaImpl implements Arena
|
|||
return deadPlayers.contains(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRejoin() {
|
||||
return rejoin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String configName()
|
||||
{
|
||||
|
@ -1579,7 +1641,7 @@ public class ArenaImpl implements Arena
|
|||
messenger.tell(p, Msg.JOIN_ARENA_EDIT_MODE);
|
||||
else if (arenaPlayers.contains(p) || lobbyPlayers.contains(p))
|
||||
messenger.tell(p, Msg.JOIN_ALREADY_PLAYING);
|
||||
else if (running)
|
||||
else if (running && !rejoin)
|
||||
messenger.tell(p, Msg.JOIN_ARENA_IS_RUNNING);
|
||||
else if (!hasPermission(p))
|
||||
messenger.tell(p, Msg.JOIN_ARENA_PERMISSION);
|
||||
|
|
|
@ -329,6 +329,8 @@ public class ArenaListener
|
|||
case SNOW:
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,6 +356,8 @@ public class ArenaListener
|
|||
case LAVA:
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,6 +414,8 @@ public class ArenaListener
|
|||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// If not custom, we probably don't want it, so get rid of it
|
||||
|
|
|
@ -81,11 +81,6 @@ public class ScoreboardManager {
|
|||
return;
|
||||
}
|
||||
|
||||
String name = ChatColor.GRAY + player.getName();
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 15);
|
||||
}
|
||||
|
||||
Score score = kills.getScore(player.getName());
|
||||
if (score == null) {
|
||||
return;
|
||||
|
@ -94,18 +89,25 @@ public class ScoreboardManager {
|
|||
int value = score.getScore();
|
||||
scoreboard.resetScores(player.getName());
|
||||
|
||||
/* In case the player has no kills, they will not show up on the
|
||||
* scoreboard unless they are first given a different score.
|
||||
* If zero kills, the score is set to 8 (which looks a bit like
|
||||
* 0), and then in the next tick, it's set to 0. Otherwise, the
|
||||
* score is just set to its current value.
|
||||
*/
|
||||
final Score fake = kills.getScore(name);
|
||||
if (value == 0) {
|
||||
fake.setScore(8);
|
||||
arena.scheduleTask(() -> fake.setScore(0), 1);
|
||||
} else {
|
||||
fake.setScore(value);
|
||||
if (!arena.canRejoin()) {
|
||||
/* In case the player has no kills, they will not show up on the
|
||||
* scoreboard unless they are first given a different score.
|
||||
* If zero kills, the score is set to 8 (which looks a bit like
|
||||
* 0), and then in the next tick, it's set to 0. Otherwise, the
|
||||
* score is just set to its current value.
|
||||
*/
|
||||
String name = ChatColor.GRAY + player.getName();
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 15);
|
||||
}
|
||||
|
||||
final Score fake = kills.getScore(name);
|
||||
if (value == 0) {
|
||||
fake.setScore(8);
|
||||
arena.scheduleTask(() -> fake.setScore(0), 1);
|
||||
} else {
|
||||
fake.setScore(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,6 @@ import com.garbagemule.MobArena.util.Slugs;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandInfo(
|
||||
name = "addarena",
|
||||
pattern = "(add|new)arena",
|
||||
|
|
|
@ -328,8 +328,9 @@ public class SetupCommand implements Command, Listener {
|
|||
switch (action) {
|
||||
case LEFT_CLICK_BLOCK: regions(lower, loc); return true;
|
||||
case RIGHT_CLICK_BLOCK: regions(upper, loc); return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean warps(PlayerInteractEvent event) {
|
||||
|
@ -350,8 +351,9 @@ public class SetupCommand implements Command, Listener {
|
|||
}
|
||||
next = formatYellow("Current warp: %s", warpArray[warpIndex]);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean spawns(PlayerInteractEvent event) {
|
||||
|
@ -364,8 +366,9 @@ public class SetupCommand implements Command, Listener {
|
|||
switch (event.getAction()) {
|
||||
case LEFT_CLICK_BLOCK: spawns(l, true); return true;
|
||||
case RIGHT_CLICK_BLOCK: spawns(l, false); return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean chests(PlayerInteractEvent event) {
|
||||
|
@ -377,8 +380,9 @@ public class SetupCommand implements Command, Listener {
|
|||
switch (event.getAction()) {
|
||||
case LEFT_CLICK_BLOCK: chests(b, true); return true;
|
||||
case RIGHT_CLICK_BLOCK: chests(b, false); return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void fix(Location loc) {
|
||||
|
|
|
@ -128,7 +128,43 @@ class Environment {
|
|||
operators.add(i, token);
|
||||
}
|
||||
|
||||
@SuppressWarnings("Convert2MethodRef")
|
||||
// math functions implemented here to get rid of "unchecked conversion" warnings...
|
||||
private static Double sqrt(Double a) {
|
||||
return Math.sqrt(a);
|
||||
}
|
||||
|
||||
private static Double abs(Double a) {
|
||||
return Math.abs(a);
|
||||
}
|
||||
|
||||
private static Double ceil(Double a) {
|
||||
return Math.ceil(a);
|
||||
}
|
||||
|
||||
private static Double floor(Double a) {
|
||||
return Math.floor(a);
|
||||
}
|
||||
|
||||
private static Double sin(Double a) {
|
||||
return Math.sin(a);
|
||||
}
|
||||
|
||||
private static Double cos(Double a) {
|
||||
return Math.cos(a);
|
||||
}
|
||||
|
||||
private static Double tan(Double a) {
|
||||
return Math.tan(a);
|
||||
}
|
||||
|
||||
private static Double min(Double a, Double b) {
|
||||
return Math.min(a, b);
|
||||
}
|
||||
|
||||
private static Double max(Double a, Double b) {
|
||||
return Math.max(a, b);
|
||||
}
|
||||
|
||||
static Environment createDefault() {
|
||||
Environment result = new Environment();
|
||||
|
||||
|
@ -149,20 +185,20 @@ class Environment {
|
|||
result.registerBinaryOperator("^", 4, false, (a, b) -> Math.pow(a, b));
|
||||
|
||||
// Unary functions
|
||||
result.registerUnaryFunction("sqrt", Math::sqrt);
|
||||
result.registerUnaryFunction("abs", Math::abs);
|
||||
result.registerUnaryFunction("sqrt", Environment::sqrt);
|
||||
result.registerUnaryFunction("abs", Environment::abs);
|
||||
|
||||
result.registerUnaryFunction("ceil", Math::ceil);
|
||||
result.registerUnaryFunction("floor", Math::floor);
|
||||
result.registerUnaryFunction("ceil", Environment::ceil);
|
||||
result.registerUnaryFunction("floor", Environment::floor);
|
||||
result.registerUnaryFunction("round", value -> (double) Math.round(value));
|
||||
|
||||
result.registerUnaryFunction("sin", Math::sin);
|
||||
result.registerUnaryFunction("cos", Math::cos);
|
||||
result.registerUnaryFunction("tan", Math::tan);
|
||||
result.registerUnaryFunction("sin", Environment::sin);
|
||||
result.registerUnaryFunction("cos", Environment::cos);
|
||||
result.registerUnaryFunction("tan", Environment::tan);
|
||||
|
||||
// Binary functions
|
||||
result.registerBinaryFunction("min", Math::min);
|
||||
result.registerBinaryFunction("max", Math::max);
|
||||
result.registerBinaryFunction("min", Environment::min);
|
||||
result.registerBinaryFunction("max", Environment::max);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -20,32 +20,26 @@ public class FormulaManager {
|
|||
this.parser = parser;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void registerConstant(String name, double value) {
|
||||
env.registerConstant(name, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void registerVariable(String name, Formula formula) {
|
||||
env.registerVariable(name, formula);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void registerUnaryOperator(String symbol, int precedence, UnaryOperation operation) {
|
||||
env.registerUnaryOperator(symbol, precedence, operation);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void registerBinaryOperator(String symbol, int precedence, boolean left, BinaryOperation operation) {
|
||||
env.registerBinaryOperator(symbol, precedence, left, operation);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void registerUnaryFunction(String name, UnaryOperation operation) {
|
||||
env.registerUnaryFunction(name, operation);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void registerBinaryFunction(String name, BinaryOperation operation) {
|
||||
env.registerBinaryFunction(name, operation);
|
||||
}
|
||||
|
|
|
@ -219,6 +219,8 @@ public interface Arena
|
|||
|
||||
boolean isDead(Player p);
|
||||
|
||||
boolean canRejoin();
|
||||
|
||||
String configName();
|
||||
|
||||
/**
|
||||
|
|
|
@ -266,6 +266,8 @@ public class Leaderboard
|
|||
case SOUTH: return BlockFace.EAST;
|
||||
case WEST: return BlockFace.SOUTH;
|
||||
case EAST: return BlockFace.NORTH;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -524,8 +524,8 @@ public class ArenaRegion
|
|||
}
|
||||
|
||||
// Set the coords and save
|
||||
if (lower != null) setLocation(coords, r1.name().toLowerCase(), lower);
|
||||
if (upper != null) setLocation(coords, r2.name().toLowerCase(), upper);
|
||||
if (lower != null && r1 != null) setLocation(coords, r1.name().toLowerCase(), lower);
|
||||
if (upper != null && r2 != null) setLocation(coords, r2.name().toLowerCase(), upper);
|
||||
save();
|
||||
|
||||
// Reload regions and verify data
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.io.Serializable;
|
|||
* NOTE: I (garbagemule) DID NOT WRITE THIS CLASS (notice the author below)
|
||||
* @author creadri
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EntityPosition implements Serializable{
|
||||
private double x;
|
||||
private double y;
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.text.DecimalFormatSymbols;
|
|||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -46,11 +47,21 @@ public class ConfigUtils
|
|||
if (is == null) {
|
||||
throw new IllegalStateException("Couldn't read " + res + " from jar, please re-install MobArena");
|
||||
}
|
||||
Scanner scanner = new Scanner(is).useDelimiter("\\A");
|
||||
if (!scanner.hasNext()) {
|
||||
throw new IllegalStateException("No content in " + res + " in jar, please re-install MobArena");
|
||||
String contents;
|
||||
Scanner scanner = null;
|
||||
try {
|
||||
scanner = new Scanner(is).useDelimiter("\\A");
|
||||
contents = scanner.next();
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new IllegalStateException("No content in " + res + " in jar, please re-install MobArena");
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
if (scanner != null) {
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
String contents = scanner.next();
|
||||
|
||||
YamlConfiguration yaml = new YamlConfiguration();
|
||||
try {
|
||||
yaml.loadFromString(contents);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.garbagemule.MobArena.waves;
|
||||
|
||||
import com.garbagemule.MobArena.healthbar.HealthBar;
|
||||
import com.garbagemule.MobArena.things.Thing;
|
||||
import com.garbagemule.MobArena.things.ThingPicker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
|
|
@ -98,6 +98,8 @@ public class WaveParser
|
|||
case BOSS:
|
||||
result = parseBossWave(arena, name, config);
|
||||
break;
|
||||
default:
|
||||
throw new ConfigError("Unknown wave type for wave " + name + " of arena " + arena.configName() + ": " + t);
|
||||
}
|
||||
|
||||
// Grab the branch-specific nodes.
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.garbagemule.MobArena.Msg;
|
|||
import com.garbagemule.MobArena.formula.Formula;
|
||||
import com.garbagemule.MobArena.formula.Formulas;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import com.garbagemule.MobArena.things.Thing;
|
||||
import com.garbagemule.MobArena.things.ThingPicker;
|
||||
import com.garbagemule.MobArena.waves.AbstractWave;
|
||||
import com.garbagemule.MobArena.waves.BossAbilityThread;
|
||||
|
|
|
@ -48,3 +48,4 @@ announcer-type: title
|
|||
global-join-announce: false
|
||||
global-end-announce: false
|
||||
show-death-messages: true
|
||||
rejoin: false
|
||||
|
|
Loading…
Reference in New Issue