Added "faction chunk at %player%" Skript Expression
This commit is contained in:
parent
72799966c7
commit
9094cb4f70
2
pom.xml
2
pom.xml
@ -330,7 +330,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>CoreProtect</artifactId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<version>2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
@ -0,0 +1,55 @@
|
||||
package com.massivecraft.factions.skript.expressions.player;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.ExpressionType;
|
||||
import ch.njol.skript.lang.SkriptParser;
|
||||
import ch.njol.skript.lang.util.SimpleExpression;
|
||||
import ch.njol.util.Kleenean;
|
||||
import com.massivecraft.factions.*;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class PlayerChunkLocationExpression extends SimpleExpression<String> {
|
||||
|
||||
static{
|
||||
Skript.registerExpression(PlayerChunkLocationExpression.class, String.class, ExpressionType.SIMPLE,"[the] faction chunk at %player%", "[the] %player%['s] chunk");
|
||||
}
|
||||
|
||||
Expression<Player> playerExpression;
|
||||
|
||||
public Class<? extends String> getReturnType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
|
||||
playerExpression = (Expression<Player>) exprs[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean debug) {
|
||||
return "Player Location Expression with expression faction" + playerExpression.toString(event, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] get(Event event) {
|
||||
Player player = playerExpression.getSingle(event);
|
||||
|
||||
if (player != null) {
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
FLocation floc = new FLocation(fPlayer.getPlayer().getLocation());
|
||||
Faction fac = Board.getInstance().getFactionAt(floc);
|
||||
return new String[]{String.valueOf(fac.getTag())};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -91,7 +91,5 @@ public class PlayerFactionExpression extends SimpleExpression<String> {
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user