Skip to content

Commit

Permalink
Whee changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityfox committed Jul 20, 2018
1 parent 9fa3af2 commit 6fdc68d
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 112 deletions.
2 changes: 1 addition & 1 deletion FoxCore-Sponge
4 changes: 3 additions & 1 deletion build.gradle
Expand Up @@ -16,7 +16,9 @@ buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath 'org.spongepowered:spongegradle:0.8.2-SNAPSHOT'
classpath 'org.spongepowered:event-impl-gen:5.2.0-SNAPSHOT'
classpath 'org.spongepowered:event-impl-gen:5.1.0-SNAPSHOT'
//classpath 'gradle.plugin.org.spongepowered:event-impl-gen:5.0.2'
//classpath 'gradle.plugin.org.spongepowered:event-impl-gen:5.1.0-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
#Wed May 30 12:43:00 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
6 changes: 3 additions & 3 deletions gradlew
Expand Up @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
warn ( ) {
echo "$*"
}

die () {
die ( ) {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save () {
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
Expand Up @@ -50,6 +50,7 @@
import net.foxdenstudio.sponge.foxguard.plugin.state.factory.ControllersStateFieldFactory;
import net.foxdenstudio.sponge.foxguard.plugin.state.factory.HandlersStateFieldFactory;
import net.foxdenstudio.sponge.foxguard.plugin.state.factory.RegionsStateFieldFactory;
import net.foxdenstudio.sponge.foxguard.plugin.util.DebugManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.Game;
Expand Down Expand Up @@ -241,9 +242,14 @@ public void registerCommands(GameInitializationEvent event) {

fgDispatcher.register(new CommandPriority(), "priority", "prio", "level", "rank");

fgDispatcher.register(new CommandTest(), "test");
fgDispatcher.register(new CommandLink2(true), "link2", "connect2", "attach2");
fgDispatcher.register(new CommandLink2(false), "unlink2", "disconnect2", "detach2");

// DEBUG USE
//fgDispatcher.register(new CommandTest(), "test");
//fgDispatcher.register(DebugManager.INSTANCE, "debug");


registerCoreCommands(fgDispatcher);

game.getCommandManager().register(this, fgDispatcher, "foxguard", "foxg", "fguard", "fg");
Expand Down
Expand Up @@ -35,7 +35,7 @@
import net.foxdenstudio.sponge.foxguard.plugin.FGManager;
import net.foxdenstudio.sponge.foxguard.plugin.controller.IController;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.listener.PlayerMoveListenerNew;
import net.foxdenstudio.sponge.foxguard.plugin.listener.PlayerMoveListener;
import net.foxdenstudio.sponge.foxguard.plugin.region.IRegion;
import net.foxdenstudio.sponge.foxguard.plugin.util.FGUtil;
import org.spongepowered.api.Sponge;
Expand Down Expand Up @@ -85,7 +85,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
}
AdvCmdParser.ParseResult parse = AdvCmdParser.builder().arguments(arguments).flagMapper(MAPPER).parse();
boolean hud = false;
PlayerMoveListenerNew.HUDConfig hudConfig = new PlayerMoveListenerNew.HUDConfig(false, false, false);
PlayerMoveListener.HUDConfig hudConfig = new PlayerMoveListener.HUDConfig(false, false, false);

String worldName = parse.flags.get("world");
World world = null;
Expand Down Expand Up @@ -239,7 +239,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
if (hud) {
Player player = (Player) source;
if (CommandHUD.instance().getIsHUDEnabled().get(player)) {
PlayerMoveListenerNew instance = PlayerMoveListenerNew.getInstance();
PlayerMoveListener instance = PlayerMoveListener.getInstance();
instance.getHudConfigMap().put(player, hudConfig);
instance.renderHUD(player, regionList, handlerList, hudConfig);
instance.showScoreboard(player);
Expand Down
@@ -1,7 +1,7 @@
package net.foxdenstudio.sponge.foxguard.plugin.config;

import net.foxdenstudio.sponge.foxguard.plugin.FoxGuardMain;
import net.foxdenstudio.sponge.foxguard.plugin.listener.PlayerMoveListenerNew;
import net.foxdenstudio.sponge.foxguard.plugin.listener.PlayerMoveListener;
import org.spongepowered.api.event.entity.MoveEntityEvent;

import javax.annotation.Nonnull;
Expand All @@ -25,7 +25,7 @@ public String setup(String setting) {
setting = getDefaultValue();
full = true;
}
PlayerMoveListenerNew pml = new PlayerMoveListenerNew(true);
PlayerMoveListener pml = new PlayerMoveListener(true);
plugin.registerListener(MoveEntityEvent.class, pml);
//plugin.registerListeners(pml.new Listeners());
return setting;
Expand Down
Expand Up @@ -31,6 +31,7 @@
import net.foxdenstudio.sponge.foxguard.plugin.flag.FlagSet;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.util.DebugManager;
import net.foxdenstudio.sponge.foxguard.plugin.util.ExtraContext;
import net.foxdenstudio.sponge.foxguard.plugin.util.FGUtil;
import org.spongepowered.api.block.BlockSnapshot;
Expand Down Expand Up @@ -67,6 +68,9 @@ public void handle(ChangeBlockEvent event) throws Exception {
|| tr.getOriginal().getState().getType().equals(BlockTypes.GRASS)
&& tr.getFinal().getState().getType().equals(BlockTypes.DIRT)) return;
}

DebugManager.INSTANCE.printEvent(event);

//DebugHelper.printBlockEvent(event);
/*FlagOld typeFlag;
if (event instanceof ChangeBlockEvent.Modify) typeFlag = FlagOld.BLOCK_MODIFY;
Expand Down Expand Up @@ -105,6 +109,7 @@ public void handle(ChangeBlockEvent event) throws Exception {
}
if(handlerSet.size() == 0) return;


User user;
if (event.getCause().containsType(Player.class)) {
user = event.getCause().first(Player.class).get();
Expand All @@ -114,6 +119,8 @@ public void handle(ChangeBlockEvent event) throws Exception {
user = null;
}



boolean[] flags = BASE_FLAG_SET.clone();

if (event instanceof ChangeBlockEvent.Modify) flags[MODIFY.id] = true;
Expand Down
Expand Up @@ -26,10 +26,12 @@
package net.foxdenstudio.sponge.foxguard.plugin.listener;

import com.flowpowered.math.vector.Vector3d;
import com.google.common.collect.ImmutableList;
import net.foxdenstudio.sponge.foxguard.plugin.FGManager;
import net.foxdenstudio.sponge.foxguard.plugin.FoxGuardMain;
import net.foxdenstudio.sponge.foxguard.plugin.flag.FlagSet;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.listener.util.EntityFlagCalculator;
import net.foxdenstudio.sponge.foxguard.plugin.listener.util.FGListenerUtil;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.util.ExtraContext;
Expand All @@ -51,6 +53,7 @@

public class InteractEntityListener implements EventListener<InteractEntityEvent> {

private static final EntityFlagCalculator ENTITY_FLAG_CALCULATOR = EntityFlagCalculator.getInstance();
private static final boolean[] BASE_FLAG_SET = FlagSet.arrayFromFlags(ROOT, DEBUFF, INTERACT, ENTITY);

@Override
Expand Down Expand Up @@ -91,8 +94,7 @@ public void handle(InteractEntityEvent event) throws Exception {
if (event instanceof InteractEntityEvent.Secondary.MainHand) flags[MAIN.id] = true;
else if (event instanceof InteractEntityEvent.Secondary.OffHand) flags[OFF.id] = true;
}
Entity entity = event.getTargetEntity();
FGListenerUtil.applyEntityFlags(entity, flags);
ENTITY_FLAG_CALCULATOR.applyEntityFlags(ImmutableList.of(event.getTargetEntity()), flags);
FlagSet flagSet = new FlagSet(flags);

List<IHandler> handlerList = new ArrayList<>(handlerSet);
Expand Down
Expand Up @@ -61,11 +61,11 @@
* Created by Fox on 1/4/2016.
* Project: SpongeForge
*/
public class PlayerMoveListenerNew implements EventListener<MoveEntityEvent> {
public class PlayerMoveListener implements EventListener<MoveEntityEvent> {

private static final boolean[] BASE_FLAG_SET = FlagSet.arrayFromFlags(ROOT, DEBUFF, MOVE);

private static PlayerMoveListenerNew instance;
private static PlayerMoveListener instance;

public final boolean full;

Expand All @@ -84,7 +84,7 @@ public class PlayerMoveListenerNew implements EventListener<MoveEntityEvent> {
});
private final Map<Player, HUDConfig> hudConfigMap = new WeakCacheMap<>((k, m) -> new HUDConfig());

public PlayerMoveListenerNew(boolean full) {
public PlayerMoveListener(boolean full) {
this.full = full;
if (instance == null) instance = this;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ public void showScoreboard(Player player) {
player.setScoreboard(this.scoreboardMap.get(player));
}

public static PlayerMoveListenerNew getInstance() {
public static PlayerMoveListener getInstance() {
return instance;
}

Expand Down
Expand Up @@ -30,6 +30,7 @@
import net.foxdenstudio.sponge.foxguard.plugin.flag.Flag;
import net.foxdenstudio.sponge.foxguard.plugin.flag.FlagSet;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.listener.util.EntityFlagCalculator;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.util.ExtraContext;
import org.spongepowered.api.entity.Entity;
Expand All @@ -54,25 +55,20 @@

public class SpawnEntityListener implements EventListener<SpawnEntityEvent> {

private static final EntityFlagCalculator ENTITY_FLAG_CALCULATOR = EntityFlagCalculator.getInstance();
private static final boolean[] BASE_FLAG_SET = FlagSet.arrayFromFlags(ROOT, DEBUFF, SPAWN, ENTITY);

@Override
public void handle(SpawnEntityEvent event) throws Exception {
if (event.isCancelled()) return;
if (event.getEntities().isEmpty()) return;
for (Entity entity : event.getEntities()) {
List<Entity> entities = event.getEntities();
if (entities.isEmpty()) return;

for (Entity entity : entities) {
if (entity instanceof Player) return;
}
User user;
if (event.getCause().containsType(Player.class)) {
user = event.getCause().first(Player.class).get();
} else if (event.getCause().containsType(User.class)) {
user = event.getCause().first(User.class).get();
} else {
user = null;
}

Entity oneEntity = event.getEntities().get(0);
//Entity oneEntity = event.getEntities().get(0);
/*if (oneEntity instanceof Arrow) {
Optional<UUID> creator = oneEntity.getCreator(), notifier = oneEntity.getNotifier();
Expand All @@ -89,29 +85,10 @@ public void handle(SpawnEntityEvent event) throws Exception {
}
}*/
boolean[] flags = BASE_FLAG_SET.clone();

if (oneEntity instanceof Living) {
flags[LIVING.id] = true;
if (oneEntity instanceof Agent) {
flags[AGENT.id] = true;
if (oneEntity instanceof Hostile) {
flags[HOSTILE.id] = true;
} else if (oneEntity instanceof Human) {
flags[HUMAN.id] = true;
} else {
flags[PASSIVE.id] = true;
}
}
} else if (oneEntity instanceof Hanging) {
flags[HANGING.id] = true;
}

FlagSet flagSet = new FlagSet(flags);

Set<IHandler> handlerSet = new HashSet<>();

for (Entity entity : event.getEntities()) {
for (Entity entity : entities) {
Location<World> loc = entity.getLocation();
Vector3d pos = loc.getPosition();
World world = loc.getExtent();
Expand All @@ -122,10 +99,24 @@ public void handle(SpawnEntityEvent event) throws Exception {
.forEach(handlerSet::add));
}



//TODO maybe throw a warning
if(handlerSet.size() == 0) return;

User user;
if (event.getCause().containsType(Player.class)) {
user = event.getCause().first(Player.class).get();
} else if (event.getCause().containsType(User.class)) {
user = event.getCause().first(User.class).get();
} else {
user = null;
}

boolean[] flags = BASE_FLAG_SET.clone();

ENTITY_FLAG_CALCULATOR.applyEntityFlags(entities, flags);

FlagSet flagSet = new FlagSet(flags);

ArrayList<IHandler> handlerList = new ArrayList<>(handlerSet);
Collections.sort(handlerList);
int currPriority = handlerList.get(0).getPriority();
Expand Down
Expand Up @@ -51,7 +51,6 @@ public void applyEntityFlags(Collection<Entity> entities, boolean[] flags) {
mini.apply(flags);
}

@SuppressWarnings("Duplicates")
private MiniFlagSet getMiniFlag(Map<Class<? extends Entity>, Entity> types) {
MiniFlagSet mini = new MiniFlagSet();
Set<Flag> totalFlags = new HashSet<>();
Expand Down Expand Up @@ -210,7 +209,7 @@ public void apply(boolean[] flagset) {
}
}

public static void main(String[] args) {
/*public static void main(String[] args) {
EntityFlagCalculator calculator = EntityFlagCalculator.getInstance();
FlagRegistry registry = FlagRegistry.getInstance();
Entity entity = (Entity) Proxy.newProxyInstance(EntityFlagCalculator.class.getClassLoader(),
Expand All @@ -220,5 +219,5 @@ public static void main(String[] args) {
for (Flag flag : flags) {
System.out.println(flag.name);
}
}
}*/
}

This file was deleted.

0 comments on commit 6fdc68d

Please sign in to comment.