Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Remove useless code; support 1.13.0 through 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
datatags committed May 24, 2022
1 parent 0406196 commit baaba43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 18
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '18'
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.budderman18.TooExpensiveFix</groupId>
<artifactId>TooExpensiveFix</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand All @@ -15,13 +15,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
80 changes: 11 additions & 69 deletions src/main/java/com/budderman18/tooexpensivefix/TooExpensiveFix.java
Original file line number Diff line number Diff line change
@@ -1,85 +1,27 @@
package com.budderman18.tooexpensivefix;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

/**
* This class enables and disables the plugin
* It also imports commands and handles events
*/
public class TooExpensiveFix extends JavaPlugin implements Listener {
private final ConsoleCommandSender sender = getServer().getConsoleSender();
private final String prefixMessage = ChatColor.translateAlternateColorCodes('&', "&a[&cTooExpensiveFix&a] ");
/*
*
* Enables the plugin.
* Checks if MC version isn't the latest.
* If its not, warn the player about lacking support
* Checks if server is running offline mode
* If it is, disable the plugin
* Also loads death event
*
*/
public class TooExpensiveFix extends JavaPlugin implements Listener {

@Override
public void onEnable() {
//language variables
final String unsupportedVersionAMessage = ChatColor.translateAlternateColorCodes('&', "&4TooExpensiveFix does not support your version!");
final String unsupportedVersionBMessage = ChatColor.translateAlternateColorCodes('&', "&aOnly 1.18.2 is supported");
final String unsupportedVersionCMessage = ChatColor.translateAlternateColorCodes('&', "&aThis plugin will likely not work and you will get no support for issues");
final String unsecureServerAMessage = ChatColor.translateAlternateColorCodes('&', "&4NEVER EVER EVER EVER EVER EVER USE OFFLINE MODE!!!!!!!!!!!!!!!");
final String unsecureServerBMessage = ChatColor.translateAlternateColorCodes('&', "&cOffline mode is a serious threat to your server and will never be supported by my plugins!");
final String unsecureServerCMessage = ChatColor.translateAlternateColorCodes('&', "&cTo protect your safety and this plugin''s saftey, this plugin will now be disabled");
final String pluginEnabledMessage = ChatColor.translateAlternateColorCodes('&', "&eTooExpensiveFix by Budderman18 has been enabled!");
//check for correct version
if (!(Bukkit.getVersion().contains("1.18.2"))) {
sender.sendMessage(prefixMessage + unsupportedVersionAMessage);
sender.sendMessage(prefixMessage + unsupportedVersionBMessage);
sender.sendMessage(prefixMessage + unsupportedVersionCMessage);
}
//check for online mode
if (!(getServer().getOnlineMode())) {
sender.sendMessage(prefixMessage + unsecureServerAMessage);
sender.sendMessage(prefixMessage + unsecureServerBMessage);
sender.sendMessage(prefixMessage + unsecureServerCMessage);
getServer().getPluginManager().disablePlugin(this);
}
//events
getServer().getPluginManager().registerEvents(this,this);
//enable plugin
getServer().getPluginManager().enablePlugin(this);
sender.sendMessage(prefixMessage + pluginEnabledMessage);
getServer().getPluginManager().registerEvents(this, this);
}
/*
*
* This method disables the plugin
*
*/
@Override
public void onDisable() {
final String pluginDisabledMessage = ChatColor.translateAlternateColorCodes('&', "&eXPDeathDropFix by Budderman18 has been disabled!");
//disables plugin
getServer().getPluginManager().disablePlugin(this);
sender.sendMessage(prefixMessage + pluginDisabledMessage);
}
/*
*
* This method hadles everything involving fixing the limit
* It simply always sets the maximum to the level limit
* It also sets renamed items to 1 level
*
*/

@EventHandler
public void onAnvilUse(PrepareAnvilEvent event) {
event.getInventory().setMaximumRepairCost(21862);
if (event.getInventory().getItem(2) != null) {
if (event.getInventory().getItem(0).getItemMeta().getDisplayName() != event.getInventory().getItem(2).getItemMeta().getDisplayName() && event.getInventory().getItem(1) == null) {
event.getInventory().setRepairCost(1);
}
ItemStack original = event.getInventory().getItem(0);
ItemStack result = event.getInventory().getItem(2);
if (original == null || result == null) return;
if (!original.hasItemMeta() || !result.hasItemMeta()) return;
if (!original.getItemMeta().getDisplayName().equals(result.getItemMeta().getDisplayName()) && event.getInventory().getItem(1) == null) {
event.getInventory().setRepairCost(1);
}
}
}
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TooExpensiveFix
main: com.budderman18.TooExpensiveFix.Main
main: com.budderman18.tooexpensivefix.TooExpensiveFix
author: Budderman18
description: Removes the "Too Expensive!" tag in anvils and makes all re-name costs only 1 level.
version: 1.0
version: 2.0
api-version: 1.13

3 comments on commit baaba43

@Budderman18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you would like, I can link your fork on my spigot page as a version that supports more than just 1.18.2. You would need to attach a jar file to the 2.0 release so people can download it.

@datatags
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I can do that, just didn't know if you were OK with redistribution of modifications.

@Budderman18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with redistribution as long as its open-source and free.

Please sign in to comment.