added double doors
This commit is contained in:
parent
ebab4cbd34
commit
2d696dcdbd
@ -10,6 +10,7 @@ import eu.mhsl.craftattack.spawn.appliances.chatMessages.ChatMessages;
|
|||||||
import eu.mhsl.craftattack.spawn.appliances.customAdvancements.CustomAdvancements;
|
import eu.mhsl.craftattack.spawn.appliances.customAdvancements.CustomAdvancements;
|
||||||
import eu.mhsl.craftattack.spawn.appliances.debug.Debug;
|
import eu.mhsl.craftattack.spawn.appliances.debug.Debug;
|
||||||
import eu.mhsl.craftattack.spawn.appliances.displayName.DisplayName;
|
import eu.mhsl.craftattack.spawn.appliances.displayName.DisplayName;
|
||||||
|
import eu.mhsl.craftattack.spawn.appliances.doubeDoor.DoubleDoor;
|
||||||
import eu.mhsl.craftattack.spawn.appliances.event.Event;
|
import eu.mhsl.craftattack.spawn.appliances.event.Event;
|
||||||
import eu.mhsl.craftattack.spawn.appliances.fleischerchest.Fleischerchest;
|
import eu.mhsl.craftattack.spawn.appliances.fleischerchest.Fleischerchest;
|
||||||
import eu.mhsl.craftattack.spawn.appliances.help.Help;
|
import eu.mhsl.craftattack.spawn.appliances.help.Help;
|
||||||
@ -75,7 +76,8 @@ public final class Main extends JavaPlugin {
|
|||||||
new AutoShulker(),
|
new AutoShulker(),
|
||||||
new AntiSignEdit(),
|
new AntiSignEdit(),
|
||||||
new HotbarRefill(),
|
new HotbarRefill(),
|
||||||
new ChatMention()
|
new ChatMention(),
|
||||||
|
new DoubleDoor()
|
||||||
);
|
);
|
||||||
|
|
||||||
Main.logger.info("Loading appliances...");
|
Main.logger.info("Loading appliances...");
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.appliances.doubeDoor;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.appliance.Appliance;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.type.Door;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DoubleDoor extends Appliance {
|
||||||
|
public void openNextDoor(Block block) {
|
||||||
|
BlockData clickedData = block.getBlockData();
|
||||||
|
if (!(clickedData instanceof Door clickedDoor)) return;
|
||||||
|
|
||||||
|
BlockFace neighborFace = getNeighborFace(clickedDoor.getFacing(), clickedDoor.getHinge());
|
||||||
|
Block neighbourBlock = block.getRelative(neighborFace);
|
||||||
|
BlockData neighbourData = neighbourBlock.getBlockData();
|
||||||
|
|
||||||
|
if(!(neighbourData instanceof Door neighbourDoor)) return;
|
||||||
|
if(!(neighbourDoor.getFacing() == clickedDoor.getFacing())) return;
|
||||||
|
if(neighbourDoor.getHinge() == clickedDoor.getHinge()) return;
|
||||||
|
|
||||||
|
neighbourDoor.setOpen(!clickedDoor.isOpen());
|
||||||
|
neighbourBlock.setBlockData(neighbourDoor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull BlockFace getNeighborFace(BlockFace face, Door.Hinge hinge) {
|
||||||
|
return switch(face) {
|
||||||
|
case EAST -> (hinge == Door.Hinge.RIGHT) ? BlockFace.NORTH : BlockFace.SOUTH;
|
||||||
|
case WEST -> (hinge == Door.Hinge.RIGHT) ? BlockFace.SOUTH : BlockFace.NORTH;
|
||||||
|
case SOUTH -> (hinge == Door.Hinge.RIGHT) ? BlockFace.EAST : BlockFace.WEST;
|
||||||
|
case NORTH -> (hinge == Door.Hinge.RIGHT) ? BlockFace.WEST : BlockFace.EAST;
|
||||||
|
default -> throw new IllegalStateException(String.format("BlockFace '%s' of clicked door is not valid!", face));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NotNull List<Listener> eventHandlers() {
|
||||||
|
return List.of(new OnDoorInteractListener());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.appliances.doubeDoor;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
|
||||||
|
import eu.mhsl.craftattack.spawn.appliances.settings.Settings;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class OnDoorInteractListener extends ApplianceListener<DoubleDoor> {
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if(!event.hasBlock()) return;
|
||||||
|
if(!Objects.equals(event.getHand(), EquipmentSlot.HAND)) return;
|
||||||
|
if(!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return;
|
||||||
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
if(clickedBlock == null) return;
|
||||||
|
if(!Settings.instance().getSetting(event.getPlayer(), Settings.Key.DoubleDoors, Boolean.class)) return;
|
||||||
|
getAppliance().openNextDoor(clickedBlock);
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ public class Settings extends Appliance {
|
|||||||
SignEdit,
|
SignEdit,
|
||||||
HotbarReplacer,
|
HotbarReplacer,
|
||||||
ChatMentions,
|
ChatMentions,
|
||||||
|
DoubleDoors,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Settings instance() {
|
public static Settings instance() {
|
||||||
@ -57,7 +58,8 @@ public class Settings extends Appliance {
|
|||||||
new ChatMentionSetting(),
|
new ChatMentionSetting(),
|
||||||
new ShowJoinAndLeaveMessagesSetting(),
|
new ShowJoinAndLeaveMessagesSetting(),
|
||||||
new TechnicalTablistSetting(),
|
new TechnicalTablistSetting(),
|
||||||
new SettingsShortcutSetting()
|
new SettingsShortcutSetting(),
|
||||||
|
new DoubleDoorSetting()
|
||||||
);
|
);
|
||||||
|
|
||||||
settings.forEach(setting -> setting.initializeFromPlayer(player));
|
settings.forEach(setting -> setting.initializeFromPlayer(player));
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.appliances.settings.settings;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.appliances.settings.CategorizedSetting;
|
||||||
|
import eu.mhsl.craftattack.spawn.appliances.settings.SettingCategory;
|
||||||
|
import eu.mhsl.craftattack.spawn.appliances.settings.Settings;
|
||||||
|
import eu.mhsl.craftattack.spawn.appliances.settings.datatypes.BoolSetting;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public class DoubleDoorSetting extends BoolSetting implements CategorizedSetting {
|
||||||
|
public DoubleDoorSetting() {
|
||||||
|
super(Settings.Key.DoubleDoors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String title() {
|
||||||
|
return "Automatische Doppeltüren";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String description() {
|
||||||
|
return "Öffnet und schließt die zweite Hälfte einer Doppeltür automatisch";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Material icon() {
|
||||||
|
return Material.OAK_DOOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean defaultValue() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SettingCategory category() {
|
||||||
|
return SettingCategory.Gameplay;
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,10 @@ public class Whitelist extends Appliance {
|
|||||||
public void integrityCheck(Player player) throws DisconnectInfo.Throwable {
|
public void integrityCheck(Player player) throws DisconnectInfo.Throwable {
|
||||||
try {
|
try {
|
||||||
Main.instance().getLogger().info(String.format("Running integrityCheck for %s", player.getName()));
|
Main.instance().getLogger().info(String.format("Running integrityCheck for %s", player.getName()));
|
||||||
UserData user = this.fetchUserData(player.getUniqueId());
|
boolean overrideCheck = localConfig().getBoolean("overrideIntegrityCheck", false);
|
||||||
|
UserData user = overrideCheck
|
||||||
|
? new UserData(player.getUniqueId(), player.getName(), "", "", 0L, 0L)
|
||||||
|
: this.fetchUserData(player.getUniqueId());
|
||||||
|
|
||||||
if(timestampRelevant(user.banned_until)) {
|
if(timestampRelevant(user.banned_until)) {
|
||||||
Instant bannedDate = new Date(user.banned_until * 1000L)
|
Instant bannedDate = new Date(user.banned_until * 1000L)
|
||||||
@ -100,8 +103,7 @@ public class Whitelist extends Appliance {
|
|||||||
URIBuilder uriBuilder = new URIBuilder(apiEndpoint);
|
URIBuilder uriBuilder = new URIBuilder(apiEndpoint);
|
||||||
uriBuilder.addParameter("uuid", uuid.toString());
|
uriBuilder.addParameter("uuid", uuid.toString());
|
||||||
|
|
||||||
try {
|
try(HttpClient client = HttpClient.newHttpClient()) {
|
||||||
HttpClient client = HttpClient.newHttpClient();
|
|
||||||
HttpRequest httpRequest = HttpRequest.newBuilder()
|
HttpRequest httpRequest = HttpRequest.newBuilder()
|
||||||
.uri(uriBuilder.build())
|
.uri(uriBuilder.build())
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user