Compare commits
2 Commits
master
...
4068eae5bb
Author | SHA1 | Date | |
---|---|---|---|
4068eae5bb | |||
092d33beb3 |
@@ -14,11 +14,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AntiSignEdit extends Appliance {
|
public class AntiSignEdit extends Appliance {
|
||||||
private final Component disallowMessage = Component.text(
|
|
||||||
"Nutze /settings um das Bearbeiten von Schildern zu aktivieren!",
|
|
||||||
NamedTextColor.RED
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Settings.instance().declareSetting(SignEditSetting.class);
|
Settings.instance().declareSetting(SignEditSetting.class);
|
||||||
@@ -27,9 +22,8 @@ public class AntiSignEdit extends Appliance {
|
|||||||
public boolean preventSignEdit(Player p, SignSide sign) {
|
public boolean preventSignEdit(Player p, SignSide sign) {
|
||||||
SelectSetting.Options.Option setting = Settings.instance().getSetting(p, Settings.Key.SignEdit, SelectSetting.Options.Option.class);
|
SelectSetting.Options.Option setting = Settings.instance().getSetting(p, Settings.Key.SignEdit, SelectSetting.Options.Option.class);
|
||||||
if(setting.is(SignEditSetting.editable)) return false;
|
if(setting.is(SignEditSetting.editable)) return false;
|
||||||
|
|
||||||
if(setting.is(SignEditSetting.readOnly)) {
|
if(setting.is(SignEditSetting.readOnly)) {
|
||||||
p.sendActionBar(this.disallowMessage);
|
p.sendActionBar(Component.text("Das Bearbeiten von Schildern ist in deinen Einstellungen deaktiviert.", NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +32,7 @@ public class AntiSignEdit extends Appliance {
|
|||||||
.anyMatch(line -> !PlainTextComponentSerializer.plainText().serialize(line).isBlank());
|
.anyMatch(line -> !PlainTextComponentSerializer.plainText().serialize(line).isBlank());
|
||||||
|
|
||||||
if(hasText) {
|
if(hasText) {
|
||||||
p.sendActionBar(this.disallowMessage);
|
p.sendActionBar(Component.text("Das Bearbeiten von Schildern, welch bereits beschrieben sind, ist bei dir deaktiviert.", NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ public class DoubleDoorSetting extends BoolSetting implements CategorizedSetting
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean defaultValue() {
|
protected Boolean defaultValue() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -45,6 +45,6 @@ public class KnockDoorSetting extends SelectSetting implements CategorizedSettin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Options.Option defaultValue() {
|
protected Options.Option defaultValue() {
|
||||||
return knockThreeTimes;
|
return disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@ import eu.mhsl.craftattack.spawn.craftattack.appliances.tooling.whitelist.Whitel
|
|||||||
import eu.mhsl.craftattack.spawn.core.config.Configuration;
|
import eu.mhsl.craftattack.spawn.core.config.Configuration;
|
||||||
import eu.mhsl.craftattack.spawn.core.util.text.DisconnectInfo;
|
import eu.mhsl.craftattack.spawn.core.util.text.DisconnectInfo;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -49,29 +48,6 @@ public class Outlawed extends Appliance implements DisplayName.Prefixed {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void askForConfirmation(Player player) {
|
|
||||||
Component confirmationMessage = switch(this.getLawStatus(player)) {
|
|
||||||
case DISABLED -> Component.text("Wenn du Vogelfrei aktivierst, darfst du von allen Spielern grundlos angegriffen werden.");
|
|
||||||
case VOLUNTARILY -> Component.text("Wenn du Vogelfrei deaktivierst, darfst du nicht mehr grundlos von Spielern angegriffen werden.");
|
|
||||||
case FORCED -> Component.text("Du darfst zurzeit deinen Vogelfreistatus nicht ändern, da dieser als Strafe auferlegt wurde!");
|
|
||||||
};
|
|
||||||
String command = String.format("/%s confirm", OutlawedCommand.commandName);
|
|
||||||
Component changeText = Component.text(
|
|
||||||
String.format(
|
|
||||||
"Zum ändern deines Vogelfrei status klicke auf diese Nachricht oder tippe '%s'",
|
|
||||||
command
|
|
||||||
),
|
|
||||||
NamedTextColor.GOLD
|
|
||||||
).clickEvent(ClickEvent.suggestCommand(command));
|
|
||||||
|
|
||||||
player.sendMessage(
|
|
||||||
Component.text()
|
|
||||||
.append(confirmationMessage.color(NamedTextColor.RED))
|
|
||||||
.appendNewline()
|
|
||||||
.append(changeText)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void switchLawStatus(Player player) throws OutlawChangeNotPermitted {
|
void switchLawStatus(Player player) throws OutlawChangeNotPermitted {
|
||||||
if(this.getLawStatus(player).equals(Status.FORCED)) {
|
if(this.getLawStatus(player).equals(Status.FORCED)) {
|
||||||
throw new OutlawChangeNotPermitted("Dein Vogelfreistatus wurde als Strafe auferlegt und kann daher nicht verändert werden.");
|
throw new OutlawChangeNotPermitted("Dein Vogelfreistatus wurde als Strafe auferlegt und kann daher nicht verändert werden.");
|
||||||
@@ -127,7 +103,7 @@ public class Outlawed extends Appliance implements DisplayName.Prefixed {
|
|||||||
public Component getStatusDescription(Status status) {
|
public Component getStatusDescription(Status status) {
|
||||||
return switch(status) {
|
return switch(status) {
|
||||||
case DISABLED -> Component.text("Vogelfreistatus inaktiv: ", NamedTextColor.GREEN)
|
case DISABLED -> Component.text("Vogelfreistatus inaktiv: ", NamedTextColor.GREEN)
|
||||||
.append(Component.text("Es gelten die normalen Regeln!", NamedTextColor.GOLD));
|
.append(Component.text("Es gelten die Standard Regeln!", NamedTextColor.GOLD));
|
||||||
|
|
||||||
case VOLUNTARILY, FORCED -> Component.text("Vogelfreistatus aktiv: ", NamedTextColor.RED)
|
case VOLUNTARILY, FORCED -> Component.text("Vogelfreistatus aktiv: ", NamedTextColor.RED)
|
||||||
.append(Component.text("Du darfst von jedem angegriffen und getötet werden!", NamedTextColor.GOLD));
|
.append(Component.text("Du darfst von jedem angegriffen und getötet werden!", NamedTextColor.GOLD));
|
||||||
|
@@ -8,23 +8,20 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
class OutlawedCommand extends ApplianceCommand.PlayerChecked<Outlawed> {
|
class OutlawedCommand extends ApplianceCommand.PlayerChecked<Outlawed> {
|
||||||
public static final String commandName = "vogelfrei";
|
|
||||||
|
|
||||||
public OutlawedCommand() {
|
public OutlawedCommand() {
|
||||||
super(commandName);
|
super("vogelfrei");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
||||||
if(args.length == 1 && args[0].equals("confirm")) {
|
|
||||||
try {
|
try {
|
||||||
this.getAppliance().switchLawStatus(this.getPlayer());
|
this.getAppliance().switchLawStatus(this.getPlayer());
|
||||||
sender.sendMessage(this.getAppliance().getStatusDescription(this.getAppliance().getLawStatus(this.getPlayer())));
|
sender.sendMessage(
|
||||||
|
this.getAppliance()
|
||||||
|
.getStatusDescription(this.getAppliance().getLawStatus(this.getPlayer()))
|
||||||
|
);
|
||||||
} catch(OutlawChangeNotPermitted e) {
|
} catch(OutlawChangeNotPermitted e) {
|
||||||
sender.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED));
|
sender.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.getAppliance().askForConfirmation(this.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package eu.mhsl.craftattack.spawn.common.appliances.security.antiAutoTotem;
|
package eu.mhsl.craftattack.spawn.craftattack.appliances.security.antiAutoTotem;
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.common.appliances.tooling.acInform.AcInform;
|
import eu.mhsl.craftattack.spawn.common.appliances.tooling.acInform.AcInform;
|
||||||
import eu.mhsl.craftattack.spawn.core.Main;
|
import eu.mhsl.craftattack.spawn.core.Main;
|
@@ -1,4 +1,4 @@
|
|||||||
package eu.mhsl.craftattack.spawn.common.appliances.security.antiAutoTotem;
|
package eu.mhsl.craftattack.spawn.craftattack.appliances.security.antiAutoTotem;
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
@@ -1,16 +0,0 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.armadilloInfectionReducer;
|
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ArmadilloInfectionReducer extends Appliance {
|
|
||||||
@Override
|
|
||||||
protected @NotNull List<Listener> listeners() {
|
|
||||||
return List.of(
|
|
||||||
new InfectionSpawnListener()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.armadilloInfectionReducer;
|
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
class InfectionSpawnListener extends ApplianceListener<ArmadilloInfectionReducer> {
|
|
||||||
@EventHandler
|
|
||||||
public void onSpawn(CreatureSpawnEvent event) {
|
|
||||||
if(!event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) return;
|
|
||||||
if(!event.getEntity().getType().equals(EntityType.SILVERFISH)) return;
|
|
||||||
if(ThreadLocalRandom.current().nextDouble() > 0.7) event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,16 +0,0 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.mendingReducer;
|
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MendingReducer extends Appliance {
|
|
||||||
@Override
|
|
||||||
protected @NotNull List<Listener> listeners() {
|
|
||||||
return List.of(
|
|
||||||
new MendingRepairListener()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.mendingReducer;
|
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerItemMendEvent;
|
|
||||||
|
|
||||||
public class MendingRepairListener extends ApplianceListener<MendingReducer> {
|
|
||||||
private static final double COST_MULTIPLIER = 2.0;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onMendingRepair(PlayerItemMendEvent event) {
|
|
||||||
int baseConsumed = event.getConsumedExperience();
|
|
||||||
int orbExp = event.getExperienceOrb().getExperience();
|
|
||||||
|
|
||||||
int desiredTotal = (int) Math.ceil(baseConsumed * COST_MULTIPLIER);
|
|
||||||
int extraCost = Math.max(0, desiredTotal - baseConsumed);
|
|
||||||
|
|
||||||
int maxExtraPossible = Math.max(0, orbExp - baseConsumed);
|
|
||||||
int extraApplied = Math.min(extraCost, maxExtraPossible);
|
|
||||||
|
|
||||||
if (extraApplied > 0) event.getExperienceOrb().setExperience(orbExp - extraApplied);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.silverfishExpReducer;
|
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
|
|
||||||
class SilverfishDeathListener extends ApplianceListener<SilverfishExpReducer> {
|
|
||||||
@EventHandler
|
|
||||||
public void onDeath(EntityDeathEvent event) {
|
|
||||||
if(!event.getEntity().getType().equals(EntityType.SILVERFISH)) return;
|
|
||||||
event.setDroppedExp(event.getDroppedExp() / 3);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,16 +0,0 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.silverfishExpReducer;
|
|
||||||
|
|
||||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SilverfishExpReducer extends Appliance {
|
|
||||||
@Override
|
|
||||||
public @NotNull List<Listener> listeners() {
|
|
||||||
return List.of(
|
|
||||||
new SilverfishDeathListener()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,49 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
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