Reorganized the folders slightly

Reorganized the way repositories are
This commit is contained in:
Aztec 2020-06-28 16:24:08 -06:00 committed by Rezel
parent b391514fb1
commit 3690a3b50d
68 changed files with 520 additions and 216 deletions

View File

@ -0,0 +1,29 @@
package com.sekwah.advancedportals;
import java.lang.reflect.Type;
public class Config {
public Config(String key, String classType, String value) {
this.key = key;
this.value = value;
}
private String key;
private Type type;
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.core.repository;
package com.sekwah.advancedportals;
import com.sekwah.advancedportals.core.data.DataStorage;
import com.sekwah.advancedportals.data.DataStorage;
public interface ConfigRepository {

View File

@ -1,14 +1,35 @@
package com.sekwah.advancedportals.core.repository;
package com.sekwah.advancedportals;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.config.Config;
import com.sekwah.advancedportals.core.data.DataStorage;
import com.sekwah.advancedportals.config.Config;
import com.sekwah.advancedportals.data.DataStorage;
import java.util.HashMap;
@Singleton
public class ConfigRepositoryImpl implements ConfigRepository {
private HashMap<String, Config> configs;
private Config config;
public ConfigRepositoryImpl() {
configs = new HashMap<String,Config>();
}
public <T> T getValue(String output) {
try {
return (T) configs.get(output);
} catch (ClassCastException ignored) {
}
return null;
}
private void test() {
this.<String>getValue("");
}
public boolean getUseOnlySpecialAxe() {
return this.config.useOnlySpecialAxe;
}

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.entities;
package com.sekwah.advancedportals;
public class DataTag {

View File

@ -1,21 +1,22 @@
package com.sekwah.advancedportals.core.entities;
package com.sekwah.advancedportals;
import com.google.gson.annotations.SerializedName;
public class PlayerLocation {
@SerializedName("x")
public final double posX;
private final double posX;
@SerializedName("y")
public final double posY;
private final double posY;
@SerializedName("z")
public final double posZ;
private final double posZ;
@SerializedName("w")
public final String worldName;
private final String worldName;
@SerializedName("yaw")
public final float yaw;
private final float yaw;
@SerializedName("p")
public final float pitch;
private final float pitch;
public PlayerLocation(String worldName, double posX, double posY, double posZ) {
this.worldName = worldName;
@ -34,4 +35,28 @@ public class PlayerLocation {
this.yaw = yaw;
this.pitch = pitch;
}
public double getPosX() {
return posX;
}
public double getPosY() {
return posY;
}
public double getPosZ() {
return posZ;
}
public String getWorldName() {
return worldName;
}
public float getYaw() {
return yaw;
}
public float getPitch() {
return pitch;
}
}

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.entities;
package com.sekwah.advancedportals;
public class PlayerTempData {

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.entities;
package com.sekwah.advancedportals;
import com.google.gson.annotations.SerializedName;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.api.commands;
package com.sekwah.advancedportals.api.commands;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,12 +1,12 @@
package com.sekwah.advancedportals.core.api.destination;
package com.sekwah.advancedportals.api.destination;
import com.google.gson.annotations.SerializedName;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
import com.sekwah.advancedportals.core.api.warphandler.ActivationData;
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.api.registry.TagRegistry;
import com.sekwah.advancedportals.api.warphandler.ActivationData;
import com.sekwah.advancedportals.api.warphandler.TagHandler;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.ArrayList;

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.api.effect;
package com.sekwah.advancedportals.api.effect;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
/**

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.api.effect;
package com.sekwah.advancedportals.api.effect;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
/**

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.api.events;
package com.sekwah.advancedportals.api.events;
/**
* Activated when something about the event is edited.

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.api.events;
package com.sekwah.advancedportals.api.events;
/**

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.api.events;
package com.sekwah.advancedportals.api.events;
/**
* Trigered whenever a player activates the warp after the tags are handled.

View File

@ -1,12 +1,12 @@
package com.sekwah.advancedportals.core.api.portal;
package com.sekwah.advancedportals.api.portal;
import com.google.gson.annotations.SerializedName;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
import com.sekwah.advancedportals.core.api.warphandler.ActivationData;
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.api.registry.TagRegistry;
import com.sekwah.advancedportals.api.warphandler.ActivationData;
import com.sekwah.advancedportals.api.warphandler.TagHandler;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.ArrayList;

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.api.registry;
package com.sekwah.advancedportals.api.registry;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.InfoLogger;
import java.util.ArrayList;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.api.registry;
package com.sekwah.advancedportals.api.registry;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
import com.sekwah.advancedportals.api.warphandler.TagHandler;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.api.registry;
package com.sekwah.advancedportals.api.registry;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.effect.WarpEffect;
import com.sekwah.advancedportals.api.effect.WarpEffect;
import java.util.HashMap;
import java.util.Map;

View File

@ -1,13 +1,14 @@
package com.sekwah.advancedportals.core.api.services;
package com.sekwah.advancedportals.api.services;
import com.sekwah.advancedportals.core.api.destination.Destination;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.api.destination.Destination;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.repository.DestinationRepositoryOld;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.ArrayList; /**
* https://github.com/sekwah41/Advanced-Portals/blob/24175610892152828e21f4ff824eb1589ccb0338/src/com/sekwah/advancedportals/core/api/managers/DestinationManager.java
* Based off the old manager with the data storage and handling moved to {@link com.sekwah.advancedportals.core.repository.DestinationRepository}
* Based off the old manager with the data storage and handling moved to {@link DestinationRepositoryOld}
*/
public final class DestinationServices {

View File

@ -1,9 +1,10 @@
package com.sekwah.advancedportals.core.api.services;
package com.sekwah.advancedportals.api.services;
import com.google.common.collect.ImmutableList;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.repository.PortalRepository;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.ArrayList;
@ -12,7 +13,7 @@ import java.util.Map;
/**
* https://github.com/sekwah41/Advanced-Portals/blob/24175610892152828e21f4ff824eb1589ccb0338/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java
*
* Based off the old manager with the data storage and handling moved to {@link com.sekwah.advancedportals.core.repository.PortalRepository}
* Based off the old manager with the data storage and handling moved to {@link PortalRepository}
*
* Excluding the temp data like selections
*/

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.api.services;
package com.sekwah.advancedportals.api.services;
import com.sekwah.advancedportals.core.entities.PlayerTempData;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PlayerTempData;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.api.warphandler;
package com.sekwah.advancedportals.api.warphandler;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.PlayerLocation;
/**
* Created by on 30/07/2016.

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.api.warphandler;
package com.sekwah.advancedportals.api.warphandler;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.commands;
package com.sekwah.advancedportals.commands;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.commands;
package com.sekwah.advancedportals.commands;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.registry.SubCommandRegistry;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.api.registry.SubCommandRegistry;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.core.commands.subcommands;
package com.sekwah.advancedportals.commands.subcommands;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.DataTag;
import java.util.ArrayList;

View File

@ -1,10 +1,10 @@
package com.sekwah.advancedportals.core.commands.subcommands.desti;
package com.sekwah.advancedportals.commands.subcommands.desti;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.destination.Destination;
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.api.destination.Destination;
import com.sekwah.advancedportals.commands.subcommands.CreateSubCommand;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,10 +1,10 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.commands.subcommands.CreateSubCommand;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.commands.subcommands.portal;
package com.sekwah.advancedportals.commands.subcommands.portal;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.config;
package com.sekwah.advancedportals.config;
/**
* To store the data for config

View File

@ -1,10 +1,12 @@
package com.sekwah.advancedportals.core.config;
package com.sekwah.advancedportals.config;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.matcher.Matchers;
import com.sekwah.advancedportals.*;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.repository.*;
import com.sekwah.advancedportals.repository.*;
public class RepositoryModule extends AbstractModule {
@ -18,8 +20,9 @@ public class RepositoryModule extends AbstractModule {
protected void configure() {
bind(PortalRepository.class).to(PortalRepositoryImpl.class).in(Scopes.SINGLETON);
bind(DestinationRepository.class).to(DestinationRepositoryImpl.class).in(Scopes.SINGLETON);
bind(PortalTempDataRepository.class).to(PortalTempDataRepositoryImpl.class).in(Scopes.SINGLETON);
bind(PortalRepository.class).to(PortalRepositoryImpl.class).in(Scopes.SINGLETON);
bind(ConfigRepository.class).to(ConfigRepositoryImpl.class).in(Scopes.SINGLETON);
bindListener(Matchers.Any(), new Log4JTypeListenr());
}
@Provides

View File

@ -2,20 +2,20 @@ package com.sekwah.advancedportals.core;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.destination.Destination;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
import com.sekwah.advancedportals.core.api.registry.WarpEffectRegistry;
import com.sekwah.advancedportals.core.api.services.DestinationServices;
import com.sekwah.advancedportals.core.api.services.PortalServices;
import com.sekwah.advancedportals.core.api.services.PortalTempDataServices;
import com.sekwah.advancedportals.core.commands.CommandWithSubCommands;
import com.sekwah.advancedportals.core.commands.subcommands.desti.CreateDestiSubCommand;
import com.sekwah.advancedportals.core.commands.subcommands.portal.*;
import com.sekwah.advancedportals.core.config.RepositoryModule;
import com.sekwah.advancedportals.core.data.DataStorage;
import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.api.destination.Destination;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.api.registry.TagRegistry;
import com.sekwah.advancedportals.api.registry.WarpEffectRegistry;
import com.sekwah.advancedportals.api.services.DestinationServices;
import com.sekwah.advancedportals.api.services.PortalServices;
import com.sekwah.advancedportals.api.services.PortalTempDataServices;
import com.sekwah.advancedportals.commands.CommandWithSubCommands;
import com.sekwah.advancedportals.commands.subcommands.desti.CreateDestiSubCommand;
import com.sekwah.advancedportals.commands.subcommands.portal.*;
import com.sekwah.advancedportals.config.RepositoryModule;
import com.sekwah.advancedportals.data.DataStorage;
import com.sekwah.advancedportals.ConfigRepository;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.command.CommandRegister;

View File

@ -1,10 +1,10 @@
package com.sekwah.advancedportals.core;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.api.services.PortalServices;
import com.sekwah.advancedportals.core.api.services.PortalTempDataServices;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.api.services.PortalServices;
import com.sekwah.advancedportals.api.services.PortalTempDataServices;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;

View File

@ -1,13 +0,0 @@
package com.sekwah.advancedportals.core.repository;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
public interface PortalRepository {
void loadPortals();
void savePortals();
boolean playerMove(PlayerContainer player, PlayerLocation fromLoc, PlayerLocation toLoc);
}

View File

@ -1,23 +0,0 @@
package com.sekwah.advancedportals.core.repository;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
@Singleton
public class PortalRepositoryImpl implements PortalRepository {
@Override
public void loadPortals() {
}
@Override
public void savePortals() {
}
@Override
public boolean playerMove(PlayerContainer player, PlayerLocation fromLoc, PlayerLocation toLoc) {
return false;
}
}

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.coreconnector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.commands.CommandTemplate;
public abstract class CommandHandler {

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.coreconnector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.commands.CommandTemplate;
public interface CommandRegister {

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.coreconnector.container;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import java.util.UUID;

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.coreconnector.container;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PortalLocation;
public interface WorldContainer {

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.core.data;
package com.sekwah.advancedportals.data;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View File

@ -1,14 +0,0 @@
package com.sekwah.advancedportals.fabric;
import net.fabricmc.api.ModInitializer;
public class AdvancedPortalsMod implements ModInitializer {
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
System.out.println("Hello Fabric world!");
}
}

View File

@ -1,18 +0,0 @@
package com.sekwah.advancedportals.fabric.mixins.common;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerEntity.class)
public class PlayerMixin {
@Inject(method="setPosition", at=@At("HEAD"))
public void setPosition(double x, double y, double z, CallbackInfo info) {
System.out.println("MOVE");
}
}

View File

@ -0,0 +1,6 @@
package com.sekwah.advancedportals.repository;
import com.sekwah.advancedportals.api.destination.Destination;
public interface DestinationRepository<T> extends JsonRepository<T> {
}

View File

@ -0,0 +1,60 @@
package com.sekwah.advancedportals.repository;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.sekwah.advancedportals.api.destination.Destination;
import it.unimi.dsi.fastutil.Hash;
import javax.inject.Singleton;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Singleton
public class DestinationRepositoryImpl implements DestinationRepository<Destination>{
private final String fileLocation = "";
private Map<String, Destination> destinationCache = new HashMap<String, Destination>();
/*Is there any reason to load it into the array if it's not been used or connected? Q for Sekwah*/
public void AddDestination(String name, Destination destination) throws IOException {
gson.toJson(destination, new FileWriter(fileLocation + name + ".json"));
}
private void test() {
destinationCache.get("");
}
@Override
public boolean save(String name, Destination destination) {
return false;
}
public boolean containsKey(String name) {
return Files.exists(Paths.get(fileLocation + "\\" + name + ".json"));
}
@Override
public boolean delete(String name) {
try {
Files.deleteIfExists(Paths.get(fileLocation + "\\" + name + ".json"));
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean update(String name, Destination destination) {
return false;
}
public ImmutableMap<String, Destination> get(String s) {
}
}

View File

@ -1,14 +1,16 @@
package com.sekwah.advancedportals.core.repository;
package com.sekwah.advancedportals.repository;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.destination.Destination;
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
import com.sekwah.advancedportals.core.entities.DataTag;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.api.destination.Destination;
import com.sekwah.advancedportals.api.warphandler.TagHandler;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
@ -18,13 +20,14 @@ import java.util.HashMap;
import java.util.Map;
@Singleton
public class DestinationRepositoryImpl implements DestinationRepository {
private Map<String, Destination> destiHashMap = new HashMap<>();
@Deprecated
public class DestinationRepositoryImpl2 implements DestinationRepositoryOld {
@Inject
private AdvancedPortalsCore portalsCore;
@Override
public void create(String name, Destination destination) {
destiHashMap.put(name, destination);
}

View File

@ -1,9 +1,10 @@
package com.sekwah.advancedportals.core.repository;
package com.sekwah.advancedportals.repository;
import com.google.common.collect.ImmutableMap;
import com.sekwah.advancedportals.core.api.destination.Destination;
import com.sekwah.advancedportals.api.destination.Destination;
public interface DestinationRepository {
@Deprecated
public interface DestinationRepositoryOld {
void create(String name, Destination destination);
void delete(String name);

View File

@ -0,0 +1,14 @@
package com.sekwah.advancedportals.repository;
import com.google.gson.Gson;
public interface JsonRepository<T> {
Gson gson = new Gson();
public boolean save(String name, T t);
public boolean containsKey(String name);
public boolean delete(String name);
public boolean update(String name, T t);
}

View File

@ -0,0 +1,7 @@
package com.sekwah.advancedportals.repository;
import com.sekwah.advancedportals.PortalLocation;
public interface PortalRepository extends JsonRepository<PortalLocation> {
}

View File

@ -0,0 +1,33 @@
package com.sekwah.advancedportals.repository;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.LoadingCache;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Singleton
public class PortalRepositoryImpl implements PortalRepository {
Cache<UUID, String> selectedPortal = CacheBuilder.newBuilder()
.concurrencyLevel(4)
.expireAfterAccess(30, TimeUnit.DAYS)
.build();
public String getSelectedPortal(UUID uuid) {
return selectedPortal.getIfPresent(uuid);
}
@Override
public boolean delete(String name) {
return false;
}
@Override
public boolean update(String name, PortalLocation portalLocation) {
return false;
}
}

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.core.repository;
package com.sekwah.advancedportals.repository;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.UUID;

View File

@ -1,18 +1,19 @@
package com.sekwah.advancedportals.core.repository;
package com.sekwah.advancedportals.repository;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Singleton
@Deprecated
public class PortalTempDataRepositoryImpl implements PortalTempDataRepository {
Cache<UUID, String> selectedPortal = CacheBuilder.newBuilder()
.concurrencyLevel(4)

View File

@ -0,0 +1,109 @@
package com.sekwah.advancedportals.services;
import com.google.common.collect.ImmutableMap;
import com.google.gson.reflect.TypeToken;
import com.sekwah.advancedportals.DataTag;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.api.destination.Destination;
import com.sekwah.advancedportals.api.warphandler.TagHandler;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import com.sekwah.advancedportals.repository.DestinationRepositoryImpl;
import org.apache.log4j.Logger;
import javax.inject.Inject;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Handles logic for all destination, this is a transient layer so it should
* not store any information.
*/
public class DestinationServices {
DestinationRepositoryImpl destinationRepository;
Logger logger;
@Inject
private DestinationServices(DestinationRepositoryImpl destinationRepository, Logger logger) {
this.destinationRepository = destinationRepository;
this.logger = logger;
}
public Response create(String name, Destination destination) {
if (!destinationRepository.containsKey(name)) {
destinationRepository.save(name, destination);
return Response.SUCCESS;
}
return Response.NAME_IN_USE;
}
public Boolean delete(String name) {
if (!destinationRepository.containsKey(name)) {
destinationRepository.delete(name);
}
return false;
}
public ImmutableMap<String, Destination> getDestination() {
return destinationRepository.get("");
}
public ImmutableMap<String, Destination> getDestinations() {
return ImmutableMap.copyOf(destinationRepository.get(""));
}
public Destination createDesti(String name, PlayerContainer player, PlayerLocation playerLocation, ArrayList<DataTag> tags) {
// TODO change to write messages
if(name == null || name.equals("")) {
player.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("desti.error.noname"));
return null;
}
else if(this.destinationRepository.containsKey(name)) {
player.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("desti.error.takenname"));
return null;
}
Destination desti = new Destination(playerLocation);
for(DataTag portalTag : tags) {
desti.setArg(portalTag);
logger.warn("Derp A Derp");
}
for(DataTag destiTag : tags) {
TagHandler.Creation<Destination> creation = AdvancedPortalsCore.getDestinationTagRegistry().getCreationHandler(destiTag.NAME);
if(creation != null) {
creation.created(desti, player, destiTag.VALUE);
}
}
try {
this.destinationRepository.AddDestination(name, desti);
} catch (IOException e) {
e.printStackTrace();
}
this.saveDestinations();
return desti;
}
//TODO Change to repository
public void loadDestinations() {
Type type = new TypeToken<HashMap<String, Destination>>() {
}.getType();
this.destiHashMap = this.portalsCore.getDataStorage().loadJson(type, "destinations.json");
this.saveDestinations();
}
public void saveDestinations() {
if (this.destiHashMap == null) {
this.destiHashMap = new HashMap<>();
}
this.portalsCore.getDataStorage().storeJson(this.destiHashMap, "destinations.json");
}
}

View File

@ -0,0 +1,52 @@
package com.sekwah.advancedportals.services;
import com.google.inject.Inject;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import com.sekwah.advancedportals.repository.PortalRepository;
import java.util.UUID;
public class PortalServices {
private final PortalRepository portalRepository;
@Inject
public PortalServices(PortalRepository portalRepository) {
this.portalRepository = portalRepository;
}
public void addSelectedPortal(UUID selectedPlayer, String portal) {
//portalRepository.save(selectedPlayer, portal);
}
public void removeSelectedPortal(UUID uuid) {
selectedPortal.invalidate(uuid);
}
public void addSelectedPosition(UUID uuid, boolean isPos1, PortalLocation portalLocation) {
selectedPositions.put(uuid, isPos1, portalLocation);
}
public void removeSelectedPosition(UUID uuid, boolean isPos1) {
selectedPositions.remove(uuid, isPos1);
}
public void removeAllSelectedHand(UUID uuid) {
selectedPositions.remove(uuid, true);
selectedPositions.remove(uuid, false);
}
public void activateCooldown(PlayerContainer player) {
}
public void playerLeave(PlayerContainer player) {
}
public boolean inPortalRegion(PlayerLocation loc) {
return false;
}
}

View File

@ -0,0 +1,7 @@
package com.sekwah.advancedportals.services;
public enum Response {
SUCCESS,
NAME_IN_USE,
}

View File

@ -2,7 +2,7 @@ package com.sekwah.advancedportals.spigot;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.CoreListeners;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.spigot.coreconnector.container.SpigotPlayerContainer;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.spigot.convertolddata;
import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.api.commands.SubCommand;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.spigot.coreconnector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.coreconnector.command.CommandHandler;
import com.sekwah.advancedportals.commands.CommandTemplate;
import com.sekwah.advancedportals.spigot.coreconnector.container.SpigotCommandSenderContainer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.spigot.coreconnector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.commands.CommandTemplate;
import com.sekwah.advancedportals.coreconnector.command.CommandRegister;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;

View File

@ -2,8 +2,8 @@ package com.sekwah.advancedportals.spigot.coreconnector.container;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.entities.PlayerLocation;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PlayerLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
import org.bukkit.Bukkit;

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.spigot.coreconnector.container;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
import org.bukkit.Material;
import org.bukkit.World;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.spigot.effect;
import com.sekwah.advancedportals.core.api.effect.WarpEffect;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.entities.PortalLocation;
import com.sekwah.advancedportals.api.effect.WarpEffect;
import com.sekwah.advancedportals.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.PortalLocation;
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
public class WarpEffectEnder extends WarpEffect {