Compare commits
6 Commits
4068eae5bb
...
master
Author | SHA1 | Date | |
---|---|---|---|
1fa5fdfeb7 | |||
3bec5f4cbd | |||
d38871eac9 | |||
238df2feff | |||
e752d7f73b | |||
b0df982be3 |
@@ -1,4 +1,4 @@
|
|||||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.security.antiAutoTotem;
|
package eu.mhsl.craftattack.spawn.common.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.craftattack.appliances.security.antiAutoTotem;
|
package eu.mhsl.craftattack.spawn.common.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;
|
@@ -14,6 +14,11 @@ 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);
|
||||||
@@ -22,8 +27,9 @@ 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(Component.text("Das Bearbeiten von Schildern ist in deinen Einstellungen deaktiviert.", NamedTextColor.RED));
|
p.sendActionBar(this.disallowMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +38,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(Component.text("Das Bearbeiten von Schildern, welch bereits beschrieben sind, ist bei dir deaktiviert.", NamedTextColor.RED));
|
p.sendActionBar(this.disallowMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ public class DoubleDoorSetting extends BoolSetting implements CategorizedSetting
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean defaultValue() {
|
protected Boolean defaultValue() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -45,6 +45,6 @@ public class KnockDoorSetting extends SelectSetting implements CategorizedSettin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Options.Option defaultValue() {
|
protected Options.Option defaultValue() {
|
||||||
return disabled;
|
return knockThreeTimes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ 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;
|
||||||
@@ -48,6 +49,29 @@ 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.");
|
||||||
@@ -103,7 +127,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 Standard Regeln!", NamedTextColor.GOLD));
|
.append(Component.text("Es gelten die normalen 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,20 +8,23 @@ 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("vogelfrei");
|
super(commandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
try {
|
if(args.length == 1 && args[0].equals("confirm")) {
|
||||||
this.getAppliance().switchLawStatus(this.getPlayer());
|
try {
|
||||||
sender.sendMessage(
|
this.getAppliance().switchLawStatus(this.getPlayer());
|
||||||
this.getAppliance()
|
sender.sendMessage(this.getAppliance().getStatusDescription(this.getAppliance().getLawStatus(this.getPlayer())));
|
||||||
.getStatusDescription(this.getAppliance().getLawStatus(this.getPlayer()))
|
} catch(OutlawChangeNotPermitted e) {
|
||||||
);
|
sender.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED));
|
||||||
} catch(OutlawChangeNotPermitted e) {
|
}
|
||||||
sender.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED));
|
} else {
|
||||||
|
this.getAppliance().askForConfirmation(this.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,17 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user