Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #631 #676

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void onEnable() {
Settings.DisableNMSCompatibilityCheck = getConfig().getBoolean("IReallyKnowWhatIAmDoing", false);
Settings.DisableSpillProtection = getConfig().getBoolean("DisableSpillProtection", false);
Settings.DisableIceForm = getConfig().getBoolean("DisableIceForm", true);
Settings.ReleaseOnDeath = getConfig().getBoolean("ReleaseOnDeath", false);

String[] localisations = {"en", "cz", "nl", "fr"};
for (String s : localisations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.countercraft.movecraft.config.Settings;
import net.countercraft.movecraft.craft.Craft;
import net.countercraft.movecraft.craft.CraftManager;
import net.countercraft.movecraft.craft.PlayerCraft;
import net.countercraft.movecraft.craft.type.CraftType;
import net.countercraft.movecraft.events.CraftReleaseEvent;
import net.countercraft.movecraft.localisation.I18nSupport;
Expand All @@ -32,15 +31,13 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.WeakHashMap;

Expand Down Expand Up @@ -102,17 +99,17 @@ public void onPlayerLogout(PlayerQuitEvent e) {
}

@EventHandler
public void onPlayerDeath(EntityDamageByEntityEvent e) {
// changed to death so when you shoot up an airship and hit the pilot, it still sinks
if (!(e instanceof Player))
public void onPlayerDeath(PlayerDeathEvent e) {
// when you shoot a craft and kill the pilot, it sinks
if (!Settings.ReleaseOnDeath)
return;

Player p = (Player) e;
Player p = e.getPlayer();
Craft craft = CraftManager.getInstance().getCraftByPlayer(p);
if (craft == null)
return;

CraftManager.getInstance().release(craft, CraftReleaseEvent.Reason.DEATH, false);
CraftManager.getInstance().sink(craft);
}

@EventHandler
Expand Down
1 change: 1 addition & 0 deletions Movecraft/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ExtraFadeTimePerBlock: # List of blocks that will take longer time to fade
DROPPER: 600
FURNACE: 600
CollisionPrimer: 1000
ReleaseOnDeath: false
ForbiddenRemoteSigns: # These strings will be ignored when searching for signs to trigger from a remote sign
- "Mounted"
- "Denied"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@

import org.bukkit.Material;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

public class Settings {
Expand All @@ -48,4 +46,5 @@ public class Settings {
public static int MaxRemoteSigns = -1;
public static boolean CraftsUseNetherPortals = false;
public static HashSet<String> ForbiddenRemoteSigns;
public static boolean ReleaseOnDeath = false;
}