Skip to content

Commit

Permalink
Remove 1.17 and before version compatibility. (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
svaningelgem authored Apr 25, 2024
1 parent d42db46 commit 7675b33
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 516 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ and more! While still being lightweight and efficient.

## Supports

* 1.7.\*, 1.8.\*, 1.9.\*, 1.10.\*, 1.11.\*, 1.12.\*, 1.13.\*, 1.14.\*, 1.15.\*, 1.16.\*, 1.17.\*, 1.18.\*, 1.19.\*,
1.20.\*
* 1.18.\*, 1.19.\*, 1.20.\*
* Spigot, Paper, Purpur, Airplane, Pufferfish, Tuinity, CraftBukkit, CatServer, Mohist, Magma, MultiPaper
* GeyserMC (Bedrock Players)
* Forge/Bukkit Hybrid servers (Mohist, Magma, CatServer)
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@

<properties>
<revision>0.0.0-SNAPSHOT</revision>
<java.version>1.8</java.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<defaultGoal>clean package</defaultGoal>
<finalName>${project.name}-${project.version}</finalName>
<outputDirectory>e:/minecraft/server/plugins</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.11.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand Down Expand Up @@ -184,7 +185,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
33 changes: 8 additions & 25 deletions src/main/java/org/avarion/graves/Graves.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.avarion.graves.command.GraveyardsCommand;
import org.avarion.graves.compatibility.Compatibility;
import org.avarion.graves.compatibility.CompatibilityBlockData;
import org.avarion.graves.compatibility.CompatibilityMaterialData;
import org.avarion.graves.listener.*;
import org.avarion.graves.manager.*;
import org.avarion.graves.type.Grave;
Expand Down Expand Up @@ -223,14 +222,8 @@ public void registerListeners() {
getServer().getPluginManager().registerEvents(new InventoryCloseListener(this), this);
getServer().getPluginManager().registerEvents(new InventoryOpenListener(this), this);
getServer().getPluginManager().registerEvents(new CreatureSpawnListener(this), this);

if (!versionManager.is_v1_7()) {
getServer().getPluginManager().registerEvents(new PlayerInteractAtEntityListener(this), this);
}

if (!versionManager.is_v1_7() && !versionManager.is_v1_8()) {
getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this);
}
getServer().getPluginManager().registerEvents(new PlayerInteractAtEntityListener(this), this);
getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this);

//getServer().getPluginManager().registerEvents(new GraveTestListener(this), this); // Test Listener
}
Expand All @@ -240,7 +233,7 @@ public void unregisterListeners() {
}

