Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

View File

@@ -1,127 +1,127 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* @author Forsaiken
*/
public final class AuctionDateGenerator
{
public static final String FIELD_INTERVAL = "interval";
public static final String FIELD_DAY_OF_WEEK = "day_of_week";
public static final String FIELD_HOUR_OF_DAY = "hour_of_day";
public static final String FIELD_MINUTE_OF_HOUR = "minute_of_hour";
private static final long MILLIS_IN_WEEK = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS);
private final Calendar _calendar;
private final int _interval;
private int _day_of_week;
private int _hour_of_day;
private int _minute_of_hour;
public AuctionDateGenerator(StatsSet config) throws IllegalArgumentException
{
_calendar = Calendar.getInstance();
_interval = config.getInt(FIELD_INTERVAL, -1);
// NC week start in Monday.
final int fixedDayWeek = config.getInt(FIELD_DAY_OF_WEEK, -1) + 1;
_day_of_week = (fixedDayWeek > 7) ? 1 : fixedDayWeek;
_hour_of_day = config.getInt(FIELD_HOUR_OF_DAY, -1);
_minute_of_hour = config.getInt(FIELD_MINUTE_OF_HOUR, -1);
checkDayOfWeek(-1);
checkHourOfDay(-1);
checkMinuteOfHour(0);
}
public final synchronized long nextDate(long date)
{
_calendar.setTimeInMillis(date);
_calendar.set(Calendar.MILLISECOND, 0);
_calendar.set(Calendar.SECOND, 0);
_calendar.set(Calendar.MINUTE, _minute_of_hour);
_calendar.set(Calendar.HOUR_OF_DAY, _hour_of_day);
if (_day_of_week > 0)
{
_calendar.set(Calendar.DAY_OF_WEEK, _day_of_week);
return calcDestTime(_calendar.getTimeInMillis(), date, MILLIS_IN_WEEK);
}
return calcDestTime(_calendar.getTimeInMillis(), date, TimeUnit.MILLISECONDS.convert(_interval, TimeUnit.DAYS));
}
private final long calcDestTime(long time, long date, long add)
{
if (time < date)
{
time += ((date - time) / add) * add;
if (time < date)
{
time += add;
}
}
return time;
}
private final void checkDayOfWeek(int defaultValue)
{
if ((_day_of_week < 1) || (_day_of_week > 7))
{
if ((defaultValue == -1) && (_interval < 1))
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_DAY_OF_WEEK + "': " + (_day_of_week == -1 ? "not found" : _day_of_week));
}
_day_of_week = defaultValue;
}
else if (_interval > 1)
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_INTERVAL + "' and '" + FIELD_DAY_OF_WEEK + "': you can use only one, not both");
}
}
private final void checkHourOfDay(int defaultValue)
{
if ((_hour_of_day < 0) || (_hour_of_day > 23))
{
if (defaultValue == -1)
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_HOUR_OF_DAY + "': " + (_hour_of_day == -1 ? "not found" : _hour_of_day));
}
_hour_of_day = defaultValue;
}
}
private final void checkMinuteOfHour(int defaultValue)
{
if ((_minute_of_hour < 0) || (_minute_of_hour > 59))
{
if (defaultValue == -1)
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_MINUTE_OF_HOUR + "': " + (_minute_of_hour == -1 ? "not found" : _minute_of_hour));
}
_minute_of_hour = defaultValue;
}
}
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* @author Forsaiken
*/
public final class AuctionDateGenerator
{
public static final String FIELD_INTERVAL = "interval";
public static final String FIELD_DAY_OF_WEEK = "day_of_week";
public static final String FIELD_HOUR_OF_DAY = "hour_of_day";
public static final String FIELD_MINUTE_OF_HOUR = "minute_of_hour";
private static final long MILLIS_IN_WEEK = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS);
private final Calendar _calendar;
private final int _interval;
private int _day_of_week;
private int _hour_of_day;
private int _minute_of_hour;
public AuctionDateGenerator(StatsSet config) throws IllegalArgumentException
{
_calendar = Calendar.getInstance();
_interval = config.getInt(FIELD_INTERVAL, -1);
// NC week start in Monday.
final int fixedDayWeek = config.getInt(FIELD_DAY_OF_WEEK, -1) + 1;
_day_of_week = (fixedDayWeek > 7) ? 1 : fixedDayWeek;
_hour_of_day = config.getInt(FIELD_HOUR_OF_DAY, -1);
_minute_of_hour = config.getInt(FIELD_MINUTE_OF_HOUR, -1);
checkDayOfWeek(-1);
checkHourOfDay(-1);
checkMinuteOfHour(0);
}
public synchronized final long nextDate(long date)
{
_calendar.setTimeInMillis(date);
_calendar.set(Calendar.MILLISECOND, 0);
_calendar.set(Calendar.SECOND, 0);
_calendar.set(Calendar.MINUTE, _minute_of_hour);
_calendar.set(Calendar.HOUR_OF_DAY, _hour_of_day);
if (_day_of_week > 0)
{
_calendar.set(Calendar.DAY_OF_WEEK, _day_of_week);
return calcDestTime(_calendar.getTimeInMillis(), date, MILLIS_IN_WEEK);
}
return calcDestTime(_calendar.getTimeInMillis(), date, TimeUnit.MILLISECONDS.convert(_interval, TimeUnit.DAYS));
}
private long calcDestTime(long time, long date, long add)
{
if (time < date)
{
time += ((date - time) / add) * add;
if (time < date)
{
time += add;
}
}
return time;
}
private void checkDayOfWeek(int defaultValue)
{
if ((_day_of_week < 1) || (_day_of_week > 7))
{
if ((defaultValue == -1) && (_interval < 1))
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_DAY_OF_WEEK + "': " + (_day_of_week == -1 ? "not found" : _day_of_week));
}
_day_of_week = defaultValue;
}
else if (_interval > 1)
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_INTERVAL + "' and '" + FIELD_DAY_OF_WEEK + "': you can use only one, not both");
}
}
private void checkHourOfDay(int defaultValue)
{
if ((_hour_of_day < 0) || (_hour_of_day > 23))
{
if (defaultValue == -1)
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_HOUR_OF_DAY + "': " + (_hour_of_day == -1 ? "not found" : _hour_of_day));
}
_hour_of_day = defaultValue;
}
}
private void checkMinuteOfHour(int defaultValue)
{
if ((_minute_of_hour < 0) || (_minute_of_hour > 59))
{
if (defaultValue == -1)
{
throw new IllegalArgumentException("Illegal params for '" + FIELD_MINUTE_OF_HOUR + "': " + (_minute_of_hour == -1 ? "not found" : _minute_of_hour));
}
_minute_of_hour = defaultValue;
}
}
}

