Restructures the plugin and starts work on cleaning and commenting the code

This commit is contained in:
2021-02-07 03:37:25 +01:00
parent 2480a432a4
commit 6ff998ac3b
46 changed files with 4918 additions and 4690 deletions

View File

@ -0,0 +1,71 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/*
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@SuppressWarnings("unused")
public class StargateAccessEvent extends StargateEvent {
private final Player player;
private boolean deny;
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateAccessEvent(Player player, Portal portal, boolean deny) {
super("StargateAccessEvent", portal);
this.player = player;
this.deny = deny;
}
/**
* Gets whether the player should be denied access
* @return <p>Whether the player should be denied access</p>
*/
public boolean getDeny() {
return this.deny;
}
/**
* Sets whether to deny the player
* @param deny <p>Whether to deny the player</p>
*/
public void setDeny(boolean deny) {
this.deny = deny;
}
public Player getPlayer() {
return this.player;
}
}

View File

@ -0,0 +1,72 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargateActivateEvent extends StargateEvent {
private final Player player;
private ArrayList<String> destinations;
private String destination;
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateActivateEvent(Portal portal, Player player, ArrayList<String> destinations, String destination) {
super("StargatActivateEvent", portal);
this.player = player;
this.destinations = destinations;
this.destination = destination;
}
public Player getPlayer() {
return player;
}
public ArrayList<String> getDestinations() {
return destinations;
}
public void setDestinations(ArrayList<String> destinations) {
this.destinations = destinations;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
}

View File

@ -0,0 +1,53 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.event.HandlerList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargateCloseEvent extends StargateEvent {
private boolean force;
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateCloseEvent(Portal portal, boolean force) {
super("StargateCloseEvent", portal);
this.force = force;
}
public boolean getForce() {
return force;
}
public void setForce(boolean force) {
this.force = force;
}
}

View File

@ -0,0 +1,85 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargateCreateEvent extends StargateEvent {
private final Player player;
private boolean deny;
private String denyReason;
private final String[] lines;
private int cost;
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateCreateEvent(Player player, Portal portal, String[] lines, boolean deny, String denyReason, int cost) {
super("StargateCreateEvent", portal);
this.player = player;
this.lines = lines;
this.deny = deny;
this.denyReason = denyReason;
this.cost = cost;
}
public Player getPlayer() {
return player;
}
public String getLine(int index) throws IndexOutOfBoundsException {
return lines[index];
}
public boolean getDeny() {
return deny;
}
public void setDeny(boolean deny) {
this.deny = deny;
}
public String getDenyReason() {
return denyReason;
}
public void setDenyReason(String denyReason) {
this.denyReason = denyReason;
}
public int getCost() {
return cost;
}
public void setCost(int cost) {
this.cost = cost;
}
}

View File

@ -0,0 +1,41 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.event.HandlerList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargateDeactivateEvent extends StargateEvent {
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateDeactivateEvent(Portal portal) {
super("StargatDeactivateEvent", portal);
}
}

View File

@ -0,0 +1,79 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargateDestroyEvent extends StargateEvent {
private final Player player;
private boolean deny;
private String denyReason;
private int cost;
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateDestroyEvent(Portal portal, Player player, boolean deny, String denyMsg, int cost) {
super("StargateDestroyEvent", portal);
this.player = player;
this.deny = deny;
this.denyReason = denyMsg;
this.cost = cost;
}
public Player getPlayer() {
return player;
}
public boolean getDeny() {
return deny;
}
public void setDeny(boolean deny) {
this.deny = deny;
}
public String getDenyReason() {
return denyReason;
}
public void setDenyReason(String denyReason) {
this.denyReason = denyReason;
}
public int getCost() {
return cost;
}
public void setCost(int cost) {
this.cost = cost;
}
}

View File

@ -0,0 +1,54 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/*
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* An abstract event describing any stargate event
*/
@SuppressWarnings("unused")
public abstract class StargateEvent extends Event implements Cancellable {
protected Portal portal;
protected boolean cancelled;
public StargateEvent(String event, Portal portal) {
this.portal = portal;
this.cancelled = false;
}
public Portal getPortal() {
return portal;
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -0,0 +1,65 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargateOpenEvent extends StargateEvent {
private final Player player;
private boolean force;
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargateOpenEvent(Player player, Portal portal, boolean force) {
super("StargateOpenEvent", portal);
this.player = player;
this.force = force;
}
/**
* Return the player than opened the gate.
*
* @return player than opened the gate
*/
public Player getPlayer() {
return player;
}
public boolean getForce() {
return force;
}
public void setForce(boolean force) {
this.force = force;
}
}

View File

@ -0,0 +1,85 @@
package net.knarcraft.stargate.event;
import net.knarcraft.stargate.Portal;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* stargate - A portal plugin for Bukkit
* Copyright (C) 2011, 2012 Steven "Drakia" Scott <Contact@TheDgtl.net>
* Copyright (C) 2021 Kristian Knarvik
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* 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 Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class StargatePortalEvent extends StargateEvent {
private final Player player;
private final Portal destination;
private Location exit;
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public StargatePortalEvent(Player player, Portal portal, Portal dest, Location exit) {
super("StargatePortalEvent", portal);
this.player = player;
this.destination = dest;
this.exit = exit;
}
/**
* Return the player that went through the gate.
*
* @return player that went through the gate
*/
public Player getPlayer() {
return player;
}
/**
* Return the destination gate
*
* @return destination gate
*/
public Portal getDestination() {
return destination;
}
/**
* Return the location of the players exit point
*
* @return org.bukkit.Location Location of the exit point
*/
public Location getExit() {
return exit;
}
/**
* Set the location of the players exit point
*/
public void setExit(Location loc) {
this.exit = loc;
}
}