Skip to content

Commit

Permalink
Strip to 1.8 compatibility (DeathSpectatingLite)
Browse files Browse the repository at this point in the history
No, I am not maintaining this branch, feel free to fork and maintain
yourself though.
  • Loading branch information
RoboMWM committed Mar 2, 2017
1 parent d5ff048 commit 5884e7b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 185 deletions.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<modelVersion>4.0.0</modelVersion>

<groupId>to.us.tf</groupId>
<artifactId>DeathSpectating</artifactId>
<version>1.1.3</version>
<artifactId>DeathSpectatingLite</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>paper-repo</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
Expand All @@ -31,9 +31,9 @@
</build>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand Down
44 changes: 0 additions & 44 deletions src/main/java/to/us/tf/DeathSpectating/CompatUtil.java

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/to/us/tf/DeathSpectating/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;

import javax.annotation.Nonnull;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -98,24 +97,6 @@ public class ConfigManager
if (messageSection.getString("deniedCommand") == null)
messageSection.set("deniedCommand", "&cYou are not allowed to use that command while death spectating.");
messages.put("deniedCommand", formatter(messageSection.getString("deniedCommand")));

//Title messages
ConfigurationSection titleSection = config.getConfigurationSection("titleMessages");
if (titleSection == null)
titleSection = config.createSection("titleMessages");

if (titleSection.getStringList("titles").isEmpty())
titleSection.set("titles", new ArrayList<>(Arrays.asList("&cYou died!", "&cGame over!")));
if (titleSection.getStringList("subtitles").isEmpty())
titleSection.set("subtitles", new ArrayList<>(Arrays.asList("Respawning in {0}", "Score: &e{1}", "Score: &e{1}&f, Respawning in {0}")));

instance.saveConfig();
}

public String getDeathTitle(@Nonnull String titleType)
{
List<String> hi = config.getConfigurationSection("titleMessages").getStringList(titleType);
return hi.get(ThreadLocalRandom.current().nextInt(hi.size()));
}

public long getRespawnTicks()
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/to/us/tf/DeathSpectating/DeathSpectating.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package to.us.tf.DeathSpectating;

import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb;
Expand All @@ -24,9 +19,7 @@
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.scheduler.BukkitRunnable;
import to.us.tf.DeathSpectating.events.DeathSpectatingEvent;
import to.us.tf.DeathSpectating.features.Titles;
import to.us.tf.DeathSpectating.listeners.DamageListener;
import to.us.tf.DeathSpectating.listeners.MiscListeners;
import to.us.tf.DeathSpectating.tasks.SpectateTask;
Expand All @@ -49,8 +42,6 @@ public void onEnable()
getServer().getPluginManager().registerEvents(this, this);
getServer().getPluginManager().registerEvents(new DamageListener(this), this);
getServer().getPluginManager().registerEvents(new MiscListeners(this), this);
if (!CompatUtil.isOlder(11)) //TODO: register in class, not in main(?)
getServer().getPluginManager().registerEvents(new Titles(this, configManager), this);
}

public ConfigManager getConfigManager()
Expand Down Expand Up @@ -163,7 +154,7 @@ public boolean startDeathSpectating(Player player)
//Compile a list of null-free/air-free items to drop
for (ItemStack itemStack : player.getInventory().getContents())
{
if (itemStack != null && itemStack.getType() != Material.AIR && !itemStack.containsEnchantment(Enchantment.VANISHING_CURSE))
if (itemStack != null && itemStack.getType() != Material.AIR)
itemsToDrop.add(itemStack);
}
}
Expand Down Expand Up @@ -212,11 +203,6 @@ public boolean startDeathSpectating(Player player)
player.incrementStatistic(Statistic.DEATHS);
player.setStatistic(Statistic.TIME_SINCE_DEATH, 0);

//TODO: Non-vanilla behavior: Player death animation (red and falling over) (Issue #13)
//Smoke effect //TODO: after 20 ticks (Issue #14) (Will implement 20 tick delay after issue #13 is resolved
if (isSpectating(player)) //TODO: does smoke effect/death animation occur if player#spigot()#respawn() is called on death? My guess is no.
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation(), 25);

//Clear potion effects
for (PotionEffect potionEffect : player.getActivePotionEffects())
player.removePotionEffect(potionEffect.getType());
Expand Down
84 changes: 0 additions & 84 deletions src/main/java/to/us/tf/DeathSpectating/features/Titles.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package to.us.tf.DeathSpectating.listeners;

import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.PlayerInventory;
import to.us.tf.DeathSpectating.CompatUtil;
import to.us.tf.DeathSpectating.DeathSpectating;

/**
Expand Down Expand Up @@ -40,18 +36,6 @@ void onPlayerBasicallyWouldBeDead(EntityDamageEvent event)
if (player.getHealth() > event.getFinalDamage())
return;

//Ignore if player is holding a totem of undying
PlayerInventory inventory = player.getInventory();
try
{
if (inventory.getItemInMainHand().getType() == Material.TOTEM || inventory.getItemInOffHand().getType() == Material.TOTEM)
return;
}
catch (NoSuchFieldError | NoSuchMethodError e) //TOTEM (not in 1.10 and below) //getItemInMainHand, etc. (not in 1.8 and below)
{
if (CompatUtil.isNewer()) throw e;
}

//Ignore if this is probably the result of the Essentials suicide command
//Essentials will perform Player#setHealth(0), which does not fire a damage event, but does kill the player. This will lead to a double death message.
if ((event.getCause() == EntityDamageEvent.DamageCause.CUSTOM || event.getCause() == EntityDamageEvent.DamageCause.SUICIDE)
Expand Down

0 comments on commit 5884e7b

Please sign in to comment.