View File

@@ -79,7 +79,7 @@ public final class AuctionItem
{
final L2ItemInstance item = ItemTable.getInstance().createItem("ItemAuction", _itemId, _itemCount, null, null);
item.setEnchantLevel(item.getDefaultEnchantLevel());
item.setEnchantLevel(item.getItem().getDefaultEnchantLevel());
final int augmentationId = _itemExtra.getInt("augmentation_id", 0);
if (augmentationId > 0)

View File

@@ -1,65 +1,65 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Forsaiken
*/
public final class ItemAuctionBid
{
private final int _playerObjId;
private long _lastBid;
public ItemAuctionBid(int playerObjId, long lastBid)
{
_playerObjId = playerObjId;
_lastBid = lastBid;
}
public final int getPlayerObjId()
{
return _playerObjId;
}
public final long getLastBid()
{
return _lastBid;
}
final void setLastBid(long lastBid)
{
_lastBid = lastBid;
}
final void cancelBid()
{
_lastBid = -1;
}
final boolean isCanceled()
{
return _lastBid <= 0;
}
final L2PcInstance getPlayer()
{
return L2World.getInstance().getPlayer(_playerObjId);
}
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Forsaiken
*/
public final class ItemAuctionBid
{
private final int _playerObjId;
private long _lastBid;
public ItemAuctionBid(int playerObjId, long lastBid)
{
_playerObjId = playerObjId;
_lastBid = lastBid;
}
public final int getPlayerObjId()
{
return _playerObjId;
}
public final long getLastBid()
{
return _lastBid;
}
final void setLastBid(long lastBid)
{
_lastBid = lastBid;
}
final void cancelBid()
{
_lastBid = -1;
}
final boolean isCanceled()
{
return _lastBid <= 0;
}
final L2PcInstance getPlayer()
{
return L2World.getInstance().getPlayer(_playerObjId);
}
}

View File

@@ -1,29 +1,29 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
/**
* @author DS
*/
public enum ItemAuctionExtendState
{
INITIAL,
EXTEND_BY_5_MIN,
EXTEND_BY_3_MIN,
EXTEND_BY_CONFIG_PHASE_A,
EXTEND_BY_CONFIG_PHASE_B;
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
/**
* @author DS
*/
public enum ItemAuctionExtendState
{
INITIAL,
EXTEND_BY_5_MIN,
EXTEND_BY_3_MIN,
EXTEND_BY_CONFIG_PHASE_A,
EXTEND_BY_CONFIG_PHASE_B
}

View File

@@ -1,51 +1,51 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
/**
* @author Forsaiken
*/
public enum ItemAuctionState
{
CREATED((byte) 0),
STARTED((byte) 1),
FINISHED((byte) 2);
private final byte _stateId;
private ItemAuctionState(byte stateId)
{
_stateId = stateId;
}
public byte getStateId()
{
return _stateId;
}
public static ItemAuctionState stateForStateId(byte stateId)
{
for (ItemAuctionState state : ItemAuctionState.values())
{
if (state.getStateId() == stateId)
{
return state;
}
}
return null;
}
/*
* This file is part of the L2J Mobius project.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.itemauction;
/**
* @author Forsaiken
*/
public enum ItemAuctionState
{
CREATED((byte) 0),
STARTED((byte) 1),
FINISHED((byte) 2);
private final byte _stateId;
ItemAuctionState(byte stateId)
{
_stateId = stateId;
}
public byte getStateId()
{
return _stateId;
}
public static ItemAuctionState stateForStateId(byte stateId)
{
for (ItemAuctionState state : ItemAuctionState.values())
{
if (state.getStateId() == stateId)
{
return state;
}
}
return null;
}
}