mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 10:36:17 +01:00
Moved classes and packages to be in src > main > java
This commit is contained in:
parent
7d07c55b67
commit
b9475a3550
@ -2,8 +2,8 @@ package com.sekwah.advancedportals.core;
|
|||||||
|
|
||||||
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||||
import com.sekwah.advancedportals.core.api.destination.Destination;
|
import com.sekwah.advancedportals.core.api.destination.Destination;
|
||||||
import com.sekwah.advancedportals.core.api.managers.DestinationManager;
|
import com.sekwah.advancedportals.core.repository.DestinationRepositoryImpl;
|
||||||
import com.sekwah.advancedportals.core.api.managers.PortalManager;
|
import com.sekwah.advancedportals.core.repository.PortalRepositoryImpl;
|
||||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
|
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
|
||||||
import com.sekwah.advancedportals.core.api.registry.WarpEffectRegistry;
|
import com.sekwah.advancedportals.core.api.registry.WarpEffectRegistry;
|
||||||
@ -37,8 +37,8 @@ public class AdvancedPortalsCore {
|
|||||||
private CommandWithSubCommands portalCommand;
|
private CommandWithSubCommands portalCommand;
|
||||||
private CommandWithSubCommands destiCommand;
|
private CommandWithSubCommands destiCommand;
|
||||||
|
|
||||||
private PortalManager portalManager;
|
private PortalRepositoryImpl portalRepositoryImpl;
|
||||||
private DestinationManager destiManager;
|
private DestinationRepositoryImpl destiManager;
|
||||||
|
|
||||||
public static final String version = "1.0.0";
|
public static final String version = "1.0.0";
|
||||||
public static final String lastTranslationUpdate = "1.0.0";
|
public static final String lastTranslationUpdate = "1.0.0";
|
||||||
@ -103,8 +103,8 @@ public class AdvancedPortalsCore {
|
|||||||
|
|
||||||
private void onEnable() {
|
private void onEnable() {
|
||||||
this.coreListeners = new CoreListeners(this);
|
this.coreListeners = new CoreListeners(this);
|
||||||
this.portalManager = new PortalManager(this);
|
this.portalRepositoryImpl = new PortalRepositoryImpl(this);
|
||||||
this.destiManager = new DestinationManager(this);
|
this.destiManager = new DestinationRepositoryImpl(this);
|
||||||
this.warpEffectRegistry = new WarpEffectRegistry();
|
this.warpEffectRegistry = new WarpEffectRegistry();
|
||||||
this.portalTagRegistry = new TagRegistry<>();
|
this.portalTagRegistry = new TagRegistry<>();
|
||||||
this.destiTagRegistry = new TagRegistry<>();
|
this.destiTagRegistry = new TagRegistry<>();
|
||||||
@ -117,7 +117,7 @@ public class AdvancedPortalsCore {
|
|||||||
this.registerPortalCommand();
|
this.registerPortalCommand();
|
||||||
this.registerDestinationCommand();
|
this.registerDestinationCommand();
|
||||||
|
|
||||||
this.portalManager.loadPortals();
|
this.portalRepositoryImpl.loadPortals();
|
||||||
|
|
||||||
this.destiManager.loadDestinations();
|
this.destiManager.loadDestinations();
|
||||||
|
|
||||||
@ -196,11 +196,11 @@ public class AdvancedPortalsCore {
|
|||||||
return instance.coreListeners;
|
return instance.coreListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PortalManager getPortalManager() {
|
public static PortalRepositoryImpl getPortalManager() {
|
||||||
return instance.portalManager;
|
return instance.portalRepositoryImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DestinationManager getDestinationManager() {
|
public static DestinationRepositoryImpl getDestinationManager() {
|
||||||
return instance.destiManager;
|
return instance.destiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.core;
|
package com.sekwah.advancedportals.core;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
import com.sekwah.advancedportals.core.entities.PlayerLocation;
|
||||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
||||||
|
@ -2,12 +2,12 @@ package com.sekwah.advancedportals.core.api.destination;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||||
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
|
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
|
||||||
import com.sekwah.advancedportals.core.api.warphandler.ActivationData;
|
import com.sekwah.advancedportals.core.api.warphandler.ActivationData;
|
||||||
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
||||||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
import com.sekwah.advancedportals.core.entities.PlayerLocation;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.core.api.effect;
|
package com.sekwah.advancedportals.core.api.effect;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.core.api.effect;
|
package com.sekwah.advancedportals.core.api.effect;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,8 @@ import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
|||||||
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
|
import com.sekwah.advancedportals.core.api.registry.TagRegistry;
|
||||||
import com.sekwah.advancedportals.core.api.warphandler.ActivationData;
|
import com.sekwah.advancedportals.core.api.warphandler.ActivationData;
|
||||||
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
||||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.core.commands.subcommands;
|
package com.sekwah.advancedportals.core.commands.subcommands;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package com.sekwah.advancedportals.core.commands.subcommands.desti;
|
|||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||||
import com.sekwah.advancedportals.core.api.destination.Destination;
|
import com.sekwah.advancedportals.core.api.destination.Destination;
|
||||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||||
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
|
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
|
@ -3,7 +3,7 @@ package com.sekwah.advancedportals.core.commands.subcommands.portal;
|
|||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||||
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
|
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.sekwah.advancedportals.core.api.portal;
|
package com.sekwah.advancedportals.core.entities;
|
||||||
|
|
||||||
public class DataTag {
|
public class DataTag {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.sekwah.advancedportals.core.data;
|
package com.sekwah.advancedportals.core.entities;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.sekwah.advancedportals.core.data;
|
package com.sekwah.advancedportals.core.entities;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.sekwah.advancedportals.core.enums;
|
||||||
|
|
||||||
|
public enum EnumHandSelection {
|
||||||
|
LEFTHAND,
|
||||||
|
RIGHTHAND
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.sekwah.advancedportals.core.repository;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.sekwah.advancedportals.core.api.destination.Destination;
|
||||||
|
|
||||||
|
public interface DestinationRepository {
|
||||||
|
void create(String name, Destination destination);
|
||||||
|
|
||||||
|
void delete(String name);
|
||||||
|
|
||||||
|
ImmutableMap<String, Destination> getDestinations();
|
||||||
|
}
|
@ -1,33 +1,41 @@
|
|||||||
package com.sekwah.advancedportals.core.api.managers;
|
package com.sekwah.advancedportals.core.repository;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
import com.sekwah.advancedportals.core.api.destination.Destination;
|
import com.sekwah.advancedportals.core.api.destination.Destination;
|
||||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||||
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
||||||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
import com.sekwah.advancedportals.core.entities.PlayerLocation;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
@Singleton
|
||||||
* @author sekwah41
|
public class DestinationRepositoryImpl implements DestinationRepository {
|
||||||
*/
|
private Map<String, Destination> destiHashMap = new HashMap<>();
|
||||||
public class DestinationManager {
|
|
||||||
|
|
||||||
private final AdvancedPortalsCore portalsCore;
|
@Override
|
||||||
/**
|
public void create(String name, Destination destination) {
|
||||||
* Contains all the data for the destinations
|
destiHashMap.put(name, destination);
|
||||||
*/
|
|
||||||
private HashMap<String, Destination> destiHashMap = new HashMap<>();
|
|
||||||
|
|
||||||
public DestinationManager(AdvancedPortalsCore portalsCore) {
|
|
||||||
this.portalsCore = portalsCore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String name) {
|
||||||
|
destiHashMap.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImmutableMap<String, Destination> getDestinations() {
|
||||||
|
return ImmutableMap.copyOf(destiHashMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Destination createDesti(String name, PlayerContainer player, PlayerLocation playerLocation, ArrayList<DataTag> tags) throws PortalException {
|
public Destination createDesti(String name, PlayerContainer player, PlayerLocation playerLocation, ArrayList<DataTag> tags) throws PortalException {
|
||||||
if(name == null || name.equals("")) {
|
if(name == null || name.equals("")) {
|
||||||
throw new PortalException("desti.error.noname");
|
throw new PortalException("desti.error.noname");
|
@ -3,11 +3,11 @@ package com.sekwah.advancedportals.core.api.managers;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
import com.sekwah.advancedportals.core.entities.DataTag;
|
||||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||||
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
||||||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
import com.sekwah.advancedportals.core.entities.PlayerLocation;
|
||||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.sekwah.advancedportals.core.repository;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
|
import com.sekwah.advancedportals.core.enums.EnumHandSelection;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface SelectionRepository {
|
||||||
|
void addSelectedPortal(UUID selectedPlayer, String portal);
|
||||||
|
|
||||||
|
void removeSelectedPortal(UUID uuid);
|
||||||
|
|
||||||
|
void addSelectedHand(UUID uuid, EnumHandSelection enumHandSelection, PortalLocation portalLocation);
|
||||||
|
|
||||||
|
void removeSelectedHand(UUID uuid, EnumHandSelection enumHandSelection);
|
||||||
|
|
||||||
|
void removeAllSelectedHand(UUID uuid);
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.sekwah.advancedportals.core.repository;
|
||||||
|
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheBuilderSpec;
|
||||||
|
import com.google.common.collect.HashBasedTable;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Table;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||||
|
import com.sekwah.advancedportals.core.enums.EnumHandSelection;
|
||||||
|
import com.sun.media.jfxmedia.events.PlayerStateEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class SelectionRepositoryImpl implements SelectionRepository {
|
||||||
|
Cache<UUID, String> selectedPortal = CacheBuilder.newBuilder()
|
||||||
|
.concurrencyLevel(4)
|
||||||
|
.expireAfterAccess(30, TimeUnit.DAYS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Table<UUID, EnumHandSelection, PortalLocation> selectedHand = HashBasedTable.create();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addSelectedPortal(UUID selectedPlayer, String portal) {
|
||||||
|
selectedPortal.put(selectedPlayer, portal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeSelectedPortal(UUID uuid) {
|
||||||
|
selectedPortal.invalidate(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addSelectedHand(UUID uuid, EnumHandSelection enumHandSelection, PortalLocation portalLocation) {
|
||||||
|
selectedHand.put(uuid, enumHandSelection, portalLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeSelectedHand(UUID uuid, EnumHandSelection enumHandSelection) {
|
||||||
|
selectedHand.remove(uuid, enumHandSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAllSelectedHand(UUID uuid) {
|
||||||
|
selectedHand.remove(uuid, EnumHandSelection.LEFTHAND);
|
||||||
|
selectedHand.remove(uuid, EnumHandSelection.RIGHTHAND);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user