Skip to content

Commit

Permalink
Merge pull request #98 from ClubObsidian/4.x
Browse files Browse the repository at this point in the history
4.x
  • Loading branch information
virustotalop authored Sep 17, 2019
2 parents c91fcd3 + 829955c commit 7e7e1d7
Show file tree
Hide file tree
Showing 51 changed files with 882 additions and 801 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Designed to make writing menus easy.
* Custom replacers
* Built-in replacer support
* Support for [PlaceholderAPI](https://www.spigotmc.org/resources/placeholderapi.6245/)
* User defined macros
* Loading guis from a remote location
* Currently supports loading from a webserver
* Different gui types
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ shadowJar {
relocate 'com.google.common', 'com.clubobsidian.dynamicgui.shaded.guava'
relocate 'com.google.gson', 'com.clubobsidian.dynamicgui.shaded.gson'
relocate 'org.yaml.snakeyaml', 'com.clubobsidian.dynamicgui.shaded.snakeyaml'
relocate 'com.clubobsidian.trident', 'com.clubobsidian.dynamicgui.shaded.trident'
baseName = 'DynamicGui'
classifier = ''
}
Expand All @@ -59,7 +60,8 @@ dependencies {
compile 'org.apache.commons:commons-lang3:3.9'
compile 'commons-io:commons-io:2.6'
compile 'com.github.clubobsidian:wrappy:1.8.0'
compile 'com.github.clubobsidian:trident:1.1.0'
compile 'com.github.clubobsidian:trident:2.0.1'
compile 'com.github.clubobsidian:dynamicguiparser:4f56cd4bbd'
compile 'com.udojava:EvalEx:2.1'
compile 'com.github.ClubObsidian:FuzzUtil:1.1.0'
}
18 changes: 10 additions & 8 deletions src/main/java/com/clubobsidian/dynamicgui/DynamicGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,20 @@
import com.clubobsidian.dynamicgui.function.impl.StatisticFunction;
import com.clubobsidian.dynamicgui.function.impl.condition.ConditionFunction;
import com.clubobsidian.dynamicgui.logger.LoggerWrapper;
import com.clubobsidian.dynamicgui.manager.dynamicgui.AnimationManager;
import com.clubobsidian.dynamicgui.manager.dynamicgui.AnimationReplacerManager;
import com.clubobsidian.dynamicgui.manager.dynamicgui.FunctionManager;
import com.clubobsidian.dynamicgui.manager.dynamicgui.GuiManager;
import com.clubobsidian.dynamicgui.manager.dynamicgui.ReplacerManager;
import com.clubobsidian.dynamicgui.messaging.MessagingRunnable;
import com.clubobsidian.dynamicgui.plugin.DynamicGuiPlugin;
import com.clubobsidian.dynamicgui.registry.replacer.impl.DynamicGuiAnimationReplacerRegistry;
import com.clubobsidian.dynamicgui.registry.replacer.impl.DynamicGuiReplacerRegistry;
import com.clubobsidian.dynamicgui.replacer.Replacer;
import com.clubobsidian.dynamicgui.server.FakeServer;
import com.clubobsidian.dynamicgui.util.ChatColor;

import com.clubobsidian.trident.EventManager;
import com.clubobsidian.trident.impl.javaassist.JavaAssistEventManager;
import com.clubobsidian.trident.EventBus;
import com.clubobsidian.trident.eventbus.javassist.JavassistEventBus;

import com.clubobsidian.wrappy.Configuration;

Expand All @@ -83,13 +85,13 @@ public class DynamicGui {
private boolean redis;
private Map<String, Integer> serverPlayerCount;

private EventManager eventManager;
private EventBus eventManager;
private DynamicGuiPlugin plugin;
private FakeServer server;
private LoggerWrapper<?> loggerWrapper;
private DynamicGui(DynamicGuiPlugin plugin, FakeServer server, LoggerWrapper<?> loggerWrapper)
{
this.eventManager = new JavaAssistEventManager();
this.eventManager = new JavassistEventBus();
this.plugin = plugin;
this.server = server;
this.loggerWrapper = loggerWrapper;
Expand All @@ -105,6 +107,8 @@ private void init()
this.checkForProxy();
this.registerListeners();
ReplacerManager.get().registerReplacerRegistry(DynamicGuiReplacerRegistry.get());
AnimationReplacerManager.get().registerReplacerRegistry(DynamicGuiAnimationReplacerRegistry.get());
AnimationManager.get();
}

private void setupFileStructure()
Expand Down Expand Up @@ -223,8 +227,6 @@ private void loadFunctions()
//FunctionApi.get().addFunction(new ExpPayFunction("payexp"));
FunctionManager.get().addFunction(new GuiFunction("gui"));


FunctionManager.get().addFunction(new MoneyWithdrawFunction("pay"));
FunctionManager.get().addFunction(new MoneyWithdrawFunction("moneywithdraw"));
FunctionManager.get().addFunction(new MoneyDepositFunction("moneydeposit"));
FunctionManager.get().addFunction(new MoneyBalanceFunction("moneybalance"));
Expand Down Expand Up @@ -312,7 +314,7 @@ public DynamicGuiPlugin getPlugin()
return this.plugin;
}

public EventManager getEventManager()
public EventBus getEventBus()
{
return this.eventManager;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.clubobsidian.dynamicgui.animation;

public interface AnimationHolder extends Refreshable {

public int getCurrentTick();
public int tick();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.clubobsidian.dynamicgui.animation;

public interface Refreshable {

public int getUpdateInterval();

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
package com.clubobsidian.dynamicgui.builder;

import com.clubobsidian.dynamicgui.function.EmptyFunction;
import com.clubobsidian.dynamicgui.function.Function;
import com.clubobsidian.dynamicgui.parser.function.FunctionData;

public class FunctionBuilder {

Expand All @@ -35,8 +34,8 @@ public FunctionBuilder setData(String data)
return this;
}

public Function build()
public FunctionData build()
{
return new EmptyFunction(this.name, this.data);
return new FunctionData(this.name, this.data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
Copyright 2019 Club Obsidian and contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.clubobsidian.dynamicgui.builder;

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

import com.clubobsidian.dynamicgui.parser.function.FunctionData;
import com.clubobsidian.dynamicgui.parser.function.FunctionToken;
import com.clubobsidian.dynamicgui.parser.function.FunctionType;

public class FunctionTokenBuilder {

private String name;
private List<FunctionType> types;
private List<FunctionData> functions;
private List<FunctionData> failOnFunctions;
public FunctionTokenBuilder()
{
this.name = UUID.randomUUID().toString();
this.types = new ArrayList<>();
this.functions = new ArrayList<>();
this.failOnFunctions = new ArrayList<>();
}

public FunctionTokenBuilder addType(String type)
{
FunctionType functionType = FunctionType.valueOf(type.toUpperCase());
this.types.add(functionType);
return this;
}

public FunctionTokenBuilder addType(String... types)
{
for(String t : types)
{
this.addType(t);
}
return this;
}

public FunctionTokenBuilder addFunction(String name, String data)
{
return this.addFailOnFunction(new FunctionData(name, data));
}

public FunctionTokenBuilder addFunction(FunctionData data)
{
this.functions.add(data);
return this;
}

public FunctionTokenBuilder addFunction(FunctionData...datas)
{
for(FunctionData data : datas)
{
this.addFunction(data);
}

return this;
}

public FunctionTokenBuilder addFailOnFunction(String name, String data)
{
return this.addFailOnFunction(new FunctionData(name, data));
}

public FunctionTokenBuilder addFailOnFunction(FunctionData data)
{
this.failOnFunctions.add(data);
return this;
}

public FunctionTokenBuilder addFailOnFunction(FunctionData...datas)
{
for(FunctionData data : datas)
{
this.addFunction(data);
}

return this;
}

public FunctionToken build()
{
return new FunctionToken(this.name, this.types, this.functions, this.failOnFunctions);
}
}
52 changes: 27 additions & 25 deletions src/main/java/com/clubobsidian/dynamicgui/builder/GuiBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import java.util.List;
import java.util.Map;

import com.clubobsidian.dynamicgui.function.Function;
import com.clubobsidian.dynamicgui.gui.Gui;
import com.clubobsidian.dynamicgui.gui.ModeEnum;
import com.clubobsidian.dynamicgui.gui.Slot;
import com.clubobsidian.dynamicgui.parser.function.tree.FunctionTree;
import com.clubobsidian.dynamicgui.world.LocationWrapper;

public class GuiBuilder {
Expand All @@ -34,11 +34,16 @@ public class GuiBuilder {
private int rows;
private Boolean close;
private ModeEnum modeEnum;
private List<Integer> npcIds = new ArrayList<>();
private List<Slot> slots = new ArrayList<>();
private List<LocationWrapper<?>> locs = new ArrayList<>();
private List<Function> functions = new ArrayList<>();
private Map<String,List<Function>> failFunctions = new HashMap<>();
private Map<String, List<Integer>> npcIds;
private List<Slot> slots;
private List<LocationWrapper<?>> locs;
private FunctionTree functionTree;
public GuiBuilder()
{
this.npcIds = new HashMap<>();
this.slots = new ArrayList<>();
this.locs = new ArrayList<>();
}

public GuiBuilder setType(String type)
{
Expand Down Expand Up @@ -81,26 +86,33 @@ public GuiBuilder setModeEnum(ModeEnum modeEnum)
return this;
}

public GuiBuilder addNpcId(Integer id)
public GuiBuilder addNpcId(String plugin, Integer id)
{
this.npcIds.add(id);
List<Integer> npcs = this.npcIds.get(plugin);
if(npcs == null)
{
npcs = new ArrayList<>();
this.npcIds.put(plugin, npcs);
}

npcs.add(id);
return this;
}

public GuiBuilder addNpcId(Integer[] npcIds)
public GuiBuilder addNpcId(String plugin, Integer[] npcIds)
{
for(Integer id : npcIds)
{
this.npcIds.add(id);
this.addNpcId(plugin, id);
}
return this;
}

public GuiBuilder addNpcId(List<Integer> npcIds)
public GuiBuilder addNpcId(String plugin, List<Integer> npcIds)
{
for(Integer id : npcIds)
{
this.npcIds.add(id);
this.addNpcId(plugin, id);
}
return this;
}
Expand All @@ -117,24 +129,14 @@ public GuiBuilder addLocation(LocationWrapper<?> loc)
return this;
}

public GuiBuilder addFunction(Function function)
{
this.functions.add(function);
return this;
}

public GuiBuilder addFailFunction(String failOn, Function function)
public GuiBuilder setFunctionTree(FunctionTree functionTree)
{
if(this.failFunctions.get(failOn) == null)
{
this.failFunctions.put(failOn, new ArrayList<>());
}
this.failFunctions.get(failOn).add(function);
this.functionTree = functionTree;
return this;
}

public Gui build()
{
return new Gui(this.name, this.type, this.title, this.rows, this.close, this.modeEnum, this.npcIds, this.slots, this.locs, this.functions, this.failFunctions);
return new Gui(this.name, this.type, this.title, this.rows, this.close, this.modeEnum, this.npcIds, this.slots, this.locs, this.functionTree);
}
}
Loading

0 comments on commit 7e7e1d7

Please sign in to comment.