Move decreeSystem into decreeCommand

Why the extra class?
This commit is contained in:
CocoTheOwner 2021-08-12 23:35:11 +02:00
parent 4f7e25038c
commit 3d68caed6b
3 changed files with 22 additions and 44 deletions

View File

@ -18,5 +18,26 @@
package com.volmit.iris.util.decree;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
public class DecreeCommand {
private static final KList<DecreeParameterHandler<?>> handlers = Iris.initialize("com.volmit.iris.util.decree.handlers", null).convert((i) -> (DecreeParameterHandler<?>) i);
/**
* Get the handler for the specified type
* @param type The type to handle
* @return The corresponding {@link DecreeParameterHandler}, or null
*/
public static DecreeParameterHandler<?> getHandler(Class<?> type)
{
for(DecreeParameterHandler<?> i : handlers)
{
if(i.supports(type))
{
return i;
}
}
return null;
}
}

View File

@ -39,7 +39,7 @@ public class DecreeParameter {
}
public DecreeParameterHandler<?> getHandler() {
return DecreeSystem.getHandler(getType());
return DecreeCommand.getHandler(getType());
}
public Class<?> getType() {

View File

@ -1,43 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.decree;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
public class DecreeSystem {
private static final KList<DecreeParameterHandler<?>> handlers = Iris.initialize("com.volmit.iris.util.decree.handlers", null).convert((i) -> (DecreeParameterHandler<?>) i);
/**
* Get the handler for the specified type
* @param type The type to handle
* @return The corresponding {@link DecreeParameterHandler}, or null
*/
public static DecreeParameterHandler<?> getHandler(Class<?> type)
{
for(DecreeParameterHandler<?> i : handlers)
{
if(i.supports(type))
{
return i;
}
}
return null;
}
}