mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
Current progress on data accessors
Pushing because I started on stuff and don't wanna lose it...
This commit is contained in:
parent
ec58a0e81f
commit
21a0a05683
@ -1,3 +1,8 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
api("org.jetbrains:annotations:17.0.0")
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.gmail.nossr50.mcmmo.api.data;
|
||||
|
||||
public interface MMOEntity {
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.mcmmo.api.data;
|
||||
|
||||
public interface MMOPlayer<N> {
|
||||
public interface MMOPlayer<N> extends MMOEntity {
|
||||
|
||||
|
||||
N getPlayer();
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.gmail.nossr50.mcmmo.api.platform;
|
||||
|
||||
import com.gmail.nossr50.mcmmo.api.data.MMOPlayer;
|
||||
import com.gmail.nossr50.mcmmo.api.platform.util.MetadataStore;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface PlatformProvider {
|
||||
@ -7,4 +11,10 @@ public interface PlatformProvider {
|
||||
Logger getLogger();
|
||||
|
||||
void tearDown();
|
||||
|
||||
MetadataStore getMetadataStore();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
void getVersion();
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.gmail.nossr50.mcmmo.api.platform.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MetadataKey<V> {
|
||||
|
||||
private final String key;
|
||||
|
||||
public MetadataKey(@NotNull String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.mcmmo.api.platform.util;
|
||||
|
||||
import com.gmail.nossr50.mcmmo.api.data.MMOEntity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
public interface MetadataStore {
|
||||
|
||||
/**
|
||||
* @param holder holder of the metadata
|
||||
* @param key key for the metdata
|
||||
* @param <V> value type
|
||||
* @return the metadata value or null
|
||||
*/
|
||||
@Nullable
|
||||
<V> V getMetadata(@NotNull MMOEntity holder, @NotNull MetadataKey<V> key);
|
||||
|
||||
/**
|
||||
* @param holder holder of the metdata
|
||||
* @param key metadata key
|
||||
* @param value metadata value
|
||||
* @param <V> value type
|
||||
* @return the existing metadata value if set, or null
|
||||
*/
|
||||
@Nullable
|
||||
<V> V setMetadata(@NotNull MMOEntity holder, @NotNull MetadataKey<V> key, @Nullable V value);
|
||||
|
||||
/**
|
||||
* @param holder holder of the metadata
|
||||
* @param key metadata key
|
||||
* @param <V> value type
|
||||
* @return the removed metadata key
|
||||
*/
|
||||
@Nullable
|
||||
<V> V removeMetadata(@NotNull MMOEntity holder, @NotNull MetadataKey<V> key);
|
||||
|
||||
}
|
@ -33,7 +33,7 @@ dependencies {
|
||||
implementation(project(":mcmmo-core"))
|
||||
|
||||
api("org.apache.tomcat:tomcat-jdbc:7.0.52")
|
||||
implementation("org.jetbrains:annotations:17.0.0")
|
||||
api("net.kyori:event-api:3.0.0")
|
||||
implementation("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1")
|
||||
implementation("org.bstats:bstats-bukkit:1.4")
|
||||
implementation("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT")
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.mcmmo.bukkit;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcmmo.api.platform.PlatformProvider;
|
||||
import com.gmail.nossr50.mcmmo.api.platform.util.MetadataStore;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -25,4 +26,9 @@ public class BukkitBoostrap extends JavaPlugin implements PlatformProvider {
|
||||
core.debug("Unregister all events...");
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataStore getMetadataStore() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.core;
|
||||
|
||||
import com.gmail.nossr50.mcmmo.api.platform.util.MetadataKey;
|
||||
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
/**
|
||||
@ -8,30 +10,28 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
public class MetadataConstants {
|
||||
|
||||
/* Metadata Values */
|
||||
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
|
||||
public static final String DODGE_TRACKER = "mcMMO: Dodge Tracker";
|
||||
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
|
||||
public final static String UNNATURAL_MOB_METAKEY = "mcMMO: Spawned Entity";
|
||||
public final static String PISTON_TRACKING_METAKEY = "mcMMO: Piston Tracking";
|
||||
public final static String FURNACE_TRACKING_METAKEY = "mcMMO: Tracked Furnace";
|
||||
public final static String TNT_TRACKING_METAKEY = "mcMMO: Tracked TNT";
|
||||
public final static String SPAWNED_FIREWORKS_METAKEY = "mcMMO: Funfetti";
|
||||
public final static String SAFE_TNT_METAKEY = "mcMMO: Safe TNT";
|
||||
public final static String CUSTOM_NAME_METAKEY = "mcMMO: Custom Name";
|
||||
public final static String NAME_VISIBILITY_METAKEY = "mcMMO: Name Visibility";
|
||||
public final static String DROPPED_ITEM_TRACKING_METAKEY = "mcMMO: Tracked Item";
|
||||
public final static String INFINITE_ARROW_METAKEY = "mcMMO: Infinite Arrow";
|
||||
public final static String BOW_FORCE_METAKEY = "mcMMO: Bow Force";
|
||||
public final static String ARROW_DISTANCE_METAKEY = "mcMMO: Arrow Distance";
|
||||
public final static String ARROW_TRACKER_METAKEY = "mcMMO: Arrow Tracker";
|
||||
public final static String BONUS_DROPS_METAKEY = "mcMMO: Bonus Drops";
|
||||
public final static String DISARMED_ITEM_METAKEY = "mcMMO: Disarmed Item";
|
||||
public final static String PLAYER_DATA_METAKEY = "mcMMO: Player Data";
|
||||
public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb";
|
||||
public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command";
|
||||
public final static String PETS_ANIMAL_TRACKING_METAKEY = "mcMMO: Pet Animal";
|
||||
public static final String COTW_TEMPORARY_SUMMON = "mcMMO: COTW Entity";
|
||||
|
||||
public static FixedMetadataValue metadataValue; //Gains value in onEnable
|
||||
public static final MetadataKey<Boolean> FISH_HOOK_REF_METAKEY = new MetadataKey<>("mcMMO: Fish Hook Tracker");
|
||||
public static final MetadataKey<Boolean> DODGE_TRACKER = new MetadataKey<>("mcMMO: Dodge Tracker");
|
||||
public static final MetadataKey<Boolean> CUSTOM_DAMAGE_METAKEY = new MetadataKey<>("mcMMO: Custom Damage");
|
||||
public final static MetadataKey<Boolean> UNNATURAL_MOB_METAKEY = new MetadataKey<>("mcMMO: Spawned Entity");
|
||||
public final static MetadataKey<Boolean> PISTON_TRACKING_METAKEY = new MetadataKey<>("mcMMO: Piston Tracking");
|
||||
public final static MetadataKey<Boolean> FURNACE_TRACKING_METAKEY = new MetadataKey<>("mcMMO: Tracked Furnace");
|
||||
public final static MetadataKey<Boolean> TNT_TRACKING_METAKEY = new MetadataKey<>("mcMMO: Tracked TNT");
|
||||
public final static MetadataKey<Boolean> SPAWNED_FIREWORKS_METAKEY = new MetadataKey<>("mcMMO: Funfetti");
|
||||
public final static MetadataKey<Boolean> SAFE_TNT_METAKEY = new MetadataKey<>("mcMMO: Safe TNT");
|
||||
public final static MetadataKey<String> CUSTOM_NAME_METAKEY = new MetadataKey<>("mcMMO: Custom Name");
|
||||
public final static MetadataKey<Boolean> NAME_VISIBILITY_METAKEY = new MetadataKey<>("mcMMO: Name Visibility");
|
||||
public final static MetadataKey<Boolean> DROPPED_ITEM_TRACKING_METAKEY = new MetadataKey<>("mcMMO: Tracked Item");
|
||||
public final static MetadataKey<Boolean> INFINITE_ARROW_METAKEY = new MetadataKey<>("mcMMO: Infinite Arrow");
|
||||
public final static MetadataKey<Boolean> BOW_FORCE_METAKEY = new MetadataKey<>("mcMMO: Bow Force");
|
||||
public final static MetadataKey<Boolean> ARROW_DISTANCE_METAKEY = new MetadataKey<>("mcMMO: Arrow Distance");
|
||||
public final static MetadataKey<Boolean> ARROW_TRACKER_METAKEY = new MetadataKey<>("mcMMO: Arrow Tracker");
|
||||
public final static MetadataKey<Boolean> BONUS_DROPS_METAKEY = new MetadataKey<>("mcMMO: Bonus Drops");
|
||||
public final static MetadataKey<Boolean> DISARMED_ITEM_METAKEY = new MetadataKey<>("mcMMO: Disarmed Item");
|
||||
public final static MetadataKey<Boolean> PLAYER_DATA_METAKEY = new MetadataKey<>("mcMMO: Player Data");
|
||||
public final static MetadataKey<Boolean> GREEN_THUMB_METAKEY = new MetadataKey<>("mcMMO: Green Thumb");
|
||||
public final static MetadataKey<Boolean> DATABASE_PROCESSING_COMMAND_METAKEY = new MetadataKey<>("mcMMO: Processing Database Command");
|
||||
public final static MetadataKey<Boolean> PETS_ANIMAL_TRACKING_METAKEY = new MetadataKey<>("mcMMO: Pet Animal");
|
||||
public static final MetadataKey<Boolean> COTW_TEMPORARY_SUMMON = new MetadataKey<>("mcMMO: COTW Entity");
|
||||
|
||||
}
|
||||
|
@ -139,9 +139,6 @@ public class mcMMO implements McMMOApi {
|
||||
try {
|
||||
platformProvider.getLogger().setFilter(new LogFilter(this));
|
||||
|
||||
//TODO: Disgusting...
|
||||
MetadataConstants.metadataValue = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = platformProvider.getServer().getPluginManager();
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
|
||||
@ -214,7 +211,7 @@ public class mcMMO implements McMMOApi {
|
||||
new PlayerProfileLoadingTask(this, player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||
}
|
||||
|
||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||
debug("Version " + getVersion() + " is enabled!");
|
||||
|
||||
scheduleTasks();
|
||||
commandRegistrationManager = new CommandRegistrationManager(this);
|
||||
@ -307,6 +304,10 @@ public class mcMMO implements McMMOApi {
|
||||
perkUtils = new PerkUtils(this);
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
platformProvider.getVersion();
|
||||
}
|
||||
|
||||
public void onLoad()
|
||||
{
|
||||
if(getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
@ -579,7 +580,7 @@ public class mcMMO implements McMMOApi {
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
private void setupFilePaths() {
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
mainDirectory = platformProvider.getDataFolder().getPath() + File.separator;
|
||||
localesDirectory = mainDirectory + "locales" + File.separator;
|
||||
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
|
Loading…
Reference in New Issue
Block a user