Skip to content

Commit

Permalink
Project Tidy up
Browse files Browse the repository at this point in the history
Improved package names and updated maven settings
  • Loading branch information
A5H73Y committed Apr 15, 2020
1 parent 57a1180 commit 0c6ae52
Show file tree
Hide file tree
Showing 40 changed files with 230 additions and 223 deletions.
21 changes: 13 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<!-- bStats -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<artifactId>bstats-bukkit-lite</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
Expand All @@ -104,16 +104,12 @@

<build>
<finalName>${project.artifactId}</finalName>
<defaultGoal>clean compile resources:resources package shade:shade</defaultGoal>
<defaultGoal>clean package</defaultGoal>

<resources>
<resource>
<targetPath>.</targetPath>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<directory>${basedir}</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>

Expand Down Expand Up @@ -144,15 +140,24 @@
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>org.bstats:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>io.github.a5h73y.Carz</shadedPattern>
<shadedPattern>io.github.a5h73y.carz</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package io.github.a5h73y;

import io.github.a5h73y.commands.CarzAutoTabCompleter;
import io.github.a5h73y.commands.CarzCommands;
import io.github.a5h73y.commands.CarzConsoleCommands;
import io.github.a5h73y.configuration.Settings;
import io.github.a5h73y.controllers.CarController;
import io.github.a5h73y.controllers.FuelController;
import io.github.a5h73y.listeners.PlayerListener;
import io.github.a5h73y.listeners.SignListener;
import io.github.a5h73y.listeners.VehicleListener;
import io.github.a5h73y.other.CarzUpdater;
import io.github.a5h73y.plugin.BountifulAPI;
import io.github.a5h73y.plugin.EconomyAPI;
import io.github.a5h73y.utility.ItemMetaUtils;
import io.github.a5h73y.utility.TranslationUtils;
import org.bstats.bukkit.Metrics;
package io.github.a5h73y.carz;

import io.github.a5h73y.carz.commands.CarzAutoTabCompleter;
import io.github.a5h73y.carz.commands.CarzCommands;
import io.github.a5h73y.carz.commands.CarzConsoleCommands;
import io.github.a5h73y.carz.configuration.Settings;
import io.github.a5h73y.carz.controllers.CarController;
import io.github.a5h73y.carz.controllers.FuelController;
import io.github.a5h73y.carz.listeners.PlayerListener;
import io.github.a5h73y.carz.listeners.SignListener;
import io.github.a5h73y.carz.listeners.VehicleListener;
import io.github.a5h73y.carz.other.CarzUpdater;
import io.github.a5h73y.carz.other.PluginUtils;
import io.github.a5h73y.carz.plugin.BountifulAPI;
import io.github.a5h73y.carz.plugin.EconomyAPI;
import io.github.a5h73y.carz.utility.ItemMetaUtils;
import io.github.a5h73y.carz.utility.TranslationUtils;
import org.bstats.bukkit.MetricsLite;
import org.bukkit.plugin.java.JavaPlugin;

