SteamWar/MissileWars
Archiviert
13
0

Add RandomPlayerScript
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-11-14 17:24:37 +01:00
Ursprung e08982f594
Commit 67847c8ff9
3 geänderte Dateien mit 54 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -87,6 +87,8 @@ public class Script {
return new SlowMoScript(jsonObject); return new SlowMoScript(jsonObject);
case "cooldown": case "cooldown":
return new CooldownScript(jsonObject); return new CooldownScript(jsonObject);
case "randomplayer":
return new RandomPlayerScript(jsonObject);
default: default:
return null; return null;
} }

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.misslewars.scripts.utils.JsonUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LingeringPotion;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;

Datei anzeigen

@ -0,0 +1,51 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.misslewars.scripts.implemented;
import com.google.gson.JsonObject;
import de.steamwar.misslewars.MWTeam;
import de.steamwar.misslewars.MissileWars;
import de.steamwar.misslewars.scripts.RunnableScript;
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
import org.bukkit.entity.Player;
import java.util.LinkedList;
import java.util.Random;
public class RandomPlayerScript implements RunnableScript {
private Random random = new Random();
public RandomPlayerScript(JsonObject __) {
}
@Override
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
MWTeam mwTeam = MissileWars.getBlueTeam();
if (Math.random() > 0.5) mwTeam = MissileWars.getRedTeam();
LinkedList<Player> players = mwTeam.getPlayers();
Player player = players.get(random.nextInt(players.size()));
runnableScriptEvent.setLocationType(RunnableScriptEvent.LocationType.CUSTOM);
runnableScriptEvent.setCustomLocation(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getLocation().getPitch(), player.getLocation().getYaw());
return true;
}
}