Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5324749a64
@ -0,0 +1,39 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.appliances.endPrevent;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.appliance.Appliance;
|
||||||
|
import eu.mhsl.craftattack.spawn.appliance.ApplianceCommand;
|
||||||
|
import eu.mhsl.craftattack.spawn.config.Configuration;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EndPrevent extends Appliance {
|
||||||
|
private final String endDisabledKey = "endDisabled";
|
||||||
|
private boolean endDisabled;
|
||||||
|
|
||||||
|
public EndPrevent() {
|
||||||
|
super("endPrevent");
|
||||||
|
this.endDisabled = localConfig().getBoolean(endDisabledKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDisabled(boolean disabled) {
|
||||||
|
localConfig().set(endDisabledKey, disabled);
|
||||||
|
Configuration.saveChanges();
|
||||||
|
this.endDisabled = disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEndDisabled() {
|
||||||
|
return endDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NotNull List<Listener> listeners() {
|
||||||
|
return List.of(new PreventEnderEyeUseListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NotNull List<ApplianceCommand<?>> commands() {
|
||||||
|
return List.of(new EndPreventCommand());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.appliances.endPrevent;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.appliance.ApplianceCommand;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class EndPreventCommand extends ApplianceCommand<EndPrevent> {
|
||||||
|
private final Map<String, Boolean> arguments = Map.of("preventEnd", true, "allowEnd", false);
|
||||||
|
|
||||||
|
public EndPreventCommand() {
|
||||||
|
super("endPrevent");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
||||||
|
if(args.length == 1 && arguments.containsKey(args[0])) {
|
||||||
|
getAppliance().setEndDisabled(arguments.get(args[0]));
|
||||||
|
sender.sendMessage(Component.text("Setting updated!", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
sender.sendMessage(Component.text(
|
||||||
|
String.format("The End is %s!", getAppliance().isEndDisabled() ? "open" : "closed"),
|
||||||
|
NamedTextColor.GOLD
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
return arguments.keySet().stream().toList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.appliances.endPrevent;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
public class PreventEnderEyeUseListener extends ApplianceListener<EndPrevent> {
|
||||||
|
@EventHandler
|
||||||
|
public void onEnderEyeInteraction(PlayerInteractEvent event) {
|
||||||
|
if(event.getClickedBlock() == null) return;
|
||||||
|
if(!event.getClickedBlock().getType().equals(Material.END_PORTAL_FRAME)) return;
|
||||||
|
if(event.getItem() == null) return;
|
||||||
|
if(!event.getItem().getType().equals(Material.ENDER_EYE)) return;
|
||||||
|
|
||||||
|
if(!getAppliance().isEndDisabled()) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendActionBar(Component.text("Das End ist noch nicht freigeschaltet!", NamedTextColor.RED));
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MaintenanceCommand extends ApplianceCommand<Maintenance> {
|
public class MaintenanceCommand extends ApplianceCommand<Maintenance> {
|
||||||
Map<String, Boolean> arguments = Map.of("enable", true, "disable", false);
|
private final Map<String, Boolean> arguments = Map.of("enable", true, "disable", false);
|
||||||
|
|
||||||
public MaintenanceCommand() {
|
public MaintenanceCommand() {
|
||||||
super("maintanance");
|
super("maintanance");
|
||||||
|
@ -67,3 +67,6 @@ packselect:
|
|||||||
url: "https://example.com/download/pack.zip"
|
url: "https://example.com/download/pack.zip"
|
||||||
hash: "" # SHA1 hash of ZIP file (will be auto determined by the server on startup when not set)
|
hash: "" # SHA1 hash of ZIP file (will be auto determined by the server on startup when not set)
|
||||||
icon: "" # base64 player-head texture, can be obtained from sites like https://minecraft-heads.com/ under developers > Value
|
icon: "" # base64 player-head texture, can be obtained from sites like https://minecraft-heads.com/ under developers > Value
|
||||||
|
|
||||||
|
endPrevent:
|
||||||
|
endDisabled: true
|
@ -47,3 +47,4 @@ commands:
|
|||||||
aliases: [ "sc" ]
|
aliases: [ "sc" ]
|
||||||
acInform:
|
acInform:
|
||||||
infobar:
|
infobar:
|
||||||
|
endPrevent:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user