public class Carz extends JavaPlugin {

private static final int PLUGIN_ID = 42269;
private static Carz instance;

private BountifulAPI bountifulAPI;
Expand Down Expand Up @@ -48,10 +50,16 @@ public void onEnable() {
setupPlugins();

getLogger().info("Enabled Carz v" + getDescription().getVersion());
new Metrics(this, 42269);
new MetricsLite(this, PLUGIN_ID);
updatePlugin();
}

@Override
public void onDisable() {
PluginUtils.log("Disabled Carz v" + getDescription().getVersion());
instance = null;
}

private void setupPlugins() {
bountifulAPI = new BountifulAPI();
economyAPI = new EconomyAPI();
Expand All @@ -77,7 +85,7 @@ public static String getPrefix() {

private void updatePlugin() {
if (getConfig().getBoolean("Other.UpdateCheck")) {
new CarzUpdater(this, 42269, this.getFile(), CarzUpdater.UpdateType.DEFAULT, true);
new CarzUpdater(this, PLUGIN_ID, this.getFile(), CarzUpdater.UpdateType.DEFAULT, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.github.a5h73y.commands;
package io.github.a5h73y.carz.commands;

import java.util.ArrayList;
import java.util.List;

import io.github.a5h73y.Carz;
import io.github.a5h73y.enums.Commands;
import io.github.a5h73y.enums.Permissions;
import io.github.a5h73y.other.AbstractPluginReceiver;
import io.github.a5h73y.utility.PermissionUtils;
import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.enums.Commands;
import io.github.a5h73y.carz.enums.Permissions;
import io.github.a5h73y.carz.other.AbstractPluginReceiver;
import io.github.a5h73y.carz.utility.PermissionUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package io.github.a5h73y.commands;

import io.github.a5h73y.Carz;
import io.github.a5h73y.conversation.CreateCarTypeConversation;
import io.github.a5h73y.enums.Commands;
import io.github.a5h73y.enums.Permissions;
import io.github.a5h73y.enums.VehicleDetailKey;
import io.github.a5h73y.model.Car;
import io.github.a5h73y.other.AbstractPluginReceiver;
import io.github.a5h73y.other.CarzHelp;
import io.github.a5h73y.other.DelayTasks;
import io.github.a5h73y.other.PluginUtils;
import io.github.a5h73y.purchases.CarPurchase;
import io.github.a5h73y.purchases.Purchasable;
import io.github.a5h73y.purchases.RefuelPurchase;
import io.github.a5h73y.purchases.UpgradePurchase;
import io.github.a5h73y.utility.CarUtils;
import io.github.a5h73y.utility.PermissionUtils;
import io.github.a5h73y.utility.StringUtils;
import io.github.a5h73y.utility.TranslationUtils;
import io.github.a5h73y.utility.ValidationUtils;
package io.github.a5h73y.carz.commands;

import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.conversation.CreateCarTypeConversation;
import io.github.a5h73y.carz.enums.Commands;
import io.github.a5h73y.carz.enums.Permissions;
import io.github.a5h73y.carz.enums.VehicleDetailKey;
import io.github.a5h73y.carz.model.Car;
import io.github.a5h73y.carz.other.AbstractPluginReceiver;
import io.github.a5h73y.carz.other.CarzHelp;
import io.github.a5h73y.carz.other.DelayTasks;
import io.github.a5h73y.carz.other.PluginUtils;
import io.github.a5h73y.carz.purchases.CarPurchase;
import io.github.a5h73y.carz.purchases.Purchasable;
import io.github.a5h73y.carz.purchases.RefuelPurchase;
import io.github.a5h73y.carz.purchases.UpgradePurchase;
import io.github.a5h73y.carz.utility.CarUtils;
import io.github.a5h73y.carz.utility.PermissionUtils;
import io.github.a5h73y.carz.utility.StringUtils;
import io.github.a5h73y.carz.utility.TranslationUtils;
import io.github.a5h73y.carz.utility.ValidationUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -27,7 +27,7 @@
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;

import static io.github.a5h73y.controllers.CarController.DEFAULT_CAR;
import static io.github.a5h73y.carz.controllers.CarController.DEFAULT_CAR;

/**
* Player-related Carz commands handling.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.a5h73y.commands;

import io.github.a5h73y.Carz;
import io.github.a5h73y.conversation.CreateCarTypeConversation;
import io.github.a5h73y.enums.Commands;
import io.github.a5h73y.other.AbstractPluginReceiver;
import io.github.a5h73y.other.PluginUtils;
import io.github.a5h73y.utility.CarUtils;
import io.github.a5h73y.utility.TranslationUtils;
package io.github.a5h73y.carz.commands;

import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.conversation.CreateCarTypeConversation;
import io.github.a5h73y.carz.enums.Commands;
import io.github.a5h73y.carz.other.AbstractPluginReceiver;
import io.github.a5h73y.carz.other.PluginUtils;
import io.github.a5h73y.carz.utility.CarUtils;
import io.github.a5h73y.carz.utility.TranslationUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
Expand All @@ -15,7 +15,7 @@
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

import static io.github.a5h73y.controllers.CarController.DEFAULT_CAR;
import static io.github.a5h73y.carz.controllers.CarController.DEFAULT_CAR;

/**
* Console-related Carz commands handling.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.github.a5h73y.configuration;
package io.github.a5h73y.carz.configuration;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;

import io.github.a5h73y.Carz;
import io.github.a5h73y.other.AbstractPluginReceiver;
import io.github.a5h73y.other.PluginUtils;
import io.github.a5h73y.utility.TranslationUtils;
import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.other.AbstractPluginReceiver;
import io.github.a5h73y.carz.other.PluginUtils;
import io.github.a5h73y.carz.utility.TranslationUtils;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package io.github.a5h73y.controllers;
package io.github.a5h73y.carz.controllers;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import io.github.a5h73y.Carz;
import io.github.a5h73y.enums.Permissions;
import io.github.a5h73y.model.Car;
import io.github.a5h73y.model.CarDetails;
import io.github.a5h73y.other.AbstractPluginReceiver;
import io.github.a5h73y.utility.CarUtils;
import io.github.a5h73y.utility.EffectUtils;
import io.github.a5h73y.utility.PermissionUtils;
import io.github.a5h73y.utility.TranslationUtils;
import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.enums.Permissions;
import io.github.a5h73y.carz.enums.VehicleDetailKey;
import io.github.a5h73y.carz.model.Car;
import io.github.a5h73y.carz.model.CarDetails;
import io.github.a5h73y.carz.other.AbstractPluginReceiver;
import io.github.a5h73y.carz.utility.CarUtils;
import io.github.a5h73y.carz.utility.EffectUtils;
import io.github.a5h73y.carz.utility.PermissionUtils;
import io.github.a5h73y.carz.utility.TranslationUtils;
import org.bukkit.Effect;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;

import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_FUEL;
import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_OWNER;
import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_SPEED;
import static io.github.a5h73y.enums.VehicleDetailKey.VEHICLE_TYPE;

/**
* All Car related functionality.
*/
Expand Down Expand Up @@ -65,14 +61,14 @@ public void populateCarTypes() {
* @param vehicle vehicle the player is driving
*/
public void startDriving(String playerName, Vehicle vehicle) {
String carType = carz.getItemMetaUtils().getValue(VEHICLE_TYPE, vehicle);
String carType = carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_TYPE, vehicle);
Car car = getOrCreateCar(vehicle.getEntityId(), carType);

if (carz.getItemMetaUtils().has(VEHICLE_SPEED, vehicle)) {
car.setMaxSpeed(Double.parseDouble(carz.getItemMetaUtils().getValue(VEHICLE_SPEED, vehicle)));
if (carz.getItemMetaUtils().has(VehicleDetailKey.VEHICLE_SPEED, vehicle)) {
car.setMaxSpeed(Double.parseDouble(carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_SPEED, vehicle)));
}
if (carz.getItemMetaUtils().has(VEHICLE_FUEL, vehicle)) {
car.setCurrentFuel(Double.parseDouble(carz.getItemMetaUtils().getValue(VEHICLE_FUEL, vehicle)));
if (carz.getItemMetaUtils().has(VehicleDetailKey.VEHICLE_FUEL, vehicle)) {
car.setCurrentFuel(Double.parseDouble(carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_FUEL, vehicle)));
}

playersDriving.put(playerName, car.getEntityId());
Expand Down Expand Up @@ -173,7 +169,7 @@ public void stashCar(Player player, Vehicle vehicle) {
return;
}

String owner = carz.getItemMetaUtils().getValue(VEHICLE_OWNER, vehicle);
String owner = carz.getItemMetaUtils().getValue(VehicleDetailKey.VEHICLE_OWNER, vehicle);

if (!player.getName().equals(owner) && !PermissionUtils.hasStrictPermission(player, Permissions.ADMIN)) {
return;
Expand Down Expand Up @@ -219,7 +215,7 @@ private void upgradeCarSpeed(Vehicle vehicle) {
}

car.setMaxSpeed(currentMax + upgradeAmount);
carz.getItemMetaUtils().setValue(VEHICLE_SPEED, vehicle, String.valueOf(car.getMaxSpeed()));
carz.getItemMetaUtils().setValue(VehicleDetailKey.VEHICLE_SPEED, vehicle, String.valueOf(car.getMaxSpeed()));
}

public Map<String, CarDetails> getCarTypes() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.a5h73y.controllers;
package io.github.a5h73y.carz.controllers;

import io.github.a5h73y.Carz;
import io.github.a5h73y.model.Car;
import io.github.a5h73y.other.AbstractPluginReceiver;
import io.github.a5h73y.utility.TranslationUtils;
import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.model.Car;
import io.github.a5h73y.carz.other.AbstractPluginReceiver;
import io.github.a5h73y.carz.utility.TranslationUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.a5h73y.conversation;
package io.github.a5h73y.carz.conversation;

import io.github.a5h73y.Carz;
import io.github.a5h73y.carz.Carz;
import org.bukkit.ChatColor;
import org.bukkit.conversations.Conversable;
import org.bukkit.conversations.Conversation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.github.a5h73y.conversation;
package io.github.a5h73y.carz.conversation;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import io.github.a5h73y.Carz;
import io.github.a5h73y.utility.ValidationUtils;
import io.github.a5h73y.carz.Carz;
import io.github.a5h73y.carz.utility.ValidationUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.a5h73y.enums;
package io.github.a5h73y.carz.enums;

/**
* The configurable Commands.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.a5h73y.enums;
package io.github.a5h73y.carz.enums;

/**
* All Carz related permissions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.a5h73y.enums;
package io.github.a5h73y.carz.enums;

import io.github.a5h73y.Carz;
import io.github.a5h73y.carz.Carz;
import org.bukkit.NamespacedKey;

public enum VehicleDetailKey {
Expand Down
Loading

0 comments on commit 0c6ae52

Please sign in to comment.