private void registerRecipes() {
if (versionManager.hasPersistentData() && !versionManager.isMohist()) {
if (!versionManager.isMohist) {
recipeManager = new RecipeManager(this);
}
}
Expand Down Expand Up @@ -387,19 +380,13 @@ private void updateChecker() {
}

private void compatibilityChecker() {
compatibility = versionManager.hasBlockData() ? new CompatibilityBlockData() : new CompatibilityMaterialData();

if (!versionManager.hasBlockData()) {
infoMessage("Legacy version detected, Graves will run but may have problems with material names, "
+ "the default config is setup for the latest version of the game, you can alter the config manually to fix "
+ "any issues you encounter, you will need to find the names of materials and sounds for your version.");
}
compatibility = new CompatibilityBlockData();

if (versionManager.isBukkit()) {
if (versionManager.isBukkit) {
infoMessage("Bukkit detected, some functions won't work on Bukkit, like hex codes.");
}

if (versionManager.isMohist()) {
if (versionManager.isMohist) {
infoMessage("Mohist detected, not injecting custom recipes.");
}
}
Expand Down Expand Up @@ -528,9 +515,7 @@ public ConfigurationSection getConfig(String config, EntityType entityType, List
if (getConfig().isConfigurationSection(section)) {
ConfigurationSection configurationSection = getConfig().getConfigurationSection(section);

if (configurationSection != null && (versionManager.hasConfigContains()
? configurationSection.contains(config, true)
: configurationSection.contains(config))) {
if (configurationSection != null && configurationSection.contains(config, true)) {
return configurationSection;
}
}
Expand All @@ -543,9 +528,7 @@ public ConfigurationSection getConfig(String config, EntityType entityType, List
if (getConfig().isConfigurationSection(section)) {
ConfigurationSection configurationSection = getConfig().getConfigurationSection(section);

if (configurationSection != null && (versionManager.hasConfigContains()
? configurationSection.contains(config, true)
: configurationSection.contains(config))) {
if (configurationSection != null && configurationSection.contains(config, true)) {
return configurationSection;
}
}
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/org/avarion/graves/integration/ItemBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ItemBridgeListenerPriority getPriority() {
public ItemStack fetchItemStack(@NotNull String string) {
string = string.toLowerCase();

if (plugin.getVersionManager().hasPersistentData() && string.startsWith("token_")) {
if (string.startsWith("token_")) {
string = string.replaceFirst("token_", "");

return plugin.getConfig().isSet("settings.token." + string)
Expand All @@ -52,7 +52,7 @@ public ItemStack fetchItemStack(@NotNull String string) {

@Override
public String getItemName(@NotNull ItemStack itemStack) {
if (plugin.getVersionManager().hasPersistentData() && plugin.getRecipeManager().isToken(itemStack)) {
if (plugin.getRecipeManager().isToken(itemStack)) {
return plugin.getRecipeManager().getTokenName(itemStack);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/avarion/graves/integration/PlayerNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ public void createCorpse(UUID uuid, Location location, Grave grave, boolean crea
npc.setItemInRightHand(grave.getEquipmentMap().get(EquipmentSlot.HAND));
}

if (plugin.getVersionManager().hasSecondHand() && grave.getEquipmentMap()
.containsKey(EquipmentSlot.OFF_HAND)) {
if (grave.getEquipmentMap().containsKey(EquipmentSlot.OFF_HAND)) {
npc.setItemInLeftHand(grave.getEquipmentMap().get(EquipmentSlot.OFF_HAND));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public EntityDamageByEntityListener(Graves plugin) {
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();

if (entity instanceof ItemFrame || (plugin.getVersionManager().is_v1_7() || entity instanceof ArmorStand)) {
if (entity instanceof ItemFrame || entity instanceof ArmorStand) {
event.setCancelled(plugin.getEntityDataManager().getGrave(entity) != null);
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/org/avarion/graves/listener/EntityDeathListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ else if (!plugin.getLocationManager().canBuild(livingEntity, location, permissio
}

// Token
if (plugin.getVersionManager().hasPersistentData()
&& plugin.getConfig("token.enabled", livingEntity, permissionList).getBoolean("token.enabled")) {
if (plugin.getConfig("token.enabled", livingEntity, permissionList).getBoolean("token.enabled")) {
String name = plugin.getConfig("token.name", livingEntity).getString("token.name", "basic");

if (plugin.getConfig().isConfigurationSection("settings.token." + name)) {
Expand Down Expand Up @@ -314,10 +313,8 @@ else if (plugin.getConfig("compass.ignore", livingEntity, permissionList)
grave.setTimeAlive(plugin.getConfig("grave.time", grave).getInt("grave.time") * 1000L);

// Skin
if (!plugin.getVersionManager().is_v1_7()) {
grave.setOwnerTexture(SkinUtil.getTexture(livingEntity));
grave.setOwnerTextureSignature(SkinUtil.getSignature(livingEntity));
}
grave.setOwnerTexture(SkinUtil.getTexture(livingEntity));
grave.setOwnerTextureSignature(SkinUtil.getSignature(livingEntity));

// Experience
float experiencePercent = (float) plugin.getConfig("experience.store", grave).getDouble("experience.store");
Expand Down Expand Up @@ -448,10 +445,7 @@ else if (livingEntity.getLastDamageCause() != null) {
.getGraveInventory(grave, livingEntity, graveItemStackList, removedItemStackList, permissionList));

// Equipment
grave.setEquipmentMap(!plugin.getVersionManager().is_v1_7()
? plugin.getEntityManager()
.getEquipmentMap(livingEntity, grave)
: new HashMap<>());
grave.setEquipmentMap(plugin.getEntityManager().getEquipmentMap(livingEntity, grave));

// Placeable
locationMap.entrySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public PlayerInteractAtEntityListener(Graves plugin) {
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Player player = event.getPlayer();

if ((!plugin.getVersionManager().hasSecondHand() || event.getHand() == EquipmentSlot.HAND)
if (event.getHand() == EquipmentSlot.HAND
&& event.getRightClicked() instanceof ArmorStand
&& (plugin.getVersionManager().is_v1_7() || player.getGameMode() != GameMode.SPECTATOR)) {
&& player.getGameMode() != GameMode.SPECTATOR) {
Entity entity = event.getRightClicked();
Grave grave = plugin.getEntityDataManager().getGrave(entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public PlayerInteractEntityListener(Graves plugin) {
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();

if ((!plugin.getVersionManager().hasSecondHand() || event.getHand() == EquipmentSlot.HAND)
if (event.getHand() == EquipmentSlot.HAND
&& event.getRightClicked() instanceof ItemFrame
&& (plugin.getVersionManager().is_v1_7() || player.getGameMode() != GameMode.SPECTATOR)) {
&& player.getGameMode() != GameMode.SPECTATOR) {
Entity entity = event.getRightClicked();
Grave grave = plugin.getEntityDataManager().getGrave(entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public PlayerInteractListener(Graves plugin) {
public void onPlayerInteract(@NotNull PlayerInteractEvent event) {
Player player = event.getPlayer();

if ((!plugin.getVersionManager().hasSecondHand() || (event.getHand() != null
&& event.getHand() == EquipmentSlot.HAND))
&& (plugin.getVersionManager().is_v1_7() || player.getGameMode() != GameMode.SPECTATOR)) {
if (event.getHand() != null
&& event.getHand() == EquipmentSlot.HAND
&& player.getGameMode() != GameMode.SPECTATOR) {
// Grave
if (event.getClickedBlock() != null
&& event.useInteractedBlock() != Event.Result.DENY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public PlayerMoveListener(Graves plugin) {
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();

if (plugin.getVersionManager().is_v1_7() || player.getGameMode() != GameMode.SPECTATOR) {
if (player.getGameMode() != GameMode.SPECTATOR) {
if (event.getTo() != null && (event.getTo().getBlockX() != event.getFrom().getBlockX()
|| event.getTo().getBlockY() != event.getFrom().getBlockY()
|| event.getTo().getBlockZ() != event.getFrom().getBlockZ())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
.getString("respawn.function", "none"), grave);
}, 1L);

if (plugin.getVersionManager().hasCompassMeta()
&& plugin.getConfig("respawn.compass", player, permissionList).getBoolean("respawn.compass")
if (plugin.getConfig("respawn.compass", player, permissionList).getBoolean("respawn.compass")
&& grave.getLivedTime()
<= plugin.getConfig("respawn.compass-time", player, permissionList).getInt("respawn.compass-time")
* 1000L) {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/avarion/graves/manager/BlockManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public void createBlock(Location location, Grave grave) {
if (plugin.getConfig("block.enabled", grave).getBoolean("block.enabled")) {
String materialString = plugin.getConfig("block.material", grave).getString("block.material", "CHEST");

if (materialString.equals("PLAYER_HEAD") && !plugin.getVersionManager().hasBlockData()) {
materialString = "SKULL";
}

material = Material.matchMaterial(materialString);
}
else {
Expand Down
Loading

0 comments on commit 7675b33

Please sign in to comment.