Compare commits
13 Commits
develop-de
...
develop-bl
Author | SHA1 | Date | |
---|---|---|---|
9433495a52 | |||
4955e94306 | |||
09abfefe33 | |||
bd3546abc8 | |||
8a7a0453ce | |||
64d0d817c0 | |||
713561bf07 | |||
4be3e528b1 | |||
53fca580f3 | |||
20fb4bf9fb | |||
c42d259909 | |||
5c82c8d6da | |||
5910847172 |
@@ -6,6 +6,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CraftAttackApi {
|
||||
@@ -25,4 +26,8 @@ public class CraftAttackApi {
|
||||
public static void withAuthorizationSecret(URIBuilder builder) {
|
||||
builder.addParameter("secret", apiSecret);
|
||||
}
|
||||
|
||||
public static void withAuthorizationHeader(HttpRequest.Builder builder) {
|
||||
builder.header("Authorization", apiSecret);
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import java.util.UUID;
|
||||
|
||||
public class CraftAttackReportRepository extends ReportRepository {
|
||||
public CraftAttackReportRepository() {
|
||||
super(CraftAttackApi.getBaseUri(), new RequestModifier(CraftAttackApi::withAuthorizationSecret, null));
|
||||
super(CraftAttackApi.getBaseUri(), new RequestModifier(null, CraftAttackApi::withAuthorizationHeader));
|
||||
}
|
||||
|
||||
public ReqResp<PlayerReports> queryReports(UUID player) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.common.api.repositories.ReportRepository;
|
||||
import eu.mhsl.craftattack.spawn.common.api.repositories.VaroReportRepository;
|
||||
import eu.mhsl.craftattack.spawn.core.Main;
|
||||
import eu.mhsl.craftattack.spawn.core.api.client.ReqResp;
|
||||
import eu.mhsl.craftattack.spawn.common.api.repositories.CraftAttackReportRepository;
|
||||
@@ -64,7 +63,7 @@ public class Report extends Appliance {
|
||||
}
|
||||
|
||||
private void createReport(Player issuer, ReportRepository.ReportCreationInfo reportRequest) {
|
||||
ReqResp<ReportRepository.ReportUrl> createdReport = this.queryRepository(VaroReportRepository.class)
|
||||
ReqResp<ReportRepository.ReportUrl> createdReport = this.queryRepository(CraftAttackReportRepository.class) // TODO: Besser machen!!
|
||||
.createReport(reportRequest);
|
||||
|
||||
switch(createdReport.status()) {
|
||||
@@ -115,7 +114,7 @@ public class Report extends Appliance {
|
||||
}
|
||||
|
||||
public void queryReports(Player issuer) {
|
||||
ReqResp<ReportRepository.PlayerReports> userReports = this.queryRepository(VaroReportRepository.class)
|
||||
ReqResp<ReportRepository.PlayerReports> userReports = this.queryRepository(CraftAttackReportRepository.class) // TODO: Besser machen!!
|
||||
.queryReports(issuer.getUniqueId());
|
||||
|
||||
if(userReports.status() != 200) {
|
||||
|
@@ -9,6 +9,7 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
class PlayerLimiterListener extends ApplianceListener<PlayerLimit> {
|
||||
@EventHandler
|
||||
public void onLogin(AsyncPlayerPreLoginEvent playerPreLoginEvent) {
|
||||
if(Bukkit.getOnlinePlayers().size() >= this.getAppliance().getLimit()) {
|
||||
playerPreLoginEvent.kickMessage(
|
||||
new DisconnectInfo(
|
||||
"Hohe Serverauslastung",
|
||||
@@ -17,8 +18,7 @@ class PlayerLimiterListener extends ApplianceListener<PlayerLimit> {
|
||||
playerPreLoginEvent.getUniqueId()
|
||||
).getComponent()
|
||||
);
|
||||
|
||||
if(Bukkit.getOnlinePlayers().size() >= this.getAppliance().getLimit())
|
||||
playerPreLoginEvent.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_FULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import java.util.UUID;
|
||||
|
||||
public class FeedbackRepository extends HttpRepository {
|
||||
public FeedbackRepository() {
|
||||
super(CraftAttackApi.getBaseUri(), new RequestModifier(CraftAttackApi::withAuthorizationSecret, null));
|
||||
super(CraftAttackApi.getBaseUri(), new RequestModifier(null, CraftAttackApi::withAuthorizationHeader));
|
||||
}
|
||||
|
||||
public record Request(String event, List<UUID> users) {
|
||||
|
@@ -8,7 +8,7 @@ import java.util.UUID;
|
||||
|
||||
public class WhitelistRepository extends HttpRepository {
|
||||
public WhitelistRepository() {
|
||||
super(CraftAttackApi.getBaseUri(), new RequestModifier(CraftAttackApi::withAuthorizationSecret, null));
|
||||
super(CraftAttackApi.getBaseUri(), new RequestModifier(null, CraftAttackApi::withAuthorizationHeader));
|
||||
}
|
||||
|
||||
public record UserData(
|
||||
@@ -21,10 +21,12 @@ public class WhitelistRepository extends HttpRepository {
|
||||
) {
|
||||
}
|
||||
|
||||
private record UserQuery(UUID uuid) {}
|
||||
|
||||
public ReqResp<UserData> getUserData(UUID userId) {
|
||||
return this.get(
|
||||
"user",
|
||||
parameters -> parameters.addParameter("uuid", userId.toString()),
|
||||
return this.post(
|
||||
"player",
|
||||
new UserQuery(userId),
|
||||
UserData.class
|
||||
);
|
||||
}
|
||||
|
@@ -0,0 +1,136 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.commands.BloodmoonCommand;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonMonsterDeathListener;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonPlayerJoinListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class Bloodmoon extends Appliance {
|
||||
// für alle Dimensionen? einstellbar machen?
|
||||
|
||||
public final Map<EntityType, PotionEffect[]> affectedMobEffectMap = Map.of(
|
||||
EntityType.ZOMBIE, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.WITHER, 7 * 20, 1)
|
||||
},
|
||||
EntityType.SKELETON, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.SLOWNESS, (int) (3.5 * 20), 1)
|
||||
},
|
||||
EntityType.SPIDER, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.POISON, 4 * 20, 1),
|
||||
new PotionEffect(PotionEffectType.NAUSEA, 6 * 20, 10)
|
||||
},
|
||||
EntityType.CREEPER, new PotionEffect[]{
|
||||
new LightningPotionEffect()
|
||||
},
|
||||
EntityType.HUSK, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.WITHER, 7 * 20, 1)
|
||||
},
|
||||
EntityType.DROWNED, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.WITHER, 7 * 20, 1)
|
||||
},
|
||||
EntityType.WITCH, new PotionEffect[]{},
|
||||
EntityType.ZOMBIE_VILLAGER, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.WITHER, 7 * 20, 1)
|
||||
},
|
||||
EntityType.PHANTOM, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.LEVITATION, (int) (1.5 * 20), 3)
|
||||
},
|
||||
EntityType.ENDERMAN, new PotionEffect[]{
|
||||
new PotionEffect(PotionEffectType.SLOWNESS, (int) (2.5 * 20), 2)
|
||||
}
|
||||
);
|
||||
public final int expMultiplier = 4;
|
||||
public final boolean lightningsActive = true;
|
||||
|
||||
private boolean isActive = false;
|
||||
private final BossBar bossBar = Bukkit.createBossBar(
|
||||
"Bloodmoon",
|
||||
BarColor.RED,
|
||||
BarStyle.SEGMENTED_12,
|
||||
BarFlag.CREATE_FOG,
|
||||
BarFlag.DARKEN_SKY
|
||||
);
|
||||
private final int bloodMoonLegth = 12000;
|
||||
private final int daysBetweenBloodmoons = 1;
|
||||
private final int minBonusDrops = 1;
|
||||
private final int maxBonusDrops = 4;
|
||||
private final Map<ItemStack, Integer> bonusDropWeightMap = Map.of(
|
||||
new ItemStack(Material.IRON_INGOT, 5), 10,
|
||||
new ItemStack(Material.GOLD_INGOT, 2), 5,
|
||||
new ItemStack(Material.DIAMOND, 1), 1,
|
||||
new ItemStack(Material.IRON_BLOCK, 1), 5,
|
||||
new ItemStack(Material.GOLD_BLOCK, 1), 2
|
||||
);
|
||||
|
||||
public boolean bloodmoonIsActive() {
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
public void startBloodmoon() {
|
||||
this.isActive = true;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> this.bossBar.addPlayer(player));
|
||||
}
|
||||
|
||||
public void stopBloodmoon() {
|
||||
this.isActive = false;
|
||||
this.bossBar.removeAll();
|
||||
}
|
||||
|
||||
public void addPlayerToBossBar(Player p) {
|
||||
this.bossBar.addPlayer(p);
|
||||
}
|
||||
|
||||
public List<ItemStack> getRandomBonusDrops() {
|
||||
int itemCount = ThreadLocalRandom.current().nextInt(this.minBonusDrops, this.maxBonusDrops + 1);
|
||||
List<ItemStack> result = new ArrayList<>();
|
||||
for(int i = 0; i < itemCount; i++) {
|
||||
result.add(this.getRandomBonusDrop());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ItemStack getRandomBonusDrop() {
|
||||
int totalWeight = this.bonusDropWeightMap.values().stream().mapToInt(value -> value).sum();
|
||||
int randomInt = ThreadLocalRandom.current().nextInt(0, totalWeight + 1);
|
||||
int cumulativeWeight = 0;
|
||||
for(Map.Entry<ItemStack, Integer> entry : this.bonusDropWeightMap.entrySet()) {
|
||||
cumulativeWeight += entry.getValue();
|
||||
if(randomInt <= cumulativeWeight) return entry.getKey();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(
|
||||
new BloodmoonMonsterDeathListener(),
|
||||
new BloodmoonPlayerJoinListener()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<ApplianceCommand<?>> commands() {
|
||||
return List.of(
|
||||
new BloodmoonCommand()
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class LightningPotionEffect extends PotionEffect {
|
||||
public LightningPotionEffect() {
|
||||
super(PotionEffectType.SLOWNESS, 0, 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.commands;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BloodmoonCommand extends ApplianceCommand<Bloodmoon> {
|
||||
public BloodmoonCommand() {
|
||||
super("bloodmoon");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
||||
if(args.length == 0) {
|
||||
sender.sendMessage("Bloodmoon is currently " + (this.getAppliance().bloodmoonIsActive() ? "active." : "inactive."));
|
||||
return;
|
||||
}
|
||||
|
||||
switch(args[0]) {
|
||||
case "start": {
|
||||
this.getAppliance().startBloodmoon();
|
||||
sender.sendMessage("Started bloodmoon.");
|
||||
break;
|
||||
}
|
||||
case "stop": {
|
||||
this.getAppliance().stopBloodmoon();
|
||||
sender.sendMessage("Stopped bloodmoon.");
|
||||
break;
|
||||
}
|
||||
default: throw new Error("No such option: '" + args[0] + "' !");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length == 1) return List.of("start", "stop");
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class BloodmoonEntityDamageListener extends ApplianceListener<Bloodmoon> {
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||
if(!this.getAppliance().bloodmoonIsActive()) return;
|
||||
Entity damagerEntity = event.getDamager();
|
||||
if(damagerEntity instanceof Projectile projectile) {
|
||||
if(!(projectile.getShooter() instanceof Entity shooter)) return;
|
||||
damagerEntity = shooter;
|
||||
}
|
||||
if(!(damagerEntity instanceof LivingEntity damager && event.getEntity() instanceof LivingEntity receiver)) return;
|
||||
if(event.getFinalDamage() == 0) return;
|
||||
|
||||
// TODO: damage increase / reduction and effects
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
public class BloodmoonMonsterDeathListener extends ApplianceListener<Bloodmoon> {
|
||||
@EventHandler
|
||||
public void onMonsterDeath(EntityDeathEvent event) {
|
||||
if(!this.getAppliance().bloodmoonIsActive()) return;
|
||||
LivingEntity entity = event.getEntity();
|
||||
if(!this.getAppliance().affectedMobEffectMap.containsKey(entity.getType())) return;
|
||||
|
||||
event.setDroppedExp(event.getDroppedExp() * this.getAppliance().expMultiplier);
|
||||
event.getDrops().addAll(this.getAppliance().getRandomBonusDrops());
|
||||
if(this.getAppliance().lightningsActive) event.getEntity().getWorld().strikeLightningEffect(event.getEntity().getLocation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class BloodmoonPlayerJoinListener extends ApplianceListener<Bloodmoon> {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if(!this.getAppliance().bloodmoonIsActive()) return;
|
||||
this.getAppliance().addPlayerToBossBar(event.getPlayer());
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.ironGolemAnimation;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.Main;
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class IronGolemAnimation extends Appliance {
|
||||
record BlockChange(Block original, BlockData fakeBlock) {}
|
||||
|
||||
public void onGolemSpawn(IronGolem golem) {
|
||||
this.modifyGolem(golem, false);
|
||||
Location golemLocation = golem.getLocation();
|
||||
|
||||
BlockData bodyBlockData = Bukkit.createBlockData(Material.IRON_BLOCK);
|
||||
BlockData headBlockData = Bukkit.createBlockData(
|
||||
Material.CARVED_PUMPKIN,
|
||||
blockData -> ((Directional) blockData).setFacing(golem.getFacing())
|
||||
);
|
||||
Vector facingVector = golem.getFacing().getDirection().rotateAroundY(Math.toRadians(90));
|
||||
Block golemCenterBlock = golemLocation.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
List<BlockChange> buildBlocks = List.of(
|
||||
new BlockChange(golemCenterBlock.getRelative(BlockFace.DOWN), bodyBlockData),
|
||||
new BlockChange(golemCenterBlock, bodyBlockData),
|
||||
new BlockChange(golemCenterBlock.getLocation().add(facingVector).getBlock(), bodyBlockData),
|
||||
new BlockChange(golemCenterBlock.getLocation().add(facingVector.multiply(-1)).getBlock(), bodyBlockData),
|
||||
new BlockChange(golemCenterBlock.getRelative(BlockFace.UP), headBlockData)
|
||||
);
|
||||
|
||||
Collection<Player> viewers = golemLocation.getNearbyPlayers(golemLocation.getWorld().getViewDistance() * 16);
|
||||
BiConsumer<Location, BlockData> changeBlockForViewers = (location, blockData) -> {
|
||||
viewers.forEach(player -> player.sendBlockChange(location, blockData));
|
||||
golem.getWorld().playSound(
|
||||
location,
|
||||
blockData.getSoundGroup().getPlaceSound(),
|
||||
SoundCategory.BLOCKS,
|
||||
1f,
|
||||
1f
|
||||
);
|
||||
};
|
||||
for(int i = 0; i < buildBlocks.size(); i++) {
|
||||
BlockChange blockChange = buildBlocks.get(i);
|
||||
Bukkit.getScheduler().runTaskLater(
|
||||
Main.instance(),
|
||||
() -> changeBlockForViewers.accept(blockChange.original.getLocation(), blockChange.fakeBlock),
|
||||
6L * i
|
||||
);
|
||||
}
|
||||
|
||||
Consumer<List<BlockChange>> restoreBlockChanges = (blocks) -> {
|
||||
buildBlocks.forEach((blockChange) -> changeBlockForViewers.accept(
|
||||
blockChange.original().getLocation(),
|
||||
blockChange.original.getBlockData()
|
||||
));
|
||||
|
||||
this.modifyGolem(golem, true);
|
||||
this.spawnEffect(buildBlocks);
|
||||
};
|
||||
Bukkit.getScheduler().runTaskLater(
|
||||
Main.instance(),
|
||||
() -> restoreBlockChanges.accept(buildBlocks),
|
||||
6L * buildBlocks.size() + 2
|
||||
);
|
||||
}
|
||||
|
||||
private void spawnEffect(List<BlockChange> buildBlocks) {
|
||||
buildBlocks.forEach((blockChange) -> {
|
||||
World world = blockChange.original.getLocation().getWorld();
|
||||
world.spawnParticle(
|
||||
Particle.BLOCK,
|
||||
blockChange.original.getLocation().add(0.5, 0.5, 0.5),
|
||||
50,
|
||||
blockChange.fakeBlock
|
||||
);
|
||||
world.playSound(
|
||||
blockChange.original.getLocation(),
|
||||
blockChange.fakeBlock.getSoundGroup().getBreakSound(),
|
||||
SoundCategory.BLOCKS,
|
||||
1f,
|
||||
1f
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyGolem(IronGolem golem, boolean setVisible) {
|
||||
golem.setInvisible(!setVisible);
|
||||
golem.setInvulnerable(!setVisible);
|
||||
golem.setAI(setVisible);
|
||||
golem.setGravity(setVisible);
|
||||
golem.setCollidable(setVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(
|
||||
new NaturalIronGolemSpawnEvent()
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.ironGolemAnimation;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
class NaturalIronGolemSpawnEvent extends ApplianceListener<IronGolemAnimation> {
|
||||
@EventHandler
|
||||
public void onGolemSpawn(CreatureSpawnEvent event) {
|
||||
if(!(event.getEntity() instanceof IronGolem golem)) return;
|
||||
if(event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE) return;
|
||||
this.getAppliance().onGolemSpawn(golem);
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.recoveryCompass;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
class KeepRecoveryCompassOnDeathListener extends ApplianceListener<RecoveryCompass> {
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
ItemStack source = event.getDrops().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> item.getType() == Material.RECOVERY_COMPASS)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (source == null) return;
|
||||
|
||||
if (source.getAmount() > 1) {
|
||||
source.setAmount(source.getAmount() - 1);
|
||||
} else {
|
||||
event.getDrops().remove(source);
|
||||
}
|
||||
|
||||
ItemStack kept = source.clone();
|
||||
kept.setAmount(1);
|
||||
event.getItemsToKeep().add(kept);
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.recoveryCompass;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
class PlayerFirstJoinCompassGift extends ApplianceListener<RecoveryCompass> {
|
||||
private final NamespacedKey alreadyGiftedKey = new NamespacedKey(this.getClass().getSimpleName().toLowerCase(), "alreadyGifted".toLowerCase());
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PersistentDataContainer container = player.getPersistentDataContainer();
|
||||
if(container.has(alreadyGiftedKey)) return;
|
||||
player.getInventory().addItem(ItemStack.of(Material.RECOVERY_COMPASS));
|
||||
container.set(alreadyGiftedKey, PersistentDataType.BOOLEAN, true);
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.recoveryCompass;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RecoveryCompass extends Appliance {
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(
|
||||
new PlayerFirstJoinCompassGift(),
|
||||
new KeepRecoveryCompassOnDeathListener()
|
||||
);
|
||||
}
|
||||
}
|
@@ -118,7 +118,7 @@ public class Whitelist extends Appliance {
|
||||
);
|
||||
|
||||
if(response.status() != HttpStatus.OK)
|
||||
throw new IllegalStateException(String.format("Http Reponse %d", response.status()));
|
||||
throw new IllegalStateException(String.format("Unwanted response %d!", response.status()));
|
||||
|
||||
return response.data();
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.phantomReducer;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PhantomReducer extends Appliance {
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(
|
||||
new PhantomSpawnListener()
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.phantomReducer;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import org.bukkit.entity.Phantom;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
class PhantomSpawnListener extends ApplianceListener<PhantomReducer> {
|
||||
@EventHandler
|
||||
public void onPhantomSpawn(CreatureSpawnEvent event) {
|
||||
if(!(event.getEntity() instanceof Phantom)) return;
|
||||
if(ThreadLocalRandom.current().nextDouble() > 0.8) event.setCancelled(true);
|
||||
}
|
||||
}
|
24
local.gradle.example
Normal file
24
local.gradle.example
Normal file
@@ -0,0 +1,24 @@
|
||||
tasks.register('deployVaroPlugin', Copy) {
|
||||
dependsOn ":varo:shadowJar"
|
||||
from { project(":varo").shadowJar.archivePath }
|
||||
into file('path') // path to plugins folder
|
||||
rename { fileName -> "varo.jar" }
|
||||
}
|
||||
|
||||
tasks.register("uploadVaroPlugin") {
|
||||
dependsOn(":varo:shadowJar")
|
||||
|
||||
doLast {
|
||||
def jarFile = project(":varo").tasks.named("shadowJar").get().outputs.files.singleFile
|
||||
exec {
|
||||
commandLine "scp", "-4", "-P", "22", jarFile.absolutePath, "user@host:path/varo.jar"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('deployCraftAttackPlugin', Copy) {
|
||||
dependsOn ":craftattack:shadowJar"
|
||||
from { project(":craftattack").shadowJar.archivePath }
|
||||
into file('path') // path to plugins folder
|
||||
rename { fileName -> "craftattack.jar" }
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.appliances.tooling.antiGrief;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.appliance.Appliance;
|
||||
import eu.mhsl.craftattack.spawn.appliances.tooling.antiGrief.player.PlayerGriefListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AntiGrief extends Appliance {
|
||||
private final Map<Block, UUID> blockRegistry = new HashMap<>();
|
||||
|
||||
public void addTracking(Block block, UUID player) {
|
||||
this.blockRegistry.put(block, player);
|
||||
block.getLocation().getWorld().spawn(block.getLocation(), ItemDisplay.class, itemDisplay -> {
|
||||
itemDisplay.setItemStack(ItemStack.of(Material.FIRE_CHARGE));
|
||||
itemDisplay.teleport(block.getLocation().add(0.5, 0.5, 0.5));
|
||||
});
|
||||
}
|
||||
|
||||
public @Nullable UUID getTracked(Block block) {
|
||||
return this.blockRegistry.get(block);
|
||||
}
|
||||
|
||||
public void addDestroyed(Block block, UUID player) {
|
||||
block.getLocation().getWorld().spawn(block.getLocation().add(0.5, 0.5, 0.5), BlockDisplay.class, blockDisplay -> {
|
||||
blockDisplay.setBlock(Material.GOLD_BLOCK.createBlockData());
|
||||
|
||||
Transformation transformation = blockDisplay.getTransformation();
|
||||
transformation.getScale().set(0.3);
|
||||
blockDisplay.setTransformation(transformation);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(new PlayerGriefListener());
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.appliances.tooling.antiGrief.player;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
|
||||
import eu.mhsl.craftattack.spawn.appliances.tooling.antiGrief.AntiGrief;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerGriefListener extends ApplianceListener<AntiGrief> {
|
||||
@EventHandler
|
||||
public void onIgnite(BlockIgniteEvent event) {
|
||||
Bukkit.broadcast(Component.text(event.getCause().toString()));
|
||||
switch(event.getCause()) {
|
||||
case LAVA:
|
||||
case SPREAD:
|
||||
case EXPLOSION:
|
||||
if(event.getIgnitingBlock() == null) return;
|
||||
UUID ignitedBy = this.getAppliance().getTracked(event.getIgnitingBlock());
|
||||
this.getAppliance().addTracking(event.getBlock(), ignitedBy);
|
||||
break;
|
||||
|
||||
case FLINT_AND_STEEL:
|
||||
case ENDER_CRYSTAL:
|
||||
case ARROW:
|
||||
case FIREBALL:
|
||||
if(event.getPlayer() == null) return;
|
||||
this.getAppliance().addTracking(event.getBlock(), event.getPlayer().getUniqueId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpread(BlockSpreadEvent event) {
|
||||
if(!event.getBlock().getType().equals(Material.FIRE)) return;
|
||||
UUID ignitedBy = this.getAppliance().getTracked(event.getBlock());
|
||||
this.getAppliance().addTracking(event.getBlock(), ignitedBy);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDestroy(BlockBurnEvent event) {
|
||||
UUID ignitedBy = this.getAppliance().getTracked(event.getIgnitingBlock());
|
||||
if(ignitedBy == null) return;
|
||||
this.getAppliance().addDestroyed(event.getBlock(), ignitedBy